[FFmpeg-devel] [PATCH] ffmpeg: Integrate two checks

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Tue Jul 2 00:04:43 EEST 2019


For audio packets with dts != AV_NOPTS_VALUE the dts the dts was
converted twice to the muxer's timebase during streamcopy, once as a
normal packet and once specifically as an audio packet. This has been
changed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
You are right. Seems that this is not covered by fate.

 fftools/ffmpeg.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 01f04103cf..f81b1b3983 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2044,20 +2044,19 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
     else
         opkt.pts = AV_NOPTS_VALUE;
 
-    if (pkt->dts == AV_NOPTS_VALUE)
+    if (pkt->dts == AV_NOPTS_VALUE) {
         opkt.dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ost->mux_timebase);
-    else
-        opkt.dts = av_rescale_q(pkt->dts, ist->st->time_base, ost->mux_timebase);
-    opkt.dts -= ost_tb_start_time;
-
-    if (ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && pkt->dts != AV_NOPTS_VALUE) {
+    } else if (ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
         int duration = av_get_audio_frame_duration(ist->dec_ctx, pkt->size);
         if(!duration)
             duration = ist->dec_ctx->frame_size;
-        opkt.dts = opkt.pts = av_rescale_delta(ist->st->time_base, pkt->dts,
-                                               (AVRational){1, ist->dec_ctx->sample_rate}, duration, &ist->filter_in_rescale_delta_last,
-                                               ost->mux_timebase) - ost_tb_start_time;
-    }
+        opkt.dts = av_rescale_delta(ist->st->time_base, pkt->dts,
+                                    (AVRational){1, ist->dec_ctx->sample_rate}, duration,
+                                    &ist->filter_in_rescale_delta_last, ost->mux_timebase);
+        opkt.pts = opkt.dts - ost_tb_start_time;
+    } else
+        opkt.dts = av_rescale_q(pkt->dts, ist->st->time_base, ost->mux_timebase);
+    opkt.dts -= ost_tb_start_time;
 
     opkt.duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->mux_timebase);
 
-- 
2.21.0



More information about the ffmpeg-devel mailing list