Skip to content

Commit

Permalink
set b_ref_mode=0 for ffmpeg NVENC encoder (#2074)
Browse files Browse the repository at this point in the history
Older NVIDIA cards (e.g. GTX 1650) don't support this feature, and
ffmpeg somehow force-enabled it, despite docs saying it should be set to
"auto", and --help saying the default is "disabled". Setting it to
"disabled" in the encoder works around this issue.

ALVR does not currently use multiple B frames, so there should be no
difference and no obvious difference was visible when testing.

The feature is documented as:
"Using B frame as a reference improves subjective and objective encoded
quality with no performance impact. Hence the users enabling multiple B
frames are strongly recommended to enable this feature."

Co-authored-by: David Rosca <[email protected]>
  • Loading branch information
Xaphiosis and nowrep authored Apr 20, 2024
1 parent dfadf6c commit 109f394
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions alvr/server/cpp/platform/linux/EncodePipelineNvEnc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ alvr::EncodePipelineNvEnc::EncodePipelineNvEnc(Renderer *render,
// Delay isn't actually a delay instead its how many surfaces to encode at a time
av_opt_set_int(encoder_ctx->priv_data, "delay", 1, 0);
av_opt_set_int(encoder_ctx->priv_data, "forced-idr", 1, 0);
// work around ffmpeg default not working for older NVIDIA cards
av_opt_set_int(encoder_ctx->priv_data, "b_ref_mode", 0, 0);

encoder_ctx->pix_fmt = AV_PIX_FMT_CUDA;
encoder_ctx->width = width;
Expand Down

0 comments on commit 109f394

Please sign in to comment.