[FFmpeg-devel] [PATCH] ffmpeg should look up AVCodec by name

Michael Niedermayer michaelni
Mon Oct 6 01:39:11 CEST 2008


On Mon, Oct 06, 2008 at 01:22:09AM +0200, Aurelien Jacobs wrote:
> Hi,
> 
> Curently, when specifying a codec with -[asv]codec to ffmpeg, it is
> first converted to a CODEC_ID_* and then the coresponding AVCodec
> is picked up. Problem arise when we have several AVCodec handling the
> same CODEC_ID_*. eg: -acodec libvorbis select the internal vorbis
> encoder instead of the libvorbis one...
> Attached patch ensure we pick up AVCodec using the codec name, when
> available. This allows to actually select the libvorbis encoder for
> example. This works for both input and output codecs. This also
> correctly display the selected codec.
> 
> Aurel

> Index: ffmpeg.c
> ===================================================================
> --- ffmpeg.c	(revision 15552)
> +++ ffmpeg.c	(working copy)
> @@ -1915,7 +1915,9 @@ static int av_encode(AVFormatContext **output_file
>      for(i=0;i<nb_ostreams;i++) {
>          ost = ost_table[i];
>          if (ost->encoding_needed) {
> -            AVCodec *codec;
> +            AVCodec *codec = ost->st->codec->codec;

> +            ost->st->codec->codec = NULL;

why?

besides the solution looks hackish and i think ive seen a similar patch
already from someone else ...


[...]

> Index: libavcodec/utils.c
> ===================================================================
> --- libavcodec/utils.c	(revision 15552)
> +++ libavcodec/utils.c	(working copy)
> @@ -1033,6 +1033,8 @@ AVCodec *avcodec_find_decoder(enum CodecID id)
>  AVCodec *avcodec_find_decoder_by_name(const char *name)
>  {
>      AVCodec *p;
> +    if (!name)
> +        return NULL;
>      p = first_avcodec;
>      while (p) {
>          if (p->decode != NULL && strcmp(name,p->name) == 0)

where and why is null passed?
and if approved this should be a seperate commit


> @@ -1051,7 +1053,9 @@ void avcodec_string(char *buf, int buf_size, AVCod
>      int bitrate;
>      AVRational display_aspect_ratio;
>  
> -    if (encode)
> +    if (enc->codec)
> +        p = enc->codec;
> +    else if (encode)
>          p = avcodec_find_encoder(enc->codec_id);
>      else
>          p = avcodec_find_decoder(enc->codec_id);

iam not sure if this always prints what is expected, i mean
the input should be printed as vorbis or vorbis decoded by libvorbis
not just libvorbis ...

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

The worst form of inequality is to try to make unequal things equal.
-- Aristotle
-------------- 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/20081006/73c6d60c/attachment.pgp>



More information about the ffmpeg-devel mailing list