[FFmpeg-devel] Suggested Patch for timecode timebase calculation in mov.c

jon jon at tweaksoftware.com
Tue Sep 9 21:01:23 CEST 2014


Hi ffmpeg developers.

I am still new to attempting contributing here, so please let me know if 
there is a better approach for this. I am attaching a patch I would like 
to incorporate for calculating the stream time_base of the timecode data 
track in mov's. Please advise.

Thanks!
-------------- next part --------------
>From 5ae0b5a9cf9c37e11d5a3fea05c80c66b7c00c3e Mon Sep 17 00:00:00 2001
From: Jon Morley <jon at tweaksoftware.com>
Date: Tue, 9 Sep 2014 11:48:02 -0700
Subject: [PATCH] libavformat/mov.c: Set stream time_base from
 frameduration/timescale

Use tmcd atom's timescale and frameduration to for stream time base
instead of 1/framenum. For timecode streams that have an entry for each
frame 1/framenum is less accurate than frameduration/timescale.
---
 libavformat/mov.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index ae48c02..c300dd2 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1530,8 +1530,10 @@ static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb,
             tmcd_ctx->tmcd_flags = val;
             if (val & 1)
                 st->codec->flags2 |= CODEC_FLAG2_DROP_FRAME_TIMECODE;
-            st->codec->time_base.den = st->codec->extradata[16]; /* number of frame */
-            st->codec->time_base.num = 1;
+            int timescale = AV_RB32(st->codec->extradata + 8);
+            int framedur  =  AV_RB32(st->codec->extradata + 12);
+            st->codec->time_base.den = timescale;
+            st->codec->time_base.num = framedur;            
             if (size > 30) {
                 uint32_t len = AV_RB32(st->codec->extradata + 18); /* name atom length */
                 uint32_t format = AV_RB32(st->codec->extradata + 22);
-- 
1.8.5.2 (Apple Git-48)



More information about the ffmpeg-devel mailing list