Skip to content

Quality controls: CRF, bitrate and presets

current

Rate control decides how many bits each frame gets. Choose the mode by what has to stay fixed: the quality, the file size, or the bitrate at every moment.

ModeYou setResultUse it for
CRF / constant qualityA quality valueConsistent quality; file size depends on the contentAlmost every encode you keep, archive or upload
Capped CRF (CRF + VBV)Quality value plus peak rate/bufferConstant quality, except that peaks are limitedStreaming and devices with a bitrate limit
Two-pass VBRAverage bitratePredictable size; quality close to CRF at the same sizeHitting a file size or an average-bitrate requirement
One-pass ABRAverage bitrateRoughly the right size; bits are spent poorlyLive encoding where two passes are impossible
CBRConstant bitrateBitrate held constant, with padding if neededBroadcast and some live transport
Constant QP (CQP)A fixed quantizerSame quantizer everywhere; wastes bits on hard scenesCodec development and testing, not delivery

CRF (constant rate factor) is quality-based variable bitrate. The encoder raises or lowers the quantizer from frame to frame and block to block, spending fewer bits where loss is hard to see (fast motion, complex texture) and more where it shows. At the same file size this looks better than constant QP, which ignores where the eye notices errors.

CRF numbers are encoder-specific. They do not mean the same quality across encoders, and sometimes not across versions of one encoder.

Encoder (FFmpeg name)OptionDefaultNotes
x264 (libx264)-crf23Lower is better; about ±6 halves or doubles the bitrate. 18–24 covers most uses.
x265 (libx265)-crf28Same 0–51 scale as x264, but the same number does not give the same quality.
SVT-AV1 (libsvtav1)-crf35Range 1–70 (FFmpeg’s -crf accepts up to 63). Upstream suggests 30 as a starting point for 1080p.
libaom (libaom-av1)-crf32Range 0–63. -crf alone is constant quality; adding -b:v makes it constrained quality.
libvpx (libvpx-vp9)-crf32Range 0–63. In current FFmpeg, -crf alone is constant quality; the old -b:v 0 is not needed.

Hardware encoders have their own constant-quality modes (NVENC -cq, Quick Sync ICQ, and others). They are not interchangeable with software CRF values; see the hardware encoder pages.

Presets trade speed for compression efficiency and are also encoder-specific: x264 and x265 use names (ultrafast … placebo), SVT-AV1 uses numbers where lower is slower and better. Change the preset to fit your time budget, then adjust CRF until the result looks right. At the same CRF a slower preset usually gives a smaller file or more detail.

VBV (video buffering verifier) models a decoder’s input buffer: data arrives at up to -maxrate and the buffer holds -bufsize bits. Combined with CRF it keeps constant-quality behaviour but stops peaks from exceeding what a player or connection can take:

Terminal window
ffmpeg -i input.mkv -c:v libx264 -preset slow -crf 20 -maxrate 6M -bufsize 12M -c:a copy output.mkv

-maxrate is the peak rate and -bufsize the buffer it is averaged over; you need both. A larger buffer allows short bursts; a smaller one enforces the limit more strictly. When the cap kicks in, quality drops in those scenes, so set it from the real limit of the target, not lower. The same -maxrate/-bufsize options work with libx265, and -maxrate with libsvtav1 turns its CRF mode into capped CRF.

Work out the video bitrate from the size you want:

video kbit/s = target MiB × 8388.608 / duration in seconds − audio kbit/s

For a 60-minute file of 1,500 MiB with 128 kbit/s audio: 1500 × 8388.608 / 3600 − 128 ≈ 3367 kbit/s.

Terminal window
ffmpeg -i input.mkv -c:v libx264 -preset slow -b:v 3367k -pass 1 -an -f null /dev/null
ffmpeg -i input.mkv -c:v libx264 -preset slow -b:v 3367k -pass 2 -c:a libopus -b:a 128k output.mkv

The first pass analyses the whole video and writes a stats file (ffmpeg2pass-0.log); its output is discarded, and -an skips audio work in that pass. The second pass uses the stats to put bits where they are needed. With x264, a two-pass encode looks about the same as a CRF encode that happens to produce the same size, so use two passes when the size matters and CRF otherwise.

For SVT-AV1, multi-pass mainly serves VBR; upstream describes it as not critical in CRF mode. CBR is always single-pass.

Test on a short clip that includes the hardest material in the source, and change one thing at a time. Compare the clips by watching them, not just by file size or a single metric score; the quality comparison guide covers metrics and how to use them properly.