Video Decoding Guide
FFmpeg’s decoders convert compressed video into raw frames for processing, analysis, or re-encoding.Understanding Decoders
Decoders are configured elements that enable playback and processing of multimedia streams. FFmpeg includes native decoders for most formats, with additional support through external libraries.List all available decoders:
ffmpeg -decodersBasic Decoding
Decoding happens automatically when you specify an output format or processing operation.Extract Raw Video
H.264/H.265 Decoding
FFmpeg’s native decoders handle H.264 and HEVC efficiently.Decode H.264
Decode HEVC/H.265
Force Specific Decoder
Use native H.264 decoder
Use libdav1d for AV1
Explicitly specifying a decoder can improve performance for certain formats.
AV1 Decoding
FFmpeg supports AV1 decoding through multiple decoders.Using libdav1d
libdav1d is a fast, optimized AV1 decoder.libdav1d Options
max_frame_delay: Maximum frames to buffer (0 = auto, lower = less latency)filmgrain: Apply film grain if present in bitstreamoperating_point: Select scalable AV1 operating point (0-31)alllayers: Output all spatial layers
Decoder Thread Control
Optimize decoding performance with threading options.Auto thread detection
Specific thread count
Slice-level threading for H.264
Thread Types
frame: Decode multiple frames in parallelslice: Decode slices within frames in parallelslice+frame: Use both methods (default)
-threads 0 enables automatic detection of CPU cores and optimal thread allocation.Hardware-Accelerated Decoding
Use GPU decoders for better performance and lower CPU usage.Intel QSV Decoding
H.264 QSV decode
HEVC QSV decode
AV1 QSV decode
VAAPI Decoding (Linux)
NVIDIA CUVID Decoding
H.264 CUVID
HEVC CUVID with scaling
Decode and Analyze
Extract information while decoding.Get Frame Information
Show frame data
Extract frame timestamps
Decode Specific Range
Rawvideo Decoder
Decode raw video data when format information is known.Decode raw YUV
Decode raw RGB
-pix_fmt: Pixel format (yuv420p, rgb24, etc.)-s: Frame size (WxH)-r: Frame rate (optional)
When decoding raw video, you must specify the pixel format and dimensions explicitly.
HEVC Multi-View Decoding
FFmpeg supports MV-HEVC for 3D/multi-view content.Decode all views
Decode specific views
MV-HEVC Options
view_ids: Comma-separated view IDs to decode-1: Decode all available viewsview_ids_available: Query available view IDs
Decoder Error Handling
Control how decoders handle errors.Ignore decode errors
Strict error checking
Continue on missing references
Error Detection Flags
ignore_err: Ignore errors and continuecrccheck: Verify CRC checksumsbitstream: Check bitstream validitybuffer: Check buffer boundariesexplode: Abort on minor errors
Audio Decoding
FFmpeg decodes audio formats automatically.Decode Performance Tips
Pixel Format Conversion
Convert between pixel formats during decoding.YUV to RGB
10-bit to 8-bit
Keep original format
Common Pixel Formats
| Format | Description | Bits per pixel |
|---|---|---|
yuv420p | YUV 4:2:0 planar | 12 |
yuv422p | YUV 4:2:2 planar | 16 |
yuv444p | YUV 4:4:4 planar | 24 |
rgb24 | RGB 8-bit | 24 |
rgba | RGBA 8-bit | 32 |
nv12 | YUV 4:2:0 semi-planar | 12 |
Use
ffmpeg -pix_fmts to list all supported pixel formats.Debugging Decoder Issues
Verbose decoder output
Show packet information
Check decoder capabilities
Next Steps
Encoding
Learn encoding techniques and codecs
Hardware Acceleration
Use GPU decoders for better performance
Filtering
Process decoded frames with filters
Format Conversion
Convert between formats efficiently