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

Linux: Specify rate control params for software encoding #1393

Merged
merged 2 commits into from
Jan 21, 2023

Conversation

deiteris
Copy link
Collaborator

No description provided.

Copy link
Collaborator

@nowrep nowrep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now

@Vixea Vixea merged commit 7ab85d9 into alvr-org:master Jan 21, 2023
@deiteris
Copy link
Collaborator Author

deiteris commented Jan 21, 2023

Wait, why divide by 10? The buffer is going to be huge at some point (it's basically a 10 seconds buffer now). What is wrong with 1 frame buffer size?

@nowrep
Copy link
Collaborator

nowrep commented Jan 21, 2023

What is wrong with 1 frame buffer size?

It degrades image quality a lot with sw encoder (x264).

@deiteris
Copy link
Collaborator Author

deiteris commented Jan 21, 2023

I think better logic would be to use encoder_ctx->bit_rate / settings.m_refreshRate * n then, where n is number of buffered frames and find the number that is ok, just to make it consistent. For our case, it normally should be 1.1 frame because of low latency requirement (and maybe for all other encoders too actually. AMD's LCVBR suggests using from 1.1 to 3 frames here), but if some other value works better for x264, then we can keep it more than 1.1.

@nowrep
Copy link
Collaborator

nowrep commented Jan 21, 2023

encoder_ctx->bit_rate / settings.m_refreshRate * 1.1 actually does work, but the result is exactly the same as bit_rate/10 or leaving it at the default value.
In any case, "improving" sw encode is pointless until it works without forcing all idr anyway. openh264 works fine with p-frames but also the encoder is very slow.

@deiteris
Copy link
Collaborator Author

deiteris commented Jan 21, 2023

Well, it's not only about improving sw encoding, but also other encoders should have this value set properly :) It can be better in terms of quality, but is it the same in terms of latency? Because /10 is a 10 seconds buffer (basically refresh rate * 10 number of frames), and default is whatever the codec uses (it may be large for some bitrate and may be small for the other).

@nowrep
Copy link
Collaborator

nowrep commented Jan 21, 2023

The latency and image quality is exactly the same for any value >= encoder_ctx->bit_rate / settings.m_refreshRate * 1.1

@deiteris
Copy link
Collaborator Author

I'll try experimenting on Windows with different setups. I think that's the value that we might want to use for all encoders (and maybe min_bitrate is actually useless in that case).

zarik5 pushed a commit that referenced this pull request Feb 10, 2023
* Specify rate control params for software encoding

* x264 needs bigger buffer size

Co-authored-by: David Rosca <nowrep@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants