FFmpeg 101 (2024)

A comprehensive guide to FFmpeg's architecture, covering its essential tools, libraries, and the core logic for building a simple media player using the C API.
Code repository: ffmpeg-101
FFmpeg package content
FFmpeg is composed of a suite of tools and libraries.
FFmpeg tools
The tools can be used to encode/decode/transcode a multitude of different audio and video formats, and to stream the encoded media over networks.
ffmpeg: a command line tool to convert multimedia files between formats ffplay: a simple mediaplayer based on SDL and the FFmpeg libraries ffprobe: a simple multimedia stream analyzer
FFmpeg libraries
The libraries can be used to integrate those same features into your own product.
libavformat: I/O and muxing/demuxing libavcodec: encoding/decoding libavfilter: graph-based filters for raw media libavdevice: input/output devices libavutil: common multimedia utilities libswresample: audio resampling, samples format conversion and audio mixing libswscale: color conversion and image scaling libpostproc: video post-processing (deblocking/noise filters)
FFmpeg simple player
A basic usage of FFmpeg is to demux a multimedia stream (obtained from a file or from the network) into its audio and video streams and then to decode those streams into raw audio and raw video data.
To manage the media streams, FFmpeg uses the following structures:
AVFormatContext: a high level structure providing sync, metadata and muxing for the streams AVStream: a continuous stream (audio or video) AVCodec: defines how data are encoded and decoded AVPacket: encoded data in the stream AVFrame: decoded data (raw video frame or raw audio samples)
(Note: The provided code snippets demonstrate the process of opening a file, identifying streams, finding decoders, and the send/receive loop for decoding packets into frames.)
Source: Hacker News










