From 72f801619a1ae91969fee9a7d72519422433c998 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 29 Sep 2012 06:31:18 +0200 Subject: movenc: Adjust edit lists to trim out parts of tracks with negative pts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ö --- libavformat/movenc.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libavformat/movenc.c') diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 6c95b4b3aa..4017a56158 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 */ -- cgit v1.2.3