I am using libavcodec and the nvenc codec to encode a live video stream. I am using the following settings:
av_dict_set(&video_opts, "preset", "p3", 0);
av_dict_set(&video_opts, "tune", "ull", 0);
av_dict_set_int(&video_opts, "zerolatency", 1, 0);
videoCodecCtx->max_b_frames = 2;
videoCodecCtx->gop_size = 12;
The encoded live stream playback works fine. However whenever I want to change the bitrate by changing:
videoCodecCtx->bit_rate
videoCodecCtx->rc_max_rate
videoCodecCtx->rc_min_rate
videoCodecCtx->rc_buffer_size
this line in libavcodec/nvenc.c is triggered:
ret = p_nvenc->nvEncReconfigureEncoder(ctx->nvencoder, ¶ms);
and I get back the following error:
[h264_nvenc @ 0x55f36aeff040] failed to reconfigure nvenc: invalid param (8): Reconfiguration of number of B-frames not supported.
If I only use I frames and gop_size 0 or -1, this error is not triggered. I already checked the params of gop_length, idrPeriod and frameIntervalP. They don’t change. It’s not a bug in ffmpeg and not in the Video Codec SDK. It must be inside the actual nvenc library. I can’t track it down further, since I don’t have that source code. Any help is appreciated, since I can’t adapt the stream bitrate without it.