[FFmpeg-cvslog] movenc: Adjust edit lists to trim out parts of tracks with negative pts

Michael Niedermayer git at videolan.org
Sun Oct 12 22:45:47 CEST 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat Sep 29 06:31:18 2012 +0200| [72f801619a1ae91969fee9a7d72519422433c998] | committer: Martin Storsjö

movenc: Adjust edit lists to trim out parts of tracks with negative pts

This makes sure that audio preroll for e.g. AAC is signaled correctly.

Previously we only wrote the edit list correctly if we had negative
dts but started with pts == 0 (e.g. for video with B-frames).

Signed-off-by: Martin Storsjö <martin at martin.st>

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

 libavformat/movenc.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 6c95b4b..4017a56 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1628,6 +1628,13 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVTrack *track)
             avio_wb32(pb, -1);
         }
         avio_wb32(pb, 0x00010000);
+    } else {
+        /* Avoid accidentally ending up with start_ct = -1 which has got a
+         * special meaning. Normally start_ct should end up positive or zero
+         * here, but use FFMIN in case dts is a a small positive integer
+         * rounded to 0 when represented in MOV_TIMESCALE units. */
+        start_ct  = -FFMIN(track->cluster[0].dts, 0);
+        duration += delay;
     }
 
     /* duration */



More information about the ffmpeg-cvslog mailing list