[FFmpeg-cvslog] mov: Implement parsing of the "HandlerName" from the MP4 HDLR atom

Hendrik Leppkes git at videolan.org
Tue Feb 3 22:26:03 CET 2015


ffmpeg | branch: master | Hendrik Leppkes <h.leppkes at gmail.com> | Tue Feb  3 14:58:50 2015 +0000| [e3528d2a7bf29ba148d7ac1678552ce0089cd14f] | committer: Vittorio Giovara

mov: Implement parsing of the "HandlerName" from the MP4 HDLR atom

This atom typically is used for a track title. The handler name is stored
as a Pascal string in the QT specs (first byte is the length of the string),
so do not export it.

A second length check based on the first character is added to avoid
overwriting an already specified handler_name (it happens with YouTube
videos for instance, the handler_name get masked), or specifying an
empty string metadata.

The Pascal string fix and the second length check are written
by Clément Bœsch <clement.boesch at smartjog.com>.

Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>
Signed-off-by: Luca Barbato <lu_zero at gentoo.org>

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

 libavformat/mov.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index c7d8782..7a140a8 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -558,6 +558,8 @@ static int mov_read_hdlr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     AVStream *st;
     uint32_t type;
     uint32_t av_unused ctype;
+    int64_t title_size;
+    char *title_str;
 
     if (c->fc->nb_streams < 1) // meta before first trak
         return 0;
@@ -587,6 +589,20 @@ static int mov_read_hdlr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     avio_rb32(pb); /* component flags */
     avio_rb32(pb); /* component flags mask */
 
+    title_size = atom.size - 24;
+    if (title_size > 0) {
+        title_str = av_malloc(title_size + 1); /* Add null terminator */
+        if (!title_str)
+            return AVERROR(ENOMEM);
+        avio_read(pb, title_str, title_size);
+        title_str[title_size] = 0;
+        if (title_str[0]) {
+            int off = (!c->isom && title_str[0] == title_size - 1);
+            av_dict_set(&st->metadata, "handler_name", title_str + off, 0);
+        }
+        av_freep(&title_str);
+    }
+
     return 0;
 }
 



More information about the ffmpeg-cvslog mailing list