[FFmpeg-devel] [PATCH] examples/muxing: set sample formats from list of codec supported sample formats

Stefano Sabatini stefasab at gmail.com
Tue Jan 7 17:35:40 CET 2014


On date Tuesday 2014-01-07 15:12:21 +0100, wm4 encoded:
> On Tue,  7 Jan 2014 13:05:52 +0100
> Stefano Sabatini <stefasab at gmail.com> wrote:
> 
> > Avoid the need of tweaking, also show how to get list of supported sample
> > formats.
> > ---
> >  doc/examples/muxing.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/doc/examples/muxing.c b/doc/examples/muxing.c
> > index 4cd3f65..4cf72e5 100644
> > --- a/doc/examples/muxing.c
> > +++ b/doc/examples/muxing.c
> > @@ -73,7 +73,8 @@ static AVStream *add_stream(AVFormatContext *oc, AVCodec **codec,
> >  

> >      switch ((*codec)->type) {
> >      case AVMEDIA_TYPE_AUDIO:
> > -        c->sample_fmt  = AV_SAMPLE_FMT_FLTP;
> > +        c->sample_fmt  = (*codec)->sample_fmts ?
> > +            (*codec)->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;
> 

> Why can this be NULL,

I suppose it is to retain backward compatibility with codecs which
don't contain it yet.

> and why is AV_SAMPLE_FMT_FLTP a valid fallback?

Any will do, in case it is not accepted by the encoder it should
complain aloud that it doesn't like that sample format.

> (I know, avcodec.h documents that NULL means unknown, but that's
> confusing.)
> 
> >          c->bit_rate    = 64000;
> >          c->sample_rate = 44100;
> >          c->channels    = 2;
-- 
FFmpeg = Friendly and Fancy Mortal Picky Energized Gymnast


More information about the ffmpeg-devel mailing list