Skip to content

/flags/ffmpeg/ffmpeg-crf

ffmpeg -crf: constant rate factor for x264, x265 and AV1

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash) · ffmpeg version 9.0.2-full_build-www.gyan.devupdated 2026-10-20
tool
FFmpeg
command
ffmpeg
flag
-crf
default
23 for libx264, 28 for libx265

-crf (Constant Rate Factor) tells encoders such as libx264, libx265, libvpx-vp9 and libsvtav1 to target a constant perceived quality and let the bitrate vary. Lower values mean higher quality and bigger files. For libx264 the scale is 0–51 with a default of 23; about 6 steps up halves the file size, 6 steps down doubles it.

Same clip, three CRF values

bash
ffmpeg -hide_banner -loglevel error -f lavfi -i testsrc2=size=640x360:rate=30:duration=5 -pix_fmt yuv420p -c:v rawvideo -y src.nut
for crf in 18 23 28; do
  ffmpeg -hide_banner -loglevel error -i src.nut -c:v libx264 -preset medium -crf $crf -y out-$crf.mp4
  printf 'crf %s: %s bytes\n' "$crf" "$(stat -c %s out-$crf.mp4)"
done

Output

crf 18: 741625 bytes
crf 23: 500279 bytes
crf 28: 271030 bytes

The absolute sizes depend on the content (a synthetic test pattern compresses very well); the ratio between values is what to look at.

Typical ranges

EncoderScaleDefaultUsual range
libx264 (H.264)0–512318 (visually near-lossless) to 28
libx265 (HEVC)0–512822 to 32
libvpx-vp90–63—15 to 35, with -b:v 0 for constant quality
libsvtav10–63—20 to 40

CRF and preset work together

-preset (ultrafast … veryslow) trades encoding time for compression: at the same CRF, a slower preset gives about the same quality in a smaller file. Pick the slowest preset you can afford, then adjust CRF for quality.

Sources