[FFmpeg-devel] [PATCH] new generic metadata API

Michael Niedermayer michaelni
Tue Sep 23 15:21:43 CEST 2008


On Mon, Sep 22, 2008 at 12:24:36AM +0200, Aurelien Jacobs wrote:
> Hi,
> 
> A generic metadata API was queried several times... Now, here it is !
>  - The first patch add the new API itself. It contains a compatibility
>    layer so that software using the old API will still work.
>    It also contains the appropriate #if, so that the old API and the
>    compatibility layer will disappear after next lavf major bump.
>  - The second patch changes all the muxers/demuxers to use the new API.
>  - The third patch changes ffmpeg.c, ffplay.c and ffserver.c to use
>    the new API.
> 
> Basically, this API allows to associate random string value to random
> string name, for AVFormatContext, AVStream, AVChapter and AVProgram.
> It also supports more advanced features, such as recursive metadata,
> and multiple tags with the same name.
> For an example usage of such features, here is what matroska can
> contain:
> 
> BAND
> - LEADPERFORMER
> -- ADDRESS
> --- DATE
> --- DATEEND
> -- ADDRESS
> --- DATE
> 
> I hope this new API will fit everyone needs.

A few random comments ...
how is the language/country code ofthe string specified?
(german vs english titles and names ...)

Are title vs. Title vs. Name vs. name handled when things differ from
src & dst containers?

What about formats that support generic user defined key-value metadata but
do not support tree style metadata?
I think such formats should have the whole tree stored in a flattened form,
and where one is described in the format spec in the described format.

That is
instead of just storing
"BAND"="the fobar"
it should store:
"BAND"="the fobar"
"BAND/ADDRESS"="foo street 123"
if this info is available ...

It thus may make sense to have some kind of support in the API to store and
load such flattened metadata.
This also could come in handy for getting metadata from the commend line into
the internal structs, which AFAICS is missing from your patches.

[note, also see the nut-devel ML for some related change suggestion i just
 posted]

[...]
> Index: libavformat/nutenc.c
> ===================================================================
> --- libavformat/nutenc.c	(revision 15375)
> +++ libavformat/nutenc.c	(working copy)
> @@ -445,6 +445,13 @@
>      return 1;
>  }
>  
> +static int add_tag(ByteIOContext *bc, AVMetadata *metadata, const char *type){
> +    char *value = av_metadata_get_tag(metadata, type);
> +    if (value)  return add_info(bc, type, value);
> +    return 0;
> +}
> +

> +#undef printf

huh?


>  static int write_globalinfo(NUTContext *nut, ByteIOContext *bc){
>      AVFormatContext *s= nut->avf;
>      ByteIOContext *dyn_bc;
> @@ -454,9 +461,10 @@
>      if(ret < 0)
>          return ret;
>  
> -    if(s->title    [0]) count+= add_info(dyn_bc, "Title"    , s->title);
> -    if(s->author   [0]) count+= add_info(dyn_bc, "Author"   , s->author);
> -    if(s->copyright[0]) count+= add_info(dyn_bc, "Copyright", s->copyright);
> +    count += add_tag(dyn_bc, &s->metadata, "Title");
> +    count += add_tag(dyn_bc, &s->metadata, "Author");
> +    count += add_tag(dyn_bc, &s->metadata, "Copyright");
> +    count += add_tag(dyn_bc, &s->metadata, "Description");
>      if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT))
>                          count+= add_info(dyn_bc, "Encoder"  , LIBAVFORMAT_IDENT);
>  

well, thats not supporting generic metadata, it just hardcodes 4 cases


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080923/6d5fb788/attachment.pgp>



More information about the ffmpeg-devel mailing list