[Libav-user] New api and deprecation warning

Jodon Karlik jodonk at gmail.com
Thu Mar 15 22:15:17 EET 2018


On Thu, Mar 15, 2018 at 4:54 AM, Michael IV <explomaster at gmail.com> wrote:

>
>
>
>
>
>
>
>
>
>
>
>
>
> *AVCodecParameters is for information that codecs need to do their workbut
> is stored in a structured way in the container format rather thanencoded in
> the bitstream. Codecs vary in what they need and what theyput in the
> bitstream, and formats vary in what they are able to encode,but there is
> enough common ground for quite a few fields
> inAVCodecParameters.AVCodecContext is for actual encoding en decoding. It
> needs theinformation from AVCodecParameters, but it also needs settings
> that arespecific to the process at hand.Complaining that AVCodecParameters
> does not have a flags field is likecomplaining that the TV magazine tells
> you how to turn the volumebutton on your TV.*
>
>
> Thanks you for this even more confusing explanation, Nicolas ))
> It is as clear as the FFMPEG API ;)  I guess,I am not working enough with
> the av libs  to completely understand those subtle ideas.
>
>
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
>
Hello.  I tried posting a very long version of questions along these lines
but it never made it to this list.  This thread is so similar it's been
revealing and I hopped on IRC to get a few answers confirmed.  Here is my
understanding, please feel free to correct me if I am wrong:

AVCodecContext is everything a codec needs to encode video (including
settings specific to the codec you're using).
AVCodecParameters is more like the "header info" (like a bitmap header)
shared for all codecs.  Muxers and Demuxers will pretty much store this
header info somewhere.

The AVStream::codec deprecated threw me for a long time.  But here is my
new understanding (confirmed on IRC):

For encoding:

1.  Use avcodec_find_encoder_by_name result is AVCodec.
2.  Pass that AVCodec to avformat_new_stream.  The newly created AVStream
will take the information from AVCodec and store it in its
AVCodecParameters (AVStream::codecpar).
3.  Create your own AVCodecContext.
4.  Copy the parameters out of AVStream::codecpar into your own
AVCodecContext using avcodec_parameters_to_context.
5.  Configure your own AVCodecContext (in my case, using AVOptions).
6.  Copy the newly configured parameters from AVCodecContext back to your
AVStream::codecpar using avcodec_parameters_from_context.
7.  Do all of your encoding using your AVCodecContext and forget that
AVStream::codec ever existed.

Given this workflow is the new blessed one, AVStream::codec must be
unused.  Poking at the source it looks like internally, it checks to see if
AVStream::codecpar is mismatched with AVStream::codec, and if so, it
prefers AVStream::codec by copying it again into AVStream::codecpar.
However, all AVStream needs is AVStream::codecpar.

Cheers.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20180315/4e8d4ead/attachment.html>


More information about the Libav-user mailing list