Overview
Pixel formats define how image data is stored in memory. FFmpeg supports a wide range of pixel formats for various video processing needs, from standard RGB/YUV formats to specialized hardware-accelerated formats.Format Naming Convention
Pixel formats follow the patternAV_PIX_FMT_<FORMAT><BITS><ENDIAN>:
- FORMAT: Color space or layout (RGB, YUV, GRAY, etc.)
- BITS: Bit depth per component
- ENDIAN: Byte order (BE = big-endian, LE = little-endian)
Listing Available Formats
Color Spaces
YUV Formats
YUV (luma + chroma) formats are standard for video compression and broadcast.YUV 4:2:0 (Most Common)
AV_PIX_FMT_YUV420P - Planar YUV 4:2:0, 12bpp- Chroma Subsampling: 2x2 (1 Cr & Cb sample per 2x2 Y samples)
- Use: Most common video format (H.264, HEVC, VP9)
- Storage: Separate Y, U, V planes
- Chroma: Interleaved U and V (first byte U, next byte V)
- Use: Hardware encoding/decoding, mobile devices
- Performance: Often faster than YUV420P on hardware
- Chroma: Interleaved V and U (swapped from NV12)
- Use: Some Android devices
YUV 4:2:2 (Broadcast Quality)
AV_PIX_FMT_YUV422P - Planar YUV 4:2:2, 16bpp- Chroma Subsampling: 2x1 (1 Cr & Cb sample per 2x1 Y samples)
- Use: Professional video, broadcast (MPEG-2, ProRes)
- Layout: Y0 Cb Y1 Cr (packed)
- Use: Cameras, capture devices
- Layout: Cb Y0 Cr Y1
- Use: Professional equipment, SDI
YUV 4:4:4 (No Chroma Subsampling)
AV_PIX_FMT_YUV444P - Planar YUV 4:4:4, 24bpp- Chroma Subsampling: None (1:1:1)
- Use: High-quality encoding, lossless compression
- Quality: Highest quality YUV format
High Bit Depth YUV
AV_PIX_FMT_YUV420P10LE - 10-bit YUV 4:2:0, 15bpp, little-endian- Bit Depth: 10 bits per component
- Use: HDR video, professional grading
- Codecs: HEVC, VP9, AV1
- Use: Professional broadcast, ProRes
- Use: High-end production, mastering
YUV with Alpha
AV_PIX_FMT_YUVA420P - Planar YUV 4:2:0 + alpha, 20bpp- Alpha: Separate alpha plane
- Use: Video with transparency
RGB Formats
RGB formats store red, green, and blue components.Packed RGB
AV_PIX_FMT_RGB24 - Packed RGB 8:8:8, 24bpp- Layout: RGBRGB… (3 bytes per pixel)
- Use: Image processing, display
- Layout: BGRBGR… (reversed RGB)
- Use: Windows bitmaps, OpenCV
- Layout: RGBARGBA… (includes alpha)
- Use: Compositing, overlays, PNG
- Layout: ARGBARGB…
- Use: Some graphics APIs
- Layout: BGRABGRA…
- Use: Windows, DirectX
High Bit Depth RGB
AV_PIX_FMT_RGB48LE - Packed RGB 16:16:16, 48bpp, little-endian- Bit Depth: 16 bits per component
- Use: High-quality image processing
- Use: Low-memory devices, embedded systems
Planar RGB
AV_PIX_FMT_GBRP - Planar GBR 4:4:4, 24bpp- Planes: Separate G, B, R planes
- Use: Some codecs prefer planar RGB
- Planes: G, B, R, A separate planes
Grayscale Formats
AV_PIX_FMT_GRAY8 - 8-bit grayscale, 8bppPalette Formats
AV_PIX_FMT_PAL8 - 8-bit palettized RGB32- Storage: 8-bit index + 256-entry RGB32 palette
- Use: GIF, indexed PNG
Special Formats
AV_PIX_FMT_XYZ12LE - Packed XYZ 4:4:4, 36bpp- Use: Digital cinema (DCI)
Bayer Formats
Raw sensor data from cameras. AV_PIX_FMT_BAYER_BGGR8 - Bayer BGGR pattern, 8-bit AV_PIX_FMT_BAYER_RGGB8 - Bayer RGGB pattern, 8-bit AV_PIX_FMT_BAYER_GBRG8 - Bayer GBRG pattern, 8-bit AV_PIX_FMT_BAYER_GRBG8 - Bayer GRBG pattern, 8-bitHardware Acceleration Formats
AV_PIX_FMT_VAAPI - VA-API hardware surfaces- Use: Intel hardware decoding/encoding
- Use: NVIDIA GPU acceleration
Format Conversion
Basic Conversion
Scale with Format Conversion
Preserve Quality
HDR to SDR
Format Properties
Chroma Subsampling
- 4:4:4: No subsampling (best quality)
- 4:2:2: Horizontal subsampling by 2
- 4:2:0: Horizontal and vertical subsampling by 2 (most common)
- 4:1:1: Horizontal subsampling by 4
Planar vs Packed
Planar: Each component in separate memory plane- Example: YUV420P (separate Y, U, V planes)
- Advantage: Easier to process individual components
- Example: YUYV422 (Y0 Cb Y1 Cr…)
- Advantage: Sometimes faster memory access
Bit Depth
- 8-bit: Standard dynamic range (SDR)
- 10-bit: HDR, professional video
- 12-bit: Cinema, high-end production
- 16-bit: Image processing, intermediate formats
Common Use Cases
Web Video
HDR Video
Image Sequences
Transparency
Performance Considerations
Hardware Encoding
Memory Usage
Bits per pixel:- YUV420P: 12 bpp
- YUV422P: 16 bpp
- YUV444P: 24 bpp
- RGB24: 24 bpp
- RGBA: 32 bpp
- YUV420P10LE: 15 bpp
Compatibility
Most Compatible: YUV420P (8-bit)- Supported by all devices and players
- Required for H.264 baseline/main profiles
Source Code Location
Pixel format definitions:libavutil/pixfmt.h
Key file:
/home/daytona/workspace/source/libavutil/pixfmt.h- Enum AVPixelFormat definitions
Related Concepts
- Color Range: Limited (16-235) vs Full (0-255)
- Color Space: BT.601, BT.709, BT.2020
- Color Primaries: Defines RGB/XYZ color gamut
- Transfer Characteristics: Gamma, PQ, HLG for HDR