[FFmpeg-devel] [PATCH] ffmpeg: replace missing PTS by DTS

Michael Niedermayer michaelni at gmx.at
Tue Sep 23 03:21:30 CEST 2014


This fixes the case where muxing fails hard in case of stream copying damaged input

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 ffmpeg.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/ffmpeg.c b/ffmpeg.c
index 47a4144..5492cfe 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -670,6 +670,14 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
                      - FFMIN3(pkt->pts, pkt->dts, ost->last_mux_dts + 1)
                      - FFMAX3(pkt->pts, pkt->dts, ost->last_mux_dts + 1);
         }
+        if (pkt->dts != AV_NOPTS_VALUE &&
+            pkt->pts == AV_NOPTS_VALUE &&
+            !(s->oformat->flags & AVFMT_TS_NONSTRICT)) { //FIXME use a AVFMT_TS_NEEDS_PTS
+            av_log(s, AV_LOG_WARNING, "PTS unknown, using DTS: %"PRId64" in output stream %d:%d\n",
+                   pkt->dts,
+                   ost->file_index, ost->st->index);
+            pkt->pts = pkt->dts;
+        }
      if(
         (avctx->codec_type == AVMEDIA_TYPE_AUDIO || avctx->codec_type == AVMEDIA_TYPE_VIDEO) &&
         pkt->dts != AV_NOPTS_VALUE &&
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list