Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x264 encoder failing to initialize #124

Closed
PMohanJ opened this issue Dec 19, 2023 · 3 comments · Fixed by #132
Closed

x264 encoder failing to initialize #124

PMohanJ opened this issue Dec 19, 2023 · 3 comments · Fixed by #132
Labels
bug Something isn't working encoding Audio or video encoders but not the OS interfaces

Comments

@PMohanJ
Copy link
Member

PMohanJ commented Dec 19, 2023

The default software encoder x264 is failing to initialize while trying to access the desktop from browsers like brave and edge, saying the height not divisible by 2.

Here are some logs:
highlighted_logs

Brave browser's resolution: 1920x937
brave_browser

Edge browser's resolution: 1860x927
edge

But in chrome it's working fine as the pixels of height is even numbered: 1920x912
chrome

Client device details:

  • windows 11
  • Brave Version 1.61.104 Chromium: 120.0.6099.115 (Official Build) (64-bit)]
  • Microsoft Edge Version 120.0.2210.77 (Official build) (64-bit)
  • Chrome Version 120.0.6099.110 (Official Build) (64-bit)

Image used is: ghcr.io/selkies-project/selkies-gstreamer/gst-py-example:main-ubuntu20.04

@ehfd
Copy link
Member

ehfd commented Dec 20, 2023

Yeah, that is a known restriction in x264... The solution for now is to use an even viewport... I'll think of a solution.

@ehfd ehfd added bug Something isn't working encoding Audio or video encoders but not the OS interfaces high-priority Must be addressed as soon as possible, remove when resolved labels Dec 22, 2023
@PMohanJ
Copy link
Member Author

PMohanJ commented Dec 23, 2023

Hi @ehfd,

After looking into web-interface code part, I came across below logic where the height is being calculated.

parseInt((document.body.offsetHeight - document.body.offsetHeight%2) * window.devicePixelRatio)

It seems like the point of subtracting the offsetHeight%2 from offsetHeight is just to eliminate the odd numbered pixel.
If that's the case, the reason for me still ending up with odd number is..
The DevicePixelRation of my device is 1.25
brave browser offsetHeight=750 => (750 - 0) * 1.25 = 937.5

So if we just do that subtraction after the multiplication then problem solved. I've tried this and I no longer face that not divisible by 2 error.

Let me know what you think, I've got the changes ready for PR.

@ehfd
Copy link
Member

ehfd commented Dec 23, 2023

I totally remember that part of the code now... and your solution is right. PR it on!

@ehfd ehfd closed this as completed in #132 Dec 29, 2023
@ehfd ehfd removed the high-priority Must be addressed as soon as possible, remove when resolved label Jan 5, 2024
@ehfd ehfd mentioned this issue Mar 24, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working encoding Audio or video encoders but not the OS interfaces
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants