[FFmpeg-devel] [PATCH 1/2] lavf/mux: allow muxing non monotonic timestamps

Lukasz Marek lukasz.m.luki at gmail.com
Tue Dec 31 22:24:33 CET 2013


This is required by devices to avoid error when stream is seeked backward.

Signed-off-by: Lukasz Marek <lukasz.m.luki at gmail.com>
---
 libavformat/avformat.h | 2 ++
 libavformat/mux.c      | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 6d719d7..c64a71a 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -377,6 +377,8 @@ typedef struct AVProbeData {
                                         AVFormatContext.avoid_negative_ts
                                         */
 
+#define AVFMT_TS_ANY       0x80000 /**< Format allows muxing any (non monotonic) timestamps. */
+
 #define AVFMT_SEEK_TO_PTS   0x4000000 /**< Seeking is based on PTS */
 
 /**
diff --git a/libavformat/mux.c b/libavformat/mux.c
index f01b82b..e07644f 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -457,7 +457,7 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt)
         pkt->dts = st->pts_buffer[0];
     }
 
-    if (st->cur_dts && st->cur_dts != AV_NOPTS_VALUE &&
+    if (st->cur_dts && st->cur_dts != AV_NOPTS_VALUE && !(s->oformat->flags & AVFMT_TS_ANY) &&
         ((!(s->oformat->flags & AVFMT_TS_NONSTRICT) &&
           st->cur_dts >= pkt->dts) || st->cur_dts > pkt->dts)) {
         av_log(s, AV_LOG_ERROR,
-- 
1.8.3.2



More information about the ffmpeg-devel mailing list