[FFmpeg-devel] [PATCH] read reel_name metadata from tmcd atom

Mark Reid mindmark at gmail.com
Wed Aug 6 22:25:08 CEST 2014


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

diff --git a/libavformat/mov.c b/libavformat/mov.c
index ab85918..fb8d1fe 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1529,6 +1529,26 @@ static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb,
                 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;
+            if (size > 26) {
+                uint32_t len = AV_RB32(st->codec->extradata + 18); /* name atom length */
+                uint32_t format = AV_RB32(st->codec->extradata + 22);
+                if (format == AV_RB32("name") && size >= 18 + len) {
+                    uint16_t str_size = AV_RB16(st->codec->extradata + 26); /* string length */
+                    char *reel_name = av_malloc(str_size + 1);
+                    if (!reel_name)
+                        return AVERROR(ENOMEM);
+                    memcpy(reel_name, st->codec->extradata + 30, str_size);
+                    reel_name[str_size] = 0; /* Add null terminator */
+                    /* don't add reel_name if emtpy string */
+                    if (strcmp(reel_name, "") == 0) {
+                        av_free(reel_name);
+                    }
+                    else
+                    {
+                        av_dict_set(&st->metadata, "reel_name", reel_name,  AV_DICT_DONT_STRDUP_VAL);
+                    }
+                }
+            }
         }
     } else {
         /* other codec type, just skip (rtp, mp4s ...) */
-- 
2.0.0



More information about the ffmpeg-devel mailing list