[FFmpeg-devel] [PATCH 2/3] lavf/movenc: fix writing of some iTunes metadata tag

Matthieu Bouron matthieu.bouron at gmail.com
Wed Jul 3 10:56:23 CEST 2013


On Tue, Jul 02, 2013 at 10:42:29PM +0200, Michael Niedermayer wrote:
> On Tue, Jul 02, 2013 at 09:21:51PM +0200, Matthieu Bouron wrote:
> > On Tue, Jul 2, 2013 at 7:01 PM, Michael Niedermayer <michaelni at gmx.at>wrote:
> > 
> > > On Sun, Jun 30, 2013 at 04:15:45PM +0200, Matthieu Bouron wrote:
> > > > Fix metadata display under iTunes for files using pgap, hdvd, stick,
> > > > tvsn and tves tags.
> > > > ---
> > > >  libavformat/movenc.c | 13 +++++++++++--
> > > >  1 file changed, 11 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> > > > index 8cf7fdc..5577530 100644
> > > > --- a/libavformat/movenc.c
> > > > +++ b/libavformat/movenc.c
> > > > @@ -2046,16 +2046,25 @@ static int
> > > mov_write_int8_metadata(AVFormatContext *s, AVIOContext *pb,
> > > >  {
> > > >      AVDictionaryEntry *t = NULL;
> > > >      uint8_t num;
> > > > +    int size = 25 + 3 * (len == 4);
> > >
> > > 24 + len
> > >
> > 
> > Size include the real data size (1byte or 3 padding byte + 1 byte), the
> > resulting size is either 25 or 28.
> > [ 4b size ] [ 4b "name" ] [ 4b data size ] [ 4b "data" ] [ 4b data type ] [
> > 4b flags ] [ (1b or 4b) data value ]
> 
> 24 + len is as correct as yours, they give the same values.
> Iam fine with either but i thought 24 + len is simpler and clearer

I totally misread your first reply :(
Sure 24 + len is correct and lot more clearer.
Updated patch attached.

Thanks,
Matthieu

[...]
-------------- next part --------------
>From fa3e90030c68774b7daae143bbd058b80874337b Mon Sep 17 00:00:00 2001
From: Matthieu Bouron <matthieu.bouron at gmail.com>
Date: Sat, 29 Jun 2013 17:56:49 +0200
Subject: [PATCH 1/2] lavf/movenc: fix writing of some iTunes metadata tag

Fix metadata display under iTunes for files using pgap, hdvd, stick,
tvsn and tves tags.
---
 libavformat/movenc.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index c19d58d..5d224bc 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2046,16 +2046,25 @@ static int mov_write_int8_metadata(AVFormatContext *s, AVIOContext *pb,
 {
     AVDictionaryEntry *t = NULL;
     uint8_t num;
+    int size = 24 + len;
+
+    if (len != 1 && len != 4)
+        return -1;
 
     if (!(t = av_dict_get(s->metadata, tag, NULL, 0)))
         return 0;
     num = atoi(t->value);
 
-    avio_wb32(pb, len+8);
+    avio_wb32(pb, size);
     ffio_wfourcc(pb, name);
+    avio_wb32(pb, size - 8);
+    ffio_wfourcc(pb, "data");
+    avio_wb32(pb, 0x15);
+    avio_wb32(pb, 0);
     if (len==4) avio_wb32(pb, num);
     else        avio_w8 (pb, num);
-    return len+8;
+
+    return size;
 }
 
 /* iTunes meta data list */
-- 
1.8.3.1



More information about the ffmpeg-devel mailing list