Skip to main content

FFmpeg CRF: How to Set Video Quality with -crf

FFmpeg CRF sets video quality with one flag (-crf 23 for libx264): lower looks better but makes bigger files. Commands and ranges for H.264, H.265 and VP9.

Convert MKV to MP4

Optimized CRF quality settings applied automatically

MKV MP4

Tap to choose your file

or

Supports M4A, WAV, FLAC, OGG, AAC, WMA, AIFF, OPUS • Max 100 MB

FFmpeg CRF Commands

  • ffmpeg -i input.mkv -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 192k output.mp4 — H.264: range 0–51, default 23.
  • ffmpeg -i input.mkv -c:v libx265 -crf 28 -preset medium -tag:v hvc1 -c:a aac -b:a 192k output.mp4 — H.265: range 0–51, default 28; hvc1 lets Apple devices play it.
  • ffmpeg -i input.mkv -c:v libvpx-vp9 -crf 30 -b:v 0 -c:a libopus -b:a 128k output.webm — VP9: range 0–63; -b:v 0 is required for pure constant quality.
  • ffmpeg -i input.mkv -c:v libx264 -crf 23 -maxrate 4M -bufsize 8M -c:a aac output.mp4 — capped CRF for streaming or upload limits.

The method from the FFmpeg H.264 guide: choose the highest CRF that still looks good to you, then the slowest preset you have patience for, and use both for the whole batch.

What Is CRF (Constant Rate Factor)?

CRF is the primary quality control in modern video encoders like x264 (H.264) and x265 (H.265). It's a single number that tells the encoder: "I want this level of quality — use whatever bitrate is needed to achieve it."

Unlike fixed-bitrate encoding, CRF dynamically adjusts the bitrate for each frame based on scene complexity. High-motion action scenes receive more bits (larger data). Static talking-head scenes receive fewer bits (smaller data). The result is optimal quality-to-size ratio without manual bitrate tuning.

How CRF Works

The encoder processes each frame and asks: "How many bits do I need to achieve CRF X quality for this specific frame?" The answer varies dramatically:

  • A frame of fast-paced action with explosions might need 500 KB
  • A frame of a static title card might need 5 KB
  • A frame of talking heads with a blurred background might need 50 KB

CRF produces variable bitrate (VBR) output — the bitrate fluctuates throughout the video. This is fundamentally more efficient than constant bitrate (CBR), which wastes bits on simple scenes and starves complex ones.

CRF Scale for H.264 / H.265

For H.264 (libx264), CRF ranges from 0 to 51. Lower values mean higher quality and larger files:

CRF Value Quality Level Typical Use Case File Size (1 min 1080p)
0 Lossless (mathematically perfect) Intermediate editing, archival masters ~2–5 GB
18 Visually transparent High-quality archival, source preservation ~120 MB
23 Excellent (default) General use, web, sharing ~60 MB
28 Good (some visible loss) Smaller files, mobile, email ~30 MB
33 Acceptable (noticeable artifacts) Previews, thumbnails, low-priority ~15 MB
40+ Poor (heavy compression) Not recommended <10 MB

For H.265 (libx265), the scale is the same (0–51) but equivalent quality requires higher CRF values. H.264 CRF 23 roughly equals H.265 CRF 28.

Rule of thumb: Every 6 CRF steps roughly double or halve the file size. Going from CRF 23 to CRF 17 approximately doubles the file, while going from CRF 23 to CRF 29 approximately halves it.

CRF Scale for VP9

VP9 (libvpx-vp9) uses a different CRF range: 0 to 63. The principle is the same (lower = better), but the numbers are not directly comparable to H.264:

  • CRF 15–20: High quality, large files
  • CRF 30: Good quality, our default (roughly equivalent to H.264 CRF 23)
  • CRF 35–45: Smaller files, some quality loss

VP9 at CRF 30 typically produces files 30–50% smaller than H.264 at CRF 23 with equivalent visual quality. This is because VP9 is a more efficient codec, not because of the CRF number.

CRF vs CBR vs VBR

Three main approaches to controlling video bitrate:

Method How It Works Best For Drawback
CRF Constant quality, variable bitrate File conversion, archival, general use Unpredictable file size
CBR Constant bitrate, variable quality Live streaming, strict bandwidth Wastes bits on simple scenes
VBR Target bitrate, variable around it Two-pass encoding, predictable size Needs target bitrate estimation

For file conversion (MKV to MP4, MOV to MP4, etc.), CRF is always the best choice. It produces the optimal quality-to-size ratio without requiring you to guess at a target bitrate. When a file must hit an exact size instead, read our comparison of two-pass encoding vs CRF.

Practical File Size Examples

The same 1-minute 1080p video at different CRF values (H.264, medium preset):

  • CRF 18: ~120 MB — visually perfect, 2x the default size
  • CRF 20: ~85 MB — excellent quality, slightly above default
  • CRF 23: ~60 MB — our default, imperceptible quality loss
  • CRF 26: ~40 MB — still very good, noticeable only in demanding scenes
  • CRF 28: ~30 MB — good quality, visible loss in gradients and fine detail
  • CRF 33: ~15 MB — acceptable, artifacts visible in motion

These numbers vary significantly based on content complexity. Action movies produce larger files than screencasts at any CRF level.

Our Converter Settings

Our converter uses these quality settings:

  • MP4 output: H.264, CRF 23, medium preset, AAC 192k audio
  • WebM output: VP9, CRF 30, cpu-used 3, Opus 128k audio

CRF 23 was chosen because it provides the optimal balance: a small loss that is hard to see for most content, with reasonable file sizes suitable for sharing, uploading, and streaming.

Below CRF 18: You're storing bits that no human eye can perceive. File size grows exponentially while visual quality flatlines. CRF 0 (lossless) is 10–50x larger than CRF 23 — reserved for professional editing masters, never for delivery.

What CRF Does to an Already Compressed Video

CRF measures quality against the input you give it, not against the original camera footage. Re-encoding a soft, blocky file at CRF 18 faithfully keeps the blockiness and can even produce a bigger file than the source. A lower CRF cannot bring back detail that earlier compression removed.

  • Choose the CRF you need, not a lower one “to be safe”.
  • If the video is fine and only the container is wrong, remux with -c copy instead of re-encoding.
  • Each re-encode adds a little loss, so always start from the best copy you have.

Ready to Convert?

Convert your video with optimized CRF quality settings

MKV MP4

Tap to choose your file

or

Supports M4A, WAV, FLAC, OGG, AAC, WMA, AIFF, OPUS • Max 100 MB

Frequently Asked Questions

CRF 23 is the recommended default for H.264. Use CRF 18 for highest quality (archival), CRF 28 for smaller files (sharing and email), or CRF 33 for minimum viable quality (previews and thumbnails).

For H.264, yes: -crf 0 with 8-bit libx264 is mathematically lossless. For VP9, no: libvpx-vp9 needs -lossless 1. Every pixel is preserved exactly. However, the files are enormous — often 10–50x larger than CRF 23. This is only useful for editing masters, never for delivery.

Yes, lower CRF always means higher quality and larger files. But below CRF 18, the quality improvement is imperceptible to human eyes while file size continues to grow significantly. The point of diminishing returns is around CRF 18 for most content.

VP9 CRF 30–33 produces roughly equivalent quality to H.264 CRF 23. VP9 achieves this at 30–50% smaller file sizes due to its more efficient compression algorithm.

It depends on the encoder: libx264 defaults to 23 and libx265 to 28. libvpx-vp9 has no constant-quality default; set -crf together with -b:v 0.

No. Hardware encoders have their own options: for h264_nvenc and hevc_nvenc, -rc vbr -cq 23 -b:v 0 gives a similar constant-quality mode.

More MKV to MP4 Guides

MKV vs MP4: Which Container Should You Choose?
MKV vs MP4 compared: codec support, subtitle tracks, device compatibility, and when to use each container format.
H.264 vs H.265 (HEVC): Which Video Codec Is Better?
H.264 vs H.265 codec comparison: quality, file size, encoding speed, hardware support, and compatibility.
MKV to MP4 Without Losing Quality: Complete Guide
Convert MKV to MP4 losslessly via remuxing or with minimal quality loss. CRF settings and codec compatibility explained.
Container vs Codec: What's the Difference?
Understand the difference between video containers (MKV, MP4, AVI) and codecs (H.264, H.265, VP9). Essential knowledge for video conversion.
FFmpeg Presets: Speed vs Quality vs File Size
FFmpeg encoding presets from ultrafast to veryslow. Benchmark data showing quality and speed tradeoffs for each preset.
Frame Rate Guide: 24 vs 30 vs 60 FPS Explained
Video frame rates explained: 24 fps for film, 30 fps for TV, 60 fps for gaming. When to change FPS during conversion.
Pixel Format YUV420p: Why It Matters for Video Compatibility
Why yuv420p is required for universal video playback. Chroma subsampling, color depth, and compatibility with every device.
Two-Pass Encoding vs CRF: Which Is Better?
Compare two-pass encoding and CRF for video quality. When to use each method and how they affect file size and quality.
MKV Subtitles: How to Handle Multiple Tracks
Handle MKV subtitle tracks during conversion: extract SRT, burn-in SSA/ASS, and preserve subtitle data when converting to MP4.
Back to MKV to MP4 Converter

Request a Feature

0 / 2000