]> git.sesse.net Git - ffmpeg/commitdiff
movenc: Write correct presentation timestamps in tfra
authorMartin Storsjö <martin@martin.st>
Sat, 11 Oct 2014 21:24:31 +0000 (00:24 +0300)
committerMartin Storsjö <martin@martin.st>
Fri, 7 Nov 2014 12:50:06 +0000 (14:50 +0200)
Previously we wrote decoding timestamps here, while the specs
say it should be presentation timestamps.

Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/movenc.c
libavformat/version.h

index 96bb8851a0bcc061320f8ead29045251a832c017..3b7f5aea551a02bd34a105ba99da9d32d8452d81 100644 (file)
@@ -3018,6 +3018,17 @@ static int mov_flush_fragment(AVFormatContext *s)
             info = &track->frag_info[track->nb_frag_info - 1];
             info->offset   = avio_tell(s->pb);
             info->time     = track->frag_start;
+            if (track->entry) {
+                // Try to recreate the original pts for the first packet
+                // from the fields we have stored
+                info->time = track->start_dts + track->frag_start +
+                             track->cluster[0].cts;
+                // If the pts is less than zero, we will have trimmed
+                // away parts of the media track using an edit list,
+                // and the corresponding start presentation time is zero.
+                if (info->time < 0)
+                    info->time = 0;
+            }
             info->duration = duration;
             mov_write_tfrf_tags(s->pb, mov, track);
 
index c477d5d49c316364480974dfa72c0c4999116da0..f8c5edbd9f1a23249e8107deb0e57ac011573ec2 100644 (file)
@@ -31,7 +31,7 @@
 
 #define LIBAVFORMAT_VERSION_MAJOR 56
 #define LIBAVFORMAT_VERSION_MINOR  6
-#define LIBAVFORMAT_VERSION_MICRO  3
+#define LIBAVFORMAT_VERSION_MICRO  4
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                LIBAVFORMAT_VERSION_MINOR, \