On Tue, 9 Mar 2021, Martin Storsjö wrote:

Since a0949d0bcb0eee2f3fffcf9a4810c0295d14c0dc, the b-frames
setting defaults to -1, which uses the preset's default setting.

If b-frames are enabled, but max_b_frames is kept at <= 0, the
output dts are inconsistent.
---
libavcodec/nvenc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index a061dee880..6baeec6d36 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1380,8 +1380,11 @@ static av_cold int nvenc_setup_encoder(AVCodecContext 
*avctx)
    if (res < 0)
        return res;

-    if (ctx->encode_config.frameIntervalP > 1)
+    if (ctx->encode_config.frameIntervalP > 1) {
        avctx->has_b_frames = 2;
+        if (avctx->max_b_frames <= 0)
+            avctx->max_b_frames = 1;
+    }

Or maybe we just should change nvenc_set_timestamp to use has_b_frames instead if max_b_frames, iirc that's what's used to signal the number of frames to offset dts elsewhere?

Also, as long as the encoder doesn't use something like b-pyramid, shifting dts by 1 should be enough, regardless of the number of b-frames between p-frames.

// Martin
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to