Demultiplexing in ffplay

FFplay is a simple player based on the FFmpeg library, which can be used to play various audio and video formats. Demultiplexing refers to separating different types of data such as audio, video, and subtitles in media files, and decoding and processing them so that they can be played by players.

In FFplay, the demux function is provided by the FFmpeg library. Specifically, FFplay implements the following steps by calling related functions in the FFmpeg library:

  1. Open the media file: Use the avformat open input() function to open the media file and read some meta information (such as stream number, duration, encoding format, etc.).

  2. Find stream information: Use the avformat find stream_info() function to find different types of stream information such as audio, video, and subtitles in the media file, and save it in the AVFormatContext structure.

  3. Open the decoder: For each stream, use the avcodec find decoder() function to find the corresponding decoder, and use the avcodec_open2() function to open the decoder, ready for decoding.

  4. Demultiplexing data: Use the av read frame() function to read the data in the media file frame by frame in time order and save it in the AVPacket structure.

  5. Decoding data: Use the avcodec send packet() function to send the data in the AVPacket to the decoder for decoding, and use the avcodec receive frame() function to obtain the decoded AVFrame.

  6. Rendering data: Send the decoded data to the renderer for rendering, and finally present it on the screen.

It should be noted that the demultiplexing process in FFplay is performed in real time, that is, decoding and rendering are performed immediately after each frame of data is read. This can ensure the smooth playback of the video, but it also increases the requirements for the CPU and GPU.

★The business card at the end of the article can receive audio and video development learning materials for free, including (FFmpeg, webRTC, rtmp, hls, rtsp, ffplay, srs) and audio and video learning roadmaps, etc.

see below!

Guess you like

Origin blog.csdn.net/yinshipin007/article/details/130430063