[FFmpeg-devel] [PATCH 1/3] Round the mov track duration to 3 decimals.

Benjamin Larsson benjamin
Wed Mar 2 18:27:59 CET 2011


---
 libavformat/movenc.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 8feb06e..f816273 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1256,6 +1256,8 @@ static int mov_write_minf_tag(AVIOContext *pb, MOVTrack *track, int est_nb_frame
 
 static int mov_write_mdhd_tag(AVIOContext *pb, MOVTrack *track)
 {
+    uint64_t tmptrackDuration = av_rescale_rnd(track->trackDuration, MOV_TIMESCALE,
+                                track->timescale, AV_ROUND_UP) * track->timescale/MOV_TIMESCALE;
     int version = track->trackDuration < INT32_MAX ? 0 : 1;
 
     (version == 1) ? avio_wb32(pb, 44) : avio_wb32(pb, 32); /* size */
@@ -1270,7 +1272,7 @@ static int mov_write_mdhd_tag(AVIOContext *pb, MOVTrack *track)
         avio_wb32(pb, track->time); /* modification time */
     }
     avio_wb32(pb, track->timescale); /* time scale (sample rate for audio) */
-    (version == 1) ? avio_wb64(pb, track->trackDuration) : avio_wb32(pb, track->trackDuration); /* duration */
+    (version == 1) ? avio_wb64(pb, tmptrackDuration) : avio_wb32(pb, tmptrackDuration); /* duration */
     avio_wb16(pb, track->language); /* language */
     avio_wb16(pb, 0); /* reserved (quality) */
 
-- 
1.7.1




More information about the ffmpeg-devel mailing list