[FFmpeg-devel] [PATCH 3/4] lavf: simplify setting the encoder ident tag.

Aurelien Jacobs aurel
Sat Oct 16 15:08:39 CEST 2010


On Sat, Oct 16, 2010 at 06:41:47AM +0200, Anton Khirnov wrote:
> On Fri, Oct 15, 2010 at 10:24:15PM +0200, Aurelien Jacobs wrote:
> > On Fri, Oct 15, 2010 at 09:21:00PM +0200, Anton Khirnov wrote:
> > > ---
> > >  libavformat/utils.c |   13 +++++--------
> > >  1 files changed, 5 insertions(+), 8 deletions(-)
> > > 
> > > diff --git a/libavformat/utils.c b/libavformat/utils.c
> > > index 289b91c..6fe3793 100644
> > > --- a/libavformat/utils.c
> > > +++ b/libavformat/utils.c
> > > @@ -2755,16 +2755,13 @@ int av_write_header(AVFormatContext *s)
> > >  
> > >      /* set muxer identification string */
> > >      if (!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) {
> > > -        AVMetadata *m;
> > >          AVMetadataTag *t;
> > > +        while ((t = av_metadata_get(s->metadata, "encoder", NULL, 0))) {
> > > +            char *key = av_strdup(t->key);
> > > +            av_metadata_set2(&s->metadata, key, NULL, AV_METADATA_DONT_STRDUP_KEY);
> > > +        }
> > 
> > Is this really useful ?
> yes, when we're remuxing from e.g. matroska or ogg there might be an
> all-uppercase ENCODER tag, which we don't want in the output.

Hum... It would probably be cleaner to just export generic tags from the
matroska and ogg demuxers. You could provide a conversion table
converting ENCODER to encoder (and same for other generic tag), or maybe
all tags could be converted to lowercase in those demuxers....
But in all cases, it looks wrong to try to workaround demuxers which
export encoder name in a tag which is not named "encoder".

> anyway, split to two patches.

Good.

> From 6f9c90e3fac99144ff2e2bf8d77f077fe98c1901 Mon Sep 17 00:00:00 2001
> From: Anton Khirnov <anton at khirnov.net>
> Date: Tue, 12 Oct 2010 21:53:42 +0200
> Subject: [PATCH 1/2] lavf: simplify setting the encoder ident tag.
> 
> ---
>  libavformat/utils.c |   11 +----------
>  1 files changed, 1 insertions(+), 10 deletions(-)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 289b91c..23d0a3b 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -2755,16 +2755,7 @@ int av_write_header(AVFormatContext *s)
>  
>      /* set muxer identification string */
>      if (!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) {
> -        AVMetadata *m;
> -        AVMetadataTag *t;
> -
> -        if (!(m = av_mallocz(sizeof(AVMetadata))))
> -            return AVERROR(ENOMEM);
> -        av_metadata_set2(&m, "encoder", LIBAVFORMAT_IDENT, 0);
> -        metadata_conv(&m, s->oformat->metadata_conv, NULL);
> -        if ((t = av_metadata_get(m, "", NULL, AV_METADATA_IGNORE_SUFFIX)))
> -            av_metadata_set2(&s->metadata, t->key, t->value, 0);
> -        av_metadata_free(&m);
> +        av_metadata_set2(&s->metadata, "encoder", LIBAVFORMAT_IDENT, 0);
>      }
>  
>      if(s->oformat->write_header){

I applied this one.

Aurel



More information about the ffmpeg-devel mailing list