]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/nvenc: base timestamps on frameIntervalP
authorMartin Storsjö <martin@martin.st>
Fri, 12 Mar 2021 20:42:02 +0000 (22:42 +0200)
committerTimo Rothenpieler <timo@rothenpieler.org>
Fri, 12 Mar 2021 21:11:39 +0000 (22:11 +0100)
If b-frames were enabled implicitly (if max_b_frames wasn't set by
the caller at all, since a0949d0bcb0eee2f3fffcf9a4810c0295d14c0dc),
we wouldn't offset dts at all, producing invalid pts/dts combinations
(causing loud warnings by ffmpeg, or muxer errors if passed without
an extra cleanup pass).

Instead use frameIntervalP for offsetting, which should always be
accurate.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
libavcodec/nvenc.c

index a061dee880a638fcecfdcc0e5ce300ce93983b46..fbf55ebc9d518b938d63d4d0043cdd3b8a000efb 100644 (file)
@@ -1921,7 +1921,7 @@ static int nvenc_set_timestamp(AVCodecContext *avctx,
     pkt->pts = params->outputTimeStamp;
     pkt->dts = timestamp_queue_dequeue(ctx->timestamp_list);
 
-    pkt->dts -= FFMAX(avctx->max_b_frames, 0) * FFMAX(avctx->ticks_per_frame, 1);
+    pkt->dts -= FFMAX(ctx->encode_config.frameIntervalP - 1, 0) * FFMAX(avctx->ticks_per_frame, 1);
 
     return 0;
 }