Repository navigation
Conversation
av1_update() built the SVT-AV1 private parameter dictionary and then handed
it to av_opt_set_dict_val() under the name "svtav1_opts". That is the name of
the struct member the option is bound to, not the name of the option itself:
FFmpeg registers the dictionary as "svtav1-params".
{ "svtav1-params", "Set the SVT-AV1 configuration using a :-separated list
of key=value parameters", OFFSET(svtav1_opts), AV_OPT_TYPE_DICT, { 0 },
0, 0, VE },
The lookup therefore never matched, the dictionary was silently dropped, and
the return value was ignored.
That matters specifically for CBR. The SVT-AV1 CBR branch sets rc_min_rate
but deliberately leaves rc_max_rate at 0, so libsvtav1 derives rate control
from the codec context, and with rc_max_rate (0) != bit_rate it selects mode
1 (VBR). The rc=2 entry in the dictionary was the mechanism intended to
override that, so losing the dictionary left the encoder running VBR while
the UI reported CBR.
Two more entries only become reachable once the assignment actually works,
so they are corrected here as well:
* tbr was set to bitrate * 1000 (bits per second). SVT-AV1 parses an
unsuffixed tbr as kilobits per second, and libsvtav1 already copies
avctx->bit_rate into param->target_bit_rate before applying the private
dictionary. The entry is removed rather than rescaled.
* bias-pct is no longer registered by SVT-AV1 >= 2.0.0. The Windows
dependency set for OBS 32.2.2 ships SVT-AV1 2.3.0, so this entry would now
be rejected. It is removed.
The result of the assignment is no longer discarded: a failed assignment is
logged as a warning instead of silently leaving the encoder on the wrong
rate control mode.
Fixes obsproject#13849
Verification notesI checked this against the two CI gates this change can trip, and against the upstream sources the reasoning depends on. Format — Only Root cause — the two halves of the mechanism, read from FFmpeg
So the member and the option name are two different things, and For the CBR consequence, if (avctx->bit_rate) {
param->target_bit_rate = avctx->bit_rate;
if (avctx->rc_max_rate != avctx->bit_rate)
param->rate_control_mode = 1; /* VBR */
else
param->rate_control_mode = 2; /* CBR */
}OBS's CBR branch sets Model — I wrote a small executable model of the two behaviours (option-name lookup + the :240 derivation) so the reasoning can be run rather than just asserted. It reports, BEFORE: Still not done — no OBS build here, so no end-to-end encode. That needs CMake, Qt6 and the dependency set; if you would like that before merging, say so and I will set it up. |
|
slop |
Fixes #13849
av1_update()built the SVT-AV1 private parameter dictionary and then handed it toav_opt_set_dict_val()under the namesvtav1_opts. That is the name of the struct member the option is bound to, not the name of the option itself: FFmpeg registers the dictionary assvtav1-params.{ "svtav1-params", "Set the SVT-AV1 configuration using a :-separated list of key=value parameters", OFFSET(svtav1_opts), AV_OPT_TYPE_DICT, { 0 }, 0, 0, VE },The lookup therefore never matched, the dictionary was silently dropped, and the return value was ignored.
That matters specifically for CBR. The SVT-AV1 CBR branch sets
rc_min_ratebut deliberately leavesrc_max_rateat 0, solibsvtav1derives rate control from the codec context:With
rc_max_rate (0) != bit_rate, mode 1 (VBR) is selected. Therc=2entry in the dictionary was the mechanism intended to override that, so losing the dictionary left the encoder running VBR while the UI reported CBR.Two more entries in the same dictionary only become reachable once the assignment actually works, so they are corrected here as well:
tbrwas set tobitrate * 1000(bits per second). SVT-AV1 parses an unsuffixedtbras kilobits per second, andlibsvtav1already copiesavctx->bit_rateintoparam->target_bit_ratebefore it applies the private dictionary. The entry is removed rather than rescaled - the target bitrate keeps arriving throughAVCodecContext.bias-pctis no longer registered by SVT-AV1 >= 2.0.0. The Windows dependency set for OBS 32.2.2 ships SVT-AV1 2.3.0, so this entry would now be rejected. It is removed.The result of the assignment is no longer discarded: a failed assignment is logged as a warning instead of silently leaving the encoder on the wrong rate control mode.
Verification
masterandrelease/8.1: the AVOption issvtav1-params, and itsOFFSET()points at thesvtav1_optsmember.svtav1_optsis not itself an AVOption name.rc_max_rate/bit_ratederivation above was read from the same file (libavcodec/libsvtav1.c).Not covered
There is no encoder-level test here. Confirming the change end to end needs a build with SVT-AV1 and a CBR encode with the output bitrate measured. I have not built OBS locally yet - if you want that confirmation before merging, tell me the build/test path you prefer and I will follow up. I am also happy to split the
tbr/bias-pctremovals into a separate PR if you would rather take the option-name fix on its own.