[FFmpeg-cvslog] ffmpeg: prevent pts < dts to be passed through to the muxer on stream copy

Michael Niedermayer git at videolan.org
Tue Jun 10 00:39:03 CEST 2014


ffmpeg | branch: release/2.2 | Michael Niedermayer <michaelni at gmx.at> | Thu Jun  5 18:37:32 2014 +0200| [8c33d40a7b8a44f550a1fb11a082a95aaa606284] | committer: Carl Eugen Hoyos

ffmpeg: prevent pts < dts to be passed through to the muxer on stream copy

Fixes Ticket3658

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit 27856b2fe9cdbcf48ad996647cb104667b373fa4)

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

 ffmpeg.c |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 5caac1f..5463f06 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -621,7 +621,8 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
         bsfc = bsfc->next;
     }
 
-    if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS) &&
+    if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) {
+     if(
         (avctx->codec_type == AVMEDIA_TYPE_AUDIO || avctx->codec_type == AVMEDIA_TYPE_VIDEO) &&
         pkt->dts != AV_NOPTS_VALUE &&
         ost->last_mux_dts != AV_NOPTS_VALUE) {
@@ -642,6 +643,16 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
             pkt->pts = FFMAX(pkt->pts, max);
         pkt->dts = max;
       }
+     }
+        if (pkt->dts != AV_NOPTS_VALUE &&
+            pkt->pts != AV_NOPTS_VALUE &&
+            pkt->dts > pkt->pts) {
+            av_log(s, AV_LOG_WARNING, "Invalid DTS: %"PRId64" PTS: %"PRId64" in output stream %d:%d\n",
+                   pkt->dts, pkt->pts,
+                   ost->file_index, ost->st->index);
+            pkt->pts = AV_NOPTS_VALUE;
+            pkt->dts = AV_NOPTS_VALUE;
+        }
     }
     ost->last_mux_dts = pkt->dts;
 



More information about the ffmpeg-cvslog mailing list