[FFmpeg-cvslog] avcodec/nvenc: base timestamps on frameIntervalP

Martin Storsjö git at videolan.org
Fri Mar 12 23:24:44 EET 2021


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Fri Mar 12 22:42:02 2021 +0200| [30cd7feb2dd497b16edb6d7c09a83eb49f89645d] | committer: Timo Rothenpieler

avcodec/nvenc: base timestamps on frameIntervalP

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 at rothenpieler.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=30cd7feb2dd497b16edb6d7c09a83eb49f89645d
---

 libavcodec/nvenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index a061dee880..fbf55ebc9d 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -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;
 }



More information about the ffmpeg-cvslog mailing list