[FFmpeg-devel] [PATCH] av_metadata_count()

Aurelien Jacobs aurel
Sun Feb 1 18:36:44 CET 2009


On Sun, 1 Feb 2009 02:06:21 +0100
Michael Niedermayer <michaelni at gmx.at> wrote:

> On Sun, Feb 01, 2009 at 02:00:12AM +0100, Aurelien Jacobs wrote:
> > On Fri, 30 Jan 2009 17:33:02 +0100
> > Michael Niedermayer <michaelni at gmx.at> wrote:
> > 
> > > On Fri, Jan 30, 2009 at 01:43:34AM +0100, Aurelien Jacobs wrote:
> > > > Hi,
> > > > 
> > > > Attached patch adds a new metadata API func to get the number of
> > > > available tags among a list of keys. This func will be useful
> > > > at least for the following muxers: asf, mov, mp3.
> > > > It can also be quite handy for a user application.
> > > 
> > > i cant see this to be that usefull, please first show the code
> > > that would benefit from this.
> > 
> > OK. As an example, here is a snipet from movenc:
> >     // only save meta tag if required
> >     if (s->title[0] || s->author[0] || s->album[0] || s->year ||
> >         s->comment[0] || s->genre[0] || s->track) {
> > It could be replaced by something very ugly:
> >     // only save meta tag if required
> >     if (av_metadata_get(s->metadata, "title"  , NULL, 0) ||
> >         av_metadata_get(s->metadata, "author" , NULL, 0) ||
> >         av_metadata_get(s->metadata, "album"  , NULL, 0) ||
> >         av_metadata_get(s->metadata, "year"   , NULL, 0) ||
> >         av_metadata_get(s->metadata, "comment", NULL, 0) ||
> >         av_metadata_get(s->metadata, "genre"  , NULL, 0) ||
> >         av_metadata_get(s->metadata, "track"  , NULL, 0)) {
> > Or by something simpler like:
> >     static const char const *mov_tags[] = {
> >         "title", "author", "album", "year", "copyright", "comment",
> >         "genre", "track", NULL
> >     };
> >     // only save meta tag if required
> >     if (av_metadata_count(s->metadata, mov_tags, 0)) {
> > 
> > We have something similar in the mp3 muxer, except that it currently
> > only check the presence of title to deceide whether it should mux
> > metadata or not (this is wrong and it should really check for the
> > presence of any supported tag).
> > Attached is a patch to use new metadata API in mp3 (de)muxer, which
> > make use of av_metadata_count(). (I have not yet finalized patch
> > for the mov muxer, but it will use something similar, twice)
> 
> url_open_dyn_buf(&bc)
> write title
> write author
> ...
> 
> if bc is not empty write it out

That's not as simple as "bc is not empty", because some data is written
in the metadata header anyway, so bc won't ever be empty. But still,
it's possible to do something like this by counting the number of tag
which are actually written in the buffer.

So attached is a new patch to upgrade the mp3 (de)muxer to the new
metadata API without using av_metadata_count().

Aurel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: md_mp3.diff
Type: text/x-diff
Size: 9896 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090201/434319b4/attachment.diff>



More information about the ffmpeg-devel mailing list