There are contexts in ffmpeg

There are contexts in ffmpeg

AVFormatContext
AVCodecContext

First explain the context:

The context I understand after looking up the information :
an environment that allows operations to be implemented, and there are algorithms that can implement operations in this environment, so we can use this environment to make Windows do the operations we want to perform (such as decoding).

Reference 1
Reference 2

The AVFormatContext (context format)
: the API is in direct contact with the structural body, located in avformat.h is audio and video data, which is audio and video files (typically exposed to mp3 / mp4 file, etc.) an abstract packaging , in Save input and output related data during FFMpeg format conversion.

That is, this structure contains the format information of the media stream. The more important ones are:

  • AVInputFormat or AVOutputFormat: Only one can exist at the same time.
  • AVStream
  • AVPacket
  • title、author、copyright、duration、
    start_time、bit_rate等。

AVFormatContext structure
FFmpeg: AVFormatContext structure analysis

The use of AVFormatContext:

AVFormatContext *pAVFormatContext = avformat_alloc_context ();//开空间
avformat_open_input(&pAVFormatContext,"a.mp4",nullptr,nullptr);//读取视频文件,将视频信息存入AVFormatContext对象中

AVCodecContext : Saves the AVCodec pointer and data related to the codec, such as the width and height of the video, and the sample rate of the audio.

  • Media stream in AVFormatContext
  • There is a codec in the media stream

So you can get the codec from the AVFormatContext object as follows:

 AVStream *outstream = avformat_new_stream (pAVFormatContext,NULL);
 AVCodec CodecContext = outstream->codec;//查找编码器

Guess you like

Origin blog.csdn.net/m0_49036370/article/details/110914490