obs-nvenc: Only update Target Quality in CQVBR mode#13229
Open
Lordmau5 wants to merge 1 commit intoobsproject:masterfrom
Open
obs-nvenc: Only update Target Quality in CQVBR mode#13229Lordmau5 wants to merge 1 commit intoobsproject:masterfrom
Lordmau5 wants to merge 1 commit intoobsproject:masterfrom
Conversation
Previously it was setting the `averageBitRate` value to what is being set in Variable Bitrate rate control mode. However, CQVBR is initialized with a value of `0` and instead Target Quality is being used. This adds a check for the CQVBR mode and if it's set will update the `targetQuality` value, otherwise it will update the `averageBitRate` one.
DeeDeeG
reviewed
Mar 19, 2026
| enc->config.rcParams.averageBitRate = (uint32_t)enc->props.bitrate * 1000; | ||
| } | ||
|
|
||
| enc->config.rcParams.maxBitRate = (cqvbr || vbr) ? (uint32_t)enc->props.max_bitrate * 1000 |
Contributor
There was a problem hiding this comment.
Cool that this troubleshooting effort was able to proceed to a PR!
BTW, I think if cqvbr is true, then vbr is true (as enc->config.rcParams.rateControlMode == NV_ENC_PARAMS_RC_VBR should be true; no separate CQVBR rc mode according to the driver's logic, just RC_VBR). So, this line might not need updating from how it was, and you can have a smaller diff for this PR?
(I'm not able to test right now, but I'll drop another comment if I do get a chance later. Not that anyone should wait for me as I might not have time to.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Previously while CQVBR (Variable Bitrate with Target Quality) is enabled and the encoder is updated (e.g. changing target quality, b-frames, etc.) it was setting the
averageBitRatevalue to what is being set in Variable Bitrate rate control mode.However, CQVBR is initialized with a value of
0and instead Target Quality is being used. This adds a check for the CQVBR mode and if it's updated in the Output settings will update thetargetQualityvalue for the encoder, otherwise (if VBR is active) it will updateaverageBitRate.(It was also updating it internally when the Replay Buffer was started while a recording was on-going (or the other way around) since OBS is calling the
UpdateRecordingSettingsmethod)Big thanks to Bleuzen on the OBS Discord for spotting where in the code the issue is occuring.
Motivation and Context
Fixing the newly (32.0) added CQVBR / Variable Bitrate with Target Quality mode when using both Replay Buffer and Recording.
How Has This Been Tested?
Latest 32.1 portable instance - Setting the recording to CQVBR with a Target Quality of 20, then playing some high motion content and starting the recording, then observing the Stats window / dock. Afterwards either starting Replay Buffer or updating the Target Quality setting in the Output tab.
In the latest public build it will drop the bitrate massively (as in, to the average that is set in Variable Bitrate rate control mode).
Additionally the same in this build. However, updating the settings while this mode is active works properly.
Types of changes
Checklist: