Constant Rate Factor is FFmpeg's default quality-based encoding mode for H.264, H.265, and VP9. Instead of targeting a bitrate, you target a quality level, and the encoder chooses the bitrate per scene to hit it. CRF 23 is the default; lower numbers are higher quality and larger files.

The command

ffmpeg -i input.mp4 -c:v libx264 -crf 23 output.mp4

What it does

FFmpeg hands the encoder a quality target (0 to 51 for H.264, where 0 is lossless and 51 is worst). The encoder varies the bitrate frame by frame: high-motion scenes get more bits, low-motion scenes get fewer, the average matches the target quality. Files are 20 to 50% smaller than two-pass ABR at equivalent quality.

When to use it

For single-pass delivery encodes where you want predictable quality, not a target size. CRF is the right default for streaming, archival, and most "I just want a good MP4" cases. Use a target bitrate (-b:v) when you need a specific file size, such as for broadcast specs.

Video and audio requirements

Applies to the video stream only. Audio is unaffected and is encoded with its own settings. CRF works with H.264, H.265, VP9, AV1, and most modern codecs. Each codec has its own quality range; the H.264 scale 0-51 is not comparable to the VP9 scale 0-63.

Things to avoid

  • Using the same CRF value for different codecs. CRF 23 in H.264 is roughly CRF 28 in H.265 and CRF 31 in VP9. Each codec has its own range.
  • Expecting a specific file size. CRF does not control size; it controls quality. For size, use two-pass ABR or constrained CRF (-crf with -maxrate and -bufsize).
  • Going below CRF 17 for delivery. The quality gains are imperceptible while the size balloons; CRF 18 to 23 is the practical range for H.264 delivery.
  • Re-encoding a lossy source through another CRF pass. You cannot recover what was lost. If you need a lower bitrate, start from the original encode, not the re-encode.