>FFmpegLab Sign In
FFmpeg Guide

The complete FFmpeg codecs guide

Every video and audio codec you need to know: H.264, H.265, VP9, AV1, AAC, MP3, lossless codecs, hardware acceleration, and how to pick the right one for your project. With practical commands and comparison tables.

FFmpeg supports over 100 video codecs and dozens of audio codecs[reference:0]. But only a fraction of those are worth a deeper dive. This guide covers the ones you'll actually use — from the universal compatibility of H.264 to the bleeding‑edge compression of AV1.

Before we dive in, a quick note on how FFmpeg names codecs:

Key takeaways

Video codecs

H.264 / AVC – libx264

H.264 is the most widely used video codec in the world. It's supported by every browser, every phone, every smart TV, and every video platform. If you need maximum compatibility, this is your codec.

FFmpeg uses the libx264 encoder. It's an external library, so your FFmpeg build needs --enable-libx264[reference:3].

Basic H.264 encode

ShareRenders{ } CodeConfig
Generated CodeLogsCustomize
ffmpeg -i input.mov -c:v libx264 -preset medium -crf 23 -c:a aac output.mp4

libx264 options

For advanced tuning, use -x264-params with a colon‑separated list of key=value pairs[reference:4]:

ShareRenders{ } CodeConfig
Generated CodeLogsCustomize
ffmpeg -i input.mov -c:v libx264 -x264-params "keyint=250:min-keyint=25:bframes=3" output.mp4

H.265 / HEVC – libx265

H.265 (High Efficiency Video Coding) delivers roughly 50% better compression than H.264 at the same visual quality[reference:5]. That means half the file size for the same quality, or better quality at the same file size. It's the go‑to codec for 4K, 8K, and HDR content.

FFmpeg uses the libx265 encoder. Enable with --enable-libx265 at build time[reference:6].

Basic H.265 encode

ShareRenders{ } CodeConfig
Generated CodeLogsCustomize
ffmpeg -i input.mov -c:v libx265 -preset medium -crf 24 -c:a aac output.mp4

libx265 options

ShareRenders{ } CodeConfig
Generated CodeLogsCustomize
ffmpeg -i input.mov -c:v libx265 -x265-params "crf=26:psy-rd=1" output.mp4

VP9 – libvpx-vp9

VP9 is Google's royalty‑free, open‑source codec. It's the standard for WebM and is widely supported in browsers (Chrome, Firefox, Edge)[reference:8]. In terms of compression, VP9 is roughly comparable to H.265, but it's completely free to use with no licensing fees.

FFmpeg uses the libvpx-vp9 encoder. Enable with --enable-libvpx.

Basic VP9 encode

ShareRenders{ } CodeConfig
Generated CodeLogsCustomize
ffmpeg -i input.mov -c:v libvpx-vp9 -crf 30 -b:v 0 -c:a libopus output.webm

VP9 options

ShareRenders{ } CodeConfig
Generated CodeLogsCustomize
ffmpeg -i input.mov -c:v libvpx-vp9 -crf 30 -b:v 0 -speed 2 -row-mt 1 -c:a libopus output.webm

AV1 – libaom-av1 / libsvtav1

AV1 is the next‑generation, royalty‑free codec from the Alliance for Open Media. It typically delivers ~30% better compression than VP9 and ~50% better than H.264[reference:9]. It's the future of web video — already supported in Chrome, Firefox, and Edge.

FFmpeg offers two main AV1 encoders:

Basic AV1 encode (libsvtav1)

ShareRenders{ } CodeConfig
Generated CodeLogsCustomize
ffmpeg -i input.mov -c:v libsvtav1 -crf 30 -preset 8 -g 240 -c:a libopus output.mkv

AV1 options


Lossless & near‑lossless video codecs

Sometimes you need pixel‑perfect quality — for archiving, intermediate masters, or when you'll be doing further processing.

ShareRenders{ } CodeConfig
Generated CodeLogsCustomize
# FFV1 lossless
ffmpeg -i input.mov -c:v ffv1 -level 3 -coder 1 -context 1 output.mkv

# ProRes 422 HQ
ffmpeg -i input.mov -c:v prores -profile:v 3 -vendor apl0 output.mov

# H.264 lossless
ffmpeg -i input.mov -c:v libx264 -crf 0 -preset slower output.mp4

Audio codecs

AAC – aac

AAC (Advanced Audio Coding) is the default audio codec for MP4 and the most widely used audio format in video. FFmpeg's native aac encoder is now the recommended choice — its quality is on par with or better than libfdk_aac at 128 kbps[reference:11].

Basic AAC encode

ShareRenders{ } CodeConfig
Generated CodeLogsCustomize
ffmpeg -i input.mov -c:a aac -b:a 128k output.mp4

AAC options


MP3 – libmp3lame

MP3 is still the most compatible audio format. Use it when you need maximum playback compatibility — old devices, MP3 players, etc. FFmpeg uses the libmp3lame encoder[reference:16].

ShareRenders{ } CodeConfig
Generated CodeLogsCustomize
ffmpeg -i input.mov -c:a libmp3lame -b:a 192k output.mp3

Opus – libopus

Opus is the most modern and efficient audio codec. It's royalty‑free, open, and delivers superior quality at low bitrates. It's the standard for WebM and is widely supported in browsers.

ShareRenders{ } CodeConfig
Generated CodeLogsCustomize
ffmpeg -i input.mov -c:a libopus -b:a 96k output.webm

Lossless audio codecs


Hardware‑accelerated encoders

If you have a modern GPU, you can offload encoding to hardware. This is much faster than software encoding, but quality per bit is usually lower. Use hardware encoding for live streaming, quick previews, or when speed is more important than file size.

HardwareH.264 encoderH.265 encoderNotes
Intel QSVh264_qsvhevc_qsvBuilt into Intel GPUs
NVIDIA NVENCh264_nvenchevc_nvencNVIDIA GPUs
AMD AMFh264_amfhevc_amfAMD GPUs
VAAPI (Linux)h264_vaapihevc_vaapiGeneric Linux GPU acceleration
Apple VideoToolboxh264_videotoolboxhevc_videotoolboxmacOS / iOS
ShareRenders{ } CodeConfig
Generated CodeLogsCustomize
# NVIDIA NVENC H.264
ffmpeg -i input.mov -c:v h264_nvenc -preset p4 -tune hq -cq 23 -c:a aac output.mp4

# Intel QSV H.265
ffmpeg -i input.mov -c:v hevc_qsv -global_quality 24 -c:a aac output.mp4

Codec comparison table

CodecFFmpeg encoderCompressionSpeedRoyalty‑freeBest for
H.264libx264GoodFastNoUniversal compatibility
H.265 / HEVClibx265Excellent (~50% better than H.264)SlowNo4K, HDR, streaming
VP9libvpx-vp9ExcellentSlowYesWeb (WebM)
AV1libsvtav1Best (~50% better than H.264)Very slowYesFuture‑proof web video
FFV1ffv1LosslessMediumYesArchiving, masters
ProResproresNear‑losslessFastYesEditing, post‑production

How to choose the right codec

Want to combine codec choices with other operations? Check out our guides on compression, format conversion, and filter complex effects.

Ready to put this into practice? FFmpegLab gives you a visual timeline where you can pick your codec, set quality presets, and generate the exact command — all entirely offline.

✦  Fresh from the render queue

Better FFmpeg workflows, delivered.

Get practical commands, new templates, and deep-dive guides for the edits that are usually hardest to get right.

✓  Copy-pasteable commands    ✓  Editor templates    ✓  No noise
One useful email at a time.

Choose the right codec on a real timeline — offline.

Free in your browser — nothing to install, nothing uploaded.