Yuxian: CSDN content partner, CSDN new star mentor, full-stack creative star creator, 51CTO (Top celebrity + expert blogger), github open source enthusiast (go-zero source code secondary development, game back-end architecture https: https://github.com/Peakchen)
FFmpeg is an open source audio and video processing library that can be used to decode, encode, convert and process audio and video data. It provides a wide range of decoders and encoders to handle audio and video files in various formats.
In FFmpeg, to extract all frames in the decoder, the following steps are usually required:
-
Register FFmpeg library: Before using FFmpeg, you need to call
av_register_all()
the function to register all decoders and formatters in the FFmpeg library. -
Open the input file: Use
avformat_open_input()
the function to open the audio and video file to be processed, and create aAVFormatContext
structure to represent the context of the input file. -
Find stream information: Use
avformat_find_stream_info()
the function to find the stream information in the input file and fill it intoAVFormatContext
the structure. -
Find the video stream: traverse
AVFormatContext
the streams in the structure and find the index of the video stream (usually theAVMEDIA_TYPE_VIDEO
type of stream)