Video containers
MP4
Most widely supported container format:- H.264 (
libx264,h264_nvenc,h264_qsv,h264_videotoolbox) - H.265 (
libx265,hevc_nvenc,hevc_qsv,hevc_videotoolbox) - AV1 (
libaom-av1,libsvtav1)
WebM
Open source container for web delivery:- VP8 (
libvpx) - VP9 (
libvpx-vp9) - AV1 (
libaom-av1)
MOV
QuickTime format, useful for intermediate files:- ProRes (
prores,prores_ks) - DNxHD (
dnxhd) - PCM audio (
pcm_s16le,pcm_s24le)
Video codecs
H.264 (libx264)
Best compatibility and hardware support:string
default:"'medium'"
Encoding speed vs compression ratio:
'ultrafast': Fastest encoding, largest file'superfast','veryfast','faster','fast''medium': Balanced'slow','slower','veryslow': Smaller file, slower encoding
number
default:"23"
Constant Rate Factor (quality):
0: Lossless (huge files)18-23: High quality (recommended)23-28: Good quality28-35: Lower quality (smaller files)51: Lowest quality
string
Optimize for specific content:
'film': Feature film content'animation': Animated content'grain': Preserve grain'stillimage': Slideshow content
H.265 (libx265)
Better compression than H.264, but slower encoding:- Encoding is 5-10x slower
- Requires modern players (may not work on older devices)
- Patent licensing issues in some regions
VP9 (libvpx-vp9)
Royalty-free codec for web delivery:- Similar quality to H.265
- Better than H.264 at low bitrates
- Native support in all modern browsers
- Slower encoding than H.264
AV1 (libaom-av1)
Next-generation codec with best compression:libsvtav1 for faster AV1 encoding:
Hardware-accelerated codecs
NVIDIA NVENC
Fast encoding on NVIDIA GPUs:'p1': Fastest'p4': Balanced'p7': Best quality
hevc_nvenc for H.265
Intel Quick Sync (QSV)
Hardware encoding on Intel CPUs:hevc_qsv, vp9_qsv
Apple VideoToolbox
Hardware encoding on macOS:hevc_videotoolbox, prores_videotoolbox
AMD VCE/VCN
Hardware encoding on AMD GPUs:Audio codecs
AAC
Most compatible audio codec:'128k': Good quality'192k': High quality (recommended)'256k': Very high quality'320k': Maximum quality (overkill for most uses)
Opus
Best quality per bitrate for WebM:Vorbis
Open source codec for WebM:PCM (uncompressed)
Lossless audio for intermediate files:'pcm_s24le': 24-bit PCM (higher quality)'pcm_s32le': 32-bit PCM'pcm_f32le': 32-bit float PCM
Pixel formats
yuv420p
Standard format, widest compatibility:- No alpha channel
- 4:2:0 chroma subsampling
yuv444p
Full chroma resolution:- No chroma subsampling
- Better color fidelity
- Larger file size
yuva420p
With alpha channel:Alpha channel requires specific codecs (VP8, VP9, PNG). H.264 does not support alpha.
Common presets
High quality for archival
Fast encoding for previews
Web optimized (small file size)
Hardware accelerated (NVIDIA)
Transparent video
Stream copy mode
Skip re-encoding for faster processing:- Adding/removing audio tracks
- Trimming video
- Changing container format
- Changing resolution
- Changing codec
- Burning in subtitles
Bitrate control
Constant Rate Factor (CRF)
Quality-based encoding:- Variable content complexity
- Archival
- When quality is more important than file size
Constant Bitrate (CBR)
Fixed bitrate:- Streaming
- Predictable file sizes
- Broadcast requirements