CRF Basics: A Beginner's Guide to Constant Rate Factor Compression
Learn what CRF is, how it works, and why it matters for video compression. Beginner-friendly guide covering CRF scales, common mistakes, and when to use CRF.
What Is CRF? A Plain-Language Explanation
CRF stands for Constant Rate Factor. It is a way to control how much your video gets compressed. Instead of telling the encoder "make the file this size" or "use this much bandwidth," CRF says "make the video look this good."
Think of it like a quality dial. You set the dial to a number, and the encoder figures out how many bits each part of the video needs to achieve that quality level. Simple scenes (a person standing against a plain wall) need fewer bits. Complex scenes (a crowd at a concert with confetti flying) need more bits. CRF handles this allocation automatically.
This is why CRF is the most recommended compression method for anyone encoding video files. It is simple to use, produces excellent results, and requires only a single encoding pass.
If you are looking for ready-to-use commands, jump to our FFmpeg CRF examples. For a technical deep dive into how CRF compares with other methods, see our CRF video compression methods guide.
Why CRF Matters
Every video you watch online has been compressed. Raw video from a camera is enormous -- a single minute of uncompressed 1080p footage is about 11 GB. Compression shrinks that to a manageable size, but the method you choose for compression determines:
- How good the video looks after compression
- How large the file is
- How efficiently your bandwidth is used
CRF is popular because it optimizes for visual quality. The encoder spends more bits on parts of the video that need them (fast motion, fine detail, complex textures) and fewer bits on parts that do not (static backgrounds, slow fades, uniform colors). The result is consistent quality from start to finish.
The CRF Scale: What the Numbers Mean
CRF uses a numerical scale where lower numbers mean higher quality (and larger files), while higher numbers mean lower quality (and smaller files).
H.264 CRF Scale (the most common)
| CRF Value | Quality Level | What to Expect |
|---|---|---|
| 0 | Lossless | Mathematically identical to source. Enormous files. |
| 14-17 | Near-lossless | Virtually indistinguishable from source. Very large files. |
| 18-21 | Excellent | Only noticeable differences in pixel-level comparison. |
| 22-24 | Very good | The default range. Slight softening in complex areas. |
| 25-28 | Good | Noticeable compression in fast motion and fine detail. |
| 29-33 | Fair | Visible artifacts in complex scenes. Acceptable for drafts. |
| 34-40 | Poor | Obvious blockiness and blurriness. |
| 41-51 | Very poor | Heavily degraded. Only for extreme compression needs. |
The default CRF value in most encoders is 23 for H.264. This is a reasonable starting point that produces good-looking video at a moderate file size.
Key Principle: Lower CRF = Better Quality = Bigger File
This is the single most important thing to remember. If your video looks too compressed, lower the CRF number. If your file is too large, raise it.
A change of 6 CRF points roughly doubles or halves the file size. So:
- Moving from CRF 23 to CRF 17 approximately doubles the file size
- Moving from CRF 23 to CRF 29 approximately halves the file size
CRF Scales Differ by Codec
Different video codecs use different CRF scales. This catches many beginners off guard. A CRF of 23 in H.264 and a CRF of 23 in H.265 produce very different results.
| Codec | CRF Range | Default Value | "Good Quality" Range |
|---|---|---|---|
| H.264 (x264) | 0-51 | 23 | 18-25 |
| H.265 (x265) | 0-51 | 28 | 22-30 |
| VP9 | 0-63 | 31 | 25-35 |
| AV1 (SVT-AV1) | 0-63 | 35 | 25-40 |
Why are the defaults different? Because newer codecs are more efficient. H.265 at CRF 28 produces roughly the same visual quality as H.264 at CRF 23, but the H.265 file is about half the size. This is the whole point of newer codecs -- better quality at lower bitrates. For detailed codec comparisons, see our H.264 vs H.265 guide and AV1 vs VP9 vs H.264 guide.
How CRF Differs from Other Compression Methods
There are several ways to control video compression. Understanding how CRF compares to the alternatives helps you choose the right one.
CRF vs Constant Bitrate (CBR)
CBR sets a fixed bitrate for the entire video. Every second uses the same amount of data.
- Simple scene (talking head): Gets more bits than it needs. Wasteful.
- Complex scene (action sequence): Does not get enough bits. Quality drops.
CRF varies the bitrate to match the content. Every scene gets the bits it needs to maintain quality.
- Simple scene: Uses fewer bits. Looks great.
- Complex scene: Uses more bits. Also looks great.
When to use CBR: Live streaming, where consistent bandwidth is required. When to use CRF: Everything else -- recording, archiving, uploading to platforms.
CRF vs Variable Bitrate (VBR)
Two-pass VBR also varies bitrate by scene complexity, but it targets a specific average bitrate (and thus a predictable file size). It requires two encoding passes: the first analyzes the video, the second encodes it.
CRF produces similar quality variation but in a single pass, targeting quality rather than file size.
When to use VBR: When you need a specific file size (email attachments, storage limits). When to use CRF: When you care about quality and are flexible on file size.
Summary Table
| Method | Targets | Passes | File Size | Quality |
|---|---|---|---|---|
| CRF | Quality | 1 | Unpredictable | Consistent |
| CBR | Bitrate | 1 | Predictable | Variable |
| Two-pass VBR | Bitrate (average) | 2 | Predictable | Mostly consistent |
| Constant QP | Quantization | 1 | Unpredictable | Variable |
Your First CRF Encode
If you have FFmpeg installed, here is the simplest possible CRF encode:
ffmpeg -i input.mp4 -c:v libx264 -crf 23 output.mp4
That is it. This command:
- Takes
input.mp4as the source - Uses the H.264 codec (libx264)
- Sets CRF to 23 (good quality, moderate file size)
- Outputs to
output.mp4
Adding Audio
The basic command above copies audio without re-encoding. To explicitly set audio encoding:
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -c:a aac -b:a 128k output.mp4
Choosing a Preset
The -preset option controls how much effort the encoder puts into finding efficient compression. Slower presets produce smaller files at the same quality:
## Fast encoding (larger file)
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset fast -c:a aac -b:a 128k output.mp4
## Balanced (default)
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k output.mp4
## Better compression (slower, smaller file)
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset slow -c:a aac -b:a 128k output.mp4
For a complete set of examples across all codecs, see our FFmpeg CRF examples guide.
How to Choose the Right CRF Value
Step 1: Start with the Default
Every codec has a sensible default CRF value. Start there:
- H.264: CRF 23
- H.265: CRF 28
- VP9: CRF 31
- AV1 (SVT-AV1): CRF 35
Step 2: Test with a Short Clip
Do not encode your entire video at multiple CRF values. Instead, extract a 30-second representative sample and test:
## Extract a test segment
ffmpeg -i input.mp4 -ss 00:01:00 -t 30 -c copy test_clip.mp4
## Encode at a few CRF values
ffmpeg -i test_clip.mp4 -c:v libx264 -crf 20 test_crf20.mp4
ffmpeg -i test_clip.mp4 -c:v libx264 -crf 23 test_crf23.mp4
ffmpeg -i test_clip.mp4 -c:v libx264 -crf 26 test_crf26.mp4
Step 3: Compare Visually
Watch each test output and compare. Pay attention to:
- Fast-moving areas (are they sharp or blurry?)
- Fine details (hair, text, fabric textures)
- Gradients (sky, walls -- do you see banding?)
- Dark areas (shadow detail preservation)
Step 4: Pick the Highest CRF That Looks Good Enough
Higher CRF means smaller files. Choose the highest value where you cannot see objectionable quality loss. This gives you the most efficient encode.
Common CRF Recommendations by Use Case
| Use Case | H.264 CRF | H.265 CRF | Notes |
|---|---|---|---|
| Master archive | 17-18 | 20-22 | Preserve maximum quality |
| Professional delivery | 19-21 | 23-25 | Very high quality |
| General purpose | 22-24 | 26-28 | Best balance |
| Social media upload | 23-25 | 27-29 | Platforms re-encode anyway |
| Email / messaging | 26-30 | 30-34 | Smaller files, acceptable quality |
| Quick preview | 32-38 | 36-42 | Small files, noticeable compression |
For resolution-specific guidance, see our 720p bitrate and compression guide.
Common CRF Mistakes Beginners Make
Mistake 1: Using the Same CRF Number Across Codecs
CRF 23 for H.264 is "good quality." CRF 23 for H.265 is "excellent quality" -- which sounds fine, except you are creating a file that is larger than necessary. Use each codec's recommended default as your starting point.
Mistake 2: Thinking Lower CRF Is Always Better
CRF 0 is lossless, but the files are absurdly large. CRF 15 is nearly indistinguishable from lossless to the human eye. Going below CRF 17-18 for H.264 wastes storage with no visible benefit for nearly all content.
Mistake 3: Ignoring the Preset
Two encodes at CRF 23 can produce very different file sizes if one uses -preset ultrafast and the other uses -preset slow. The slower preset finds more efficient ways to compress, resulting in a smaller file at the same visual quality. Always consider the preset as part of your settings.
Mistake 4: Using CRF for Live Streaming
CRF produces variable bitrate output, which can spike during complex scenes. This causes buffering during live streams. For streaming, use CBR or constrained CRF (with -maxrate and -bufsize).
Mistake 5: Encoding Already-Compressed Video at Low CRF
If your source is already compressed (downloaded from YouTube, recorded at low quality), using CRF 18 will not restore quality. It will just create a large file that looks no better than the source. Match your CRF to the source quality -- there is no point using CRF 18 on source material that was originally CRF 28.
Mistake 6: Not Testing First
Every video is different. What works for one clip may not work for another. Always test with a short representative segment before encoding hours of footage.
The Relationship Between CRF, Preset, and File Size
These three factors work together:
- CRF sets the quality target
- Preset determines how hard the encoder works to achieve that quality efficiently
- File size is the result of both
Here is a simplified view for H.264 encoding a 1-minute 1080p clip:
| CRF | Preset | Approximate File Size |
|---|---|---|
| 23 | ultrafast | 65 MB |
| 23 | medium | 35 MB |
| 23 | slow | 32 MB |
| 20 | medium | 55 MB |
| 26 | medium | 22 MB |
Notice that changing the preset from ultrafast to medium (at the same CRF) reduced the file by nearly half. This is why preset matters.
When CRF Is NOT the Right Choice
CRF is excellent for most offline encoding, but it is not always the best option:
Live streaming: Use CBR or capped VBR for predictable bandwidth consumption.
Strict file size requirements: Use two-pass VBR to hit a target file size. For example, compressing a video to fit under a 25 MB email limit.
Adaptive bitrate streaming (HLS/DASH): Use per-segment bitrate targeting for consistent segment sizes.
Hardware-constrained real-time encoding: Some hardware encoders have limited CRF support. Their "constant quality" modes may not match software CRF in intelligence.
CRF in Practice: Real-World Scenarios
Scenario 1: Compressing a wedding video for sharing
You have a 2-hour 1080p wedding video (raw: 120 GB). You want to share it with family.
ffmpeg -i wedding_raw.mp4 -c:v libx264 -crf 22 -preset slow -c:a aac -b:a 192k wedding_compressed.mp4
Expected result: approximately 4-8 GB, excellent quality, playable on any device.
Scenario 2: Batch processing security camera footage
You have daily 720p recordings that need archiving with acceptable quality.
ffmpeg -i camera_20260302.mp4 -c:v libx265 -crf 30 -preset medium -c:a aac -b:a 64k archive_20260302.mp4
Expected result: dramatically smaller files (often 90% reduction), acceptable quality for review.
Scenario 3: Preparing a video for YouTube upload
YouTube re-encodes everything, so upload at high quality.
ffmpeg -i edited_video.mp4 -c:v libx264 -crf 18 -preset slow -c:a aac -b:a 192k youtube_upload.mp4
Expected result: large but high-quality source file that gives YouTube the best material to work with.
Simplify Compression with Vibbit
If command-line encoding feels intimidating, Vibbit's video compressor handles CRF selection automatically. Upload your video, choose your desired quality or target file size, and download the optimized result. No FFmpeg knowledge required. For converting between formats with optimal compression, try our video converter.
Frequently Asked Questions
What does CRF stand for?
CRF stands for Constant Rate Factor. It is a single-pass rate control method that targets a consistent quality level across the entire video by dynamically adjusting the bitrate based on scene complexity.
What is a good CRF value?
For H.264 (the most common codec), CRF 22-24 is a good starting point for general-purpose encoding. This range provides a good balance between visual quality and file size. For archival, use 17-20. For smaller files where some quality loss is acceptable, use 26-30. Always test with your specific content.
Does a lower CRF always mean better quality?
Lower CRF means higher quality, but with diminishing returns. The difference between CRF 18 and CRF 20 is barely perceptible to most people, yet the file size difference can be 30-40%. The difference between CRF 23 and CRF 28, however, is clearly visible. Find the highest CRF that still meets your quality standards.
Can I use CRF with any video codec?
Most modern video codecs support CRF or an equivalent mode. H.264 (x264), H.265 (x265), VP9, and AV1 (both libaom and SVT-AV1) all support CRF in FFmpeg. Hardware encoders (NVENC, QuickSync, AMF) typically offer a "constant quality" mode that is similar but not identical to software CRF.
Why do different codecs have different default CRF values?
Because each codec has different compression efficiency. H.265 at CRF 28 produces approximately the same quality as H.264 at CRF 23, but with a smaller file size. The higher default CRF for H.265 reflects that it needs fewer bits to achieve equivalent quality, not that it produces lower quality.
How is CRF different from just lowering the bitrate?
Lowering the bitrate sets a hard limit on data usage. CRF sets a quality target and lets the encoder decide the appropriate bitrate for each scene. CRF is smarter because it gives more bits to complex scenes and fewer to simple scenes, maintaining consistent quality throughout. A constant bitrate would give the same bits to every scene regardless of complexity.
Is CRF lossless at 0?
Yes, CRF 0 produces mathematically lossless output for H.264 and H.265 -- the decoded video is bit-for-bit identical to the source. However, the files are enormous (often larger than raw video due to codec overhead). For practical purposes, CRF 17-18 for H.264 is considered "visually lossless" and produces much more reasonable file sizes.