Browse code

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@gmx.at>

Kari Lentz authored on 2012/08/25 04:37:47
Showing 1 changed files
... ...
@@ -1913,6 +1913,24 @@ static int mov_write_string_metadata(AVFormatContext *s, AVIOContext *pb,
1913 1913
     return mov_write_string_tag(pb, name, t->value, lang, long_style);
1914 1914
 }
1915 1915
 
1916
+/* iTunes bpm number */
1917
+static int mov_write_tmpo_tag(AVIOContext *pb, AVFormatContext *s)
1918
+{
1919
+    AVDictionaryEntry *t = av_dict_get(s->metadata, "tmpo", NULL, 0);
1920
+    int size = 0, tmpo = t ? atoi(t->value) : 0;
1921
+    if (tmpo) {
1922
+        size = 26;
1923
+        avio_wb32(pb, size);
1924
+        ffio_wfourcc(pb, "tmpo");
1925
+        avio_wb32(pb, size-8); /* size */
1926
+        ffio_wfourcc(pb, "data");
1927
+        avio_wb32(pb, 0x15);  //type specifier
1928
+        avio_wb32(pb, 0);
1929
+        avio_wb16(pb, tmpo);        // data
1930
+    }
1931
+    return size;
1932
+}
1933
+
1916 1934
 /* iTunes track number */
1917 1935
 static int mov_write_trkn_tag(AVIOContext *pb, MOVMuxContext *mov,
1918 1936
                               AVFormatContext *s)
... ...
@@ -1960,6 +1978,7 @@ static int mov_write_ilst_tag(AVIOContext *pb, MOVMuxContext *mov,
1960 1960
     mov_write_string_metadata(s, pb, "tven",    "episode_id",1);
1961 1961
     mov_write_string_metadata(s, pb, "tvnn",    "network"  , 1);
1962 1962
     mov_write_trkn_tag(pb, mov, s);
1963
+    mov_write_tmpo_tag(pb, s);
1963 1964
     return update_size(pb, pos);
1964 1965
 }
1965 1966