[FFmpeg-cvslog] mov: Fix wrong timestamp generation for fragmented movies that have time offset caused by the first edit list entry .

Yusuke Nakamura git at videolan.org
Sat Jun 11 04:16:52 CEST 2011


ffmpeg | branch: master | Yusuke Nakamura <muken.the.vfrmaniac at gmail.com> | Fri May 13 23:46:48 2011 +0900| [f33a6a22b4f2382a5113194335ae2a22ae957fed] | committer: Anton Khirnov

mov: Fix wrong timestamp generation for fragmented movies that have time offset caused by the first edit list entry.

Signed-off-by: Anton Khirnov <anton at khirnov.net>

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

 libavformat/mov.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 4d3f4f6..ab5c4e2 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1532,8 +1532,9 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
 
     /* adjust first dts according to edit list */
     if (sc->time_offset && mov->time_scale > 0) {
-        int rescaled = sc->time_offset < 0 ? av_rescale(sc->time_offset, sc->time_scale, mov->time_scale) : sc->time_offset;
-        current_dts = -rescaled;
+        if (sc->time_offset < 0)
+            sc->time_offset = av_rescale(sc->time_offset, sc->time_scale, mov->time_scale);
+        current_dts = -sc->time_offset;
         if (sc->ctts_data && sc->stts_data &&
             sc->ctts_data[0].duration / sc->stts_data[0].duration > 16) {
             /* more than 16 frames delay, dts are likely wrong
@@ -2063,7 +2064,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 
     if (flags & 0x001) data_offset        = avio_rb32(pb);
     if (flags & 0x004) first_sample_flags = avio_rb32(pb);
-    dts = st->duration;
+    dts = st->duration - sc->time_offset;
     offset = frag->base_data_offset + data_offset;
     distance = 0;
     av_dlog(c->fc, "first sample flags 0x%x\n", first_sample_flags);
@@ -2092,7 +2093,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         offset += sample_size;
     }
     frag->moof_offset = offset;
-    st->duration = dts;
+    st->duration = dts + sc->time_offset;
     return 0;
 }
 



More information about the ffmpeg-cvslog mailing list