4. The basic process of ffmpeg audio and video file processing

The main process of ffmpeg to decode a media file is:
Decoding flowchart

1. Demux (Demux)
video file audio and video are compressed separately, because audio and video compression algorithms are different,
so the decoding is different, so the audio and video need to be decoded separately. Although the audio and video are
compressed separately, for the convenience of the transmission process, the audio and video that have been decompressed are bundled together for transmission.
Therefore, the demultiplexing step is to separate the audio stream and video stream bundled in the file to facilitate the subsequent decoding of them.
Demultiplex

2. Decode (Decode)
an audio and video file must be compressed in a certain format (h264, h265, etc.), which is commonly referred to as audio and video encoding. The
encoding is to reduce the amount of data, otherwise it is for the storage of audio and video data And network transmission will be difficult to complete,
so we must compress audio and video files as much as possible.

3. The API function corresponding to the decoding process
in ffmpeg The previous is the process of ffmpeg from opening to decoding an audio and video. Each step corresponds to one or a group of APIs in ffmpeg,
as shown in the following figure:
API function corresponding to the decoding process in fmpeg

The Demux step in ffmpeg is done through the avformat_open_input() api. This api reads the file
header information and performs demux. After that, we can read the audio and video streams in the media file,
and then use av_read_frame () Read the basic data stream packet from the audio and video streams,
and then send the packet to avcodec_decode_video2() and the corresponding api for decoding.

Guess you like

Origin blog.csdn.net/yanghangwww/article/details/104529191
Recommended