[FFmpeg-cvslog] movenc: support for itunes tempo tag

Kari Lentz git at videolan.org
Mon Aug 27 19:07:09 CEST 2012


ffmpeg | branch: master | Kari Lentz <kari.k.lentz at gmail.com> | Fri Aug 24 15:37:47 2012 -0400| [be862c0dac356dc94451f64469c8abc866d8e00e] | committer: Michael Niedermayer

movenc: support for itunes tempo tag

Implements support for tmpo atom for mp4 files, typically used to store BPM.  -metadata "tmpo=127" as a command line option will record 127 as the BPM in the meta data.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavformat/movenc.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 695bd43..9ccee2c 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1913,6 +1913,24 @@ static int mov_write_string_metadata(AVFormatContext *s, AVIOContext *pb,
     return mov_write_string_tag(pb, name, t->value, lang, long_style);
 }
 
+/* iTunes bpm number */
+static int mov_write_tmpo_tag(AVIOContext *pb, AVFormatContext *s)
+{
+    AVDictionaryEntry *t = av_dict_get(s->metadata, "tmpo", NULL, 0);
+    int size = 0, tmpo = t ? atoi(t->value) : 0;
+    if (tmpo) {
+        size = 26;
+        avio_wb32(pb, size);
+        ffio_wfourcc(pb, "tmpo");
+        avio_wb32(pb, size-8); /* size */
+        ffio_wfourcc(pb, "data");
+        avio_wb32(pb, 0x15);  //type specifier
+        avio_wb32(pb, 0);
+        avio_wb16(pb, tmpo);        // data
+    }
+    return size;
+}
+
 /* iTunes track number */
 static int mov_write_trkn_tag(AVIOContext *pb, MOVMuxContext *mov,
                               AVFormatContext *s)
@@ -1960,6 +1978,7 @@ static int mov_write_ilst_tag(AVIOContext *pb, MOVMuxContext *mov,
     mov_write_string_metadata(s, pb, "tven",    "episode_id",1);
     mov_write_string_metadata(s, pb, "tvnn",    "network"  , 1);
     mov_write_trkn_tag(pb, mov, s);
+    mov_write_tmpo_tag(pb, s);
     return update_size(pb, pos);
 }
 



More information about the ffmpeg-cvslog mailing list