[FFmpeg-cvslog] movenc: Timecode in MP4 Although MP4 does not have a concrete specification to store timecode information , the following technical note from Apple describes a way to achieve this via timecode track , similar to how it is done for MOV files.

Syed Andaleeb Roomy git at videolan.org
Sun Feb 28 04:26:35 CET 2016


ffmpeg | branch: master | Syed Andaleeb Roomy <andaleebcse at gmail.com> | Thu Jan 21 07:08:09 2016 +0100| [b4dcd351ec50caaa484bc5c66b4a8d5557a0f1ea] | committer: Michael Niedermayer

movenc: Timecode in MP4 Although MP4 does not have a concrete specification to store timecode information, the following technical note from Apple describes a way to achieve this via timecode track, similar to how it is done for MOV files.

https://developer.apple.com/library/mac/technotes/tn2174/_index.html

- Enabled creation of timecode tracks for MP4 in the same way as MOV.
- Used nmhd as media information header of timecode track of MP4 instead
  of gmhd used in MOV, thus avoiding tcmi also, as recommended above.
- Bypassed adding source reference field for MP4, as suggested above.

Issue: https://trac.ffmpeg.org/ticket/4704

Signed-off-by: Syed Andaleeb Roomy <andaleebcse at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavformat/movenc.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index e0223b2..3295266 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1866,7 +1866,7 @@ static int mov_write_tmcd_tag(AVIOContext *pb, MOVTrack *track)
     if (track->st)
         t = av_dict_get(track->st->metadata, "reel_name", NULL, 0);
 
-    if (t && utf8len(t->value))
+    if (t && utf8len(t->value) && track->mode != MODE_MP4)
         mov_write_source_reference_tag(pb, track, t->value);
     else
         avio_wb16(pb, 0); /* zero size */
@@ -2246,7 +2246,10 @@ static int mov_write_minf_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *tra
     } else if (track->tag == MKTAG('r','t','p',' ')) {
         mov_write_hmhd_tag(pb);
     } else if (track->tag == MKTAG('t','m','c','d')) {
-        mov_write_gmhd_tag(pb, track);
+        if (track->mode == MODE_MP4)
+            mov_write_nmhd_tag(pb);
+        else
+            mov_write_gmhd_tag(pb, track);
     }
     if (track->mode == MODE_MOV) /* FIXME: Why do it for MODE_MOV only ? */
         mov_write_hdlr_tag(pb, NULL);
@@ -5185,7 +5188,7 @@ static int mov_write_header(AVFormatContext *s)
         }
     }
 
-    if (mov->mode == MODE_MOV) {
+    if (mov->mode == MODE_MOV || mov->mode == MODE_MP4) {
         tmcd_track = mov->nb_streams;
 
         /* +1 tmcd track for each video stream with a timecode */



More information about the ffmpeg-cvslog mailing list