aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/movenc.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2014-10-12 00:24:31 +0300
committerMartin Storsjö <martin@martin.st>2014-11-07 14:50:06 +0200
commit9cbf70fa0e44613590b019cef1fe99aa3f3c5d9d (patch)
tree2ae5c15f18f7a12d6bb9519da9a5347dc2fa9a81 /libavformat/movenc.c
parente7d20f12c5eff5570cd897f3ce3a88456024036b (diff)
downloadffmpeg-9cbf70fa0e44613590b019cef1fe99aa3f3c5d9d.tar.gz
movenc: Write correct presentation timestamps in tfra
Previously we wrote decoding timestamps here, while the specs say it should be presentation timestamps. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/movenc.c')
-rw-r--r--libavformat/movenc.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 96bb8851a0..3b7f5aea55 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -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);