guide15 min read

Video Compression Methods: CRF, Bitrate Control & Resize Explained

Complete guide to video compression methods: CRF (Constant Rate Factor), CBR, VBR bitrate control, and resolution resize. Learn when to use each method for optimal quality and file size.

By Gisg

Understanding CRF Video Compression

Constant Rate Factor (CRF) is a rate control method used by modern video encoders to produce output with consistent perceptual quality. Unlike methods that target a specific bitrate or file size, CRF targets a quality level, allowing the encoder to use as many or as few bits as each frame needs to reach that quality.

CRF has become the default recommendation for offline video encoding because it produces the best quality-per-bit ratio without requiring two encoding passes. If you have ever searched for "best FFmpeg settings" or "how to compress video without losing quality," CRF is almost certainly the answer you found.

This guide explains how CRF works at a technical level, compares it with other rate control methods, and provides clear guidance on when CRF is the right choice. For practical command-line examples, see our FFmpeg CRF examples guide. If you are completely new to CRF, start with our CRF basics introduction.

How CRF Works Internally

The Quality-Targeting Mechanism

When you set a CRF value (for example, CRF 23 for H.264), you are telling the encoder: "Aim for this perceptual quality level across the entire video." The encoder then decides how many bits to allocate to each frame based on how difficult that frame is to compress.

The internal process works as follows:

  1. Frame analysis: The encoder analyzes each frame (or group of frames) to determine its complexity -- how much spatial detail exists, how much motion occurs, and how effectively the frame can be predicted from its neighbors.

  2. Quantization parameter (QP) selection: Based on the analysis, the encoder selects a quantization parameter for each macroblock or coding unit. Higher QP means more aggressive quantization (more compression, lower quality). Lower QP means less quantization (less compression, higher quality).

  3. Quality equalization: CRF adjusts QP values to maintain consistent perceived quality. A static scene gets a higher QP (fewer bits needed to look good), while a complex scene gets a lower QP (more bits needed to preserve detail).

  4. Psychovisual optimization: Modern encoders with CRF also consider human visual perception. Areas of the frame that the human eye is less sensitive to (fast motion, fine noise) receive less precision, while areas that matter more (edges, faces, text) receive more.

CRF and Quantization Parameter (QP)

CRF is often confused with QP (Quantization Parameter), but they are fundamentally different:

Property CRF Constant QP
Controls Perceptual quality Mathematical quantization
Bitrate behavior Varies to maintain quality Varies based on content
Quality consistency Consistent perceived quality Inconsistent perceived quality
Psychovisual optimization Yes (in most encoders) No
Scene adaptation Adjusts QP per scene Fixed QP everywhere

With constant QP, a simple scene and a complex scene receive the same quantization level, which means the simple scene looks better than necessary while the complex scene looks worse than it should. CRF corrects this imbalance.

The CRF Formula

In x264 and x265, CRF roughly follows this relationship:

QP = CRF + complexity_offset

Where complexity_offset is determined by the encoder's analysis of each frame's complexity relative to the video average. Simple frames get a positive offset (higher QP, fewer bits), complex frames get a negative offset (lower QP, more bits).

The actual implementation is more sophisticated, involving look-ahead buffers, macroblock tree analysis (mbtree), and frame-type weighting, but this simplified model captures the core concept.

Macroblock Tree (mbtree)

One of the most important sub-features of CRF in x264 and x265 is macroblock tree analysis. When enabled (it is on by default), mbtree tracks how often each macroblock is referenced by future frames.

Macroblocks that are referenced frequently (static background areas, for example) receive more bits because any quality loss in them propagates to many future frames. Macroblocks that are rarely referenced (areas about to be occluded by motion) receive fewer bits because their impact is temporary.

This mechanism is why CRF produces significantly better results than constant QP encoding, even though the average QP may be similar.

CRF Scales Across Different Codecs

Each video codec has its own CRF scale. These scales are not directly comparable because they reflect different underlying quantization systems.

H.264 (x264) CRF Scale

  • Range: 0-51
  • Default: 23
  • Lossless: 0
  • Visually lossless: approximately 17-18
  • Each +6 CRF: roughly doubles the quantization, halving quality precision

The H.264 CRF scale is the most intuitive. Each increment of 1 CRF corresponds to approximately 6% increase in file size reduction (or 6% less data).

H.265 (x265) CRF Scale

  • Range: 0-51
  • Default: 28
  • Lossless: 0
  • Visually lossless: approximately 20-22

H.265 uses the same numerical range as H.264, but the default is 28 instead of 23. This does not mean H.265 at CRF 28 is lower quality -- it means H.265 at CRF 28 produces approximately the same quality as H.264 at CRF 23, but with a smaller file. For more on how H.264 and H.265 compare, see our H.264 vs H.265 comparison.

VP9 CRF Scale

  • Range: 0-63
  • Default: 31
  • Lossless: 0
  • Visually lossless: approximately 15-20

VP9 uses a wider scale (0-63), so numerical values are not directly comparable to H.264/H.265.

AV1 CRF Scale

  • Range: 0-63 (both libaom and SVT-AV1)
  • Default: 32 (libaom), 35 (SVT-AV1)
  • Lossless: 0
  • Visually lossless: approximately 18-23 (libaom), 20-25 (SVT-AV1)

For a comprehensive comparison of these codecs, see our AV1 vs VP9 vs H.264 analysis.

Cross-Codec Quality Equivalence

Quality Level H.264 CRF H.265 CRF VP9 CRF AV1 (SVT) CRF
Visually lossless 17-18 20-22 15-20 20-25
Excellent 19-21 23-25 22-28 26-30
Good (general purpose) 22-24 26-28 30-34 32-36
Acceptable 26-28 30-32 36-40 38-42
Low quality 30+ 34+ 42+ 45+

CRF vs Other Rate Control Methods

CRF vs Constant Bitrate (CBR)

CBR maintains a fixed bitrate regardless of content complexity. This is the simplest rate control method and the one required for most live streaming scenarios.

Aspect CRF CBR
Quality consistency Consistent quality Variable quality
Bitrate behavior Variable Fixed
File size predictability Unpredictable Predictable
Encoding passes Single pass Single pass
Best for Offline encoding, archival Live streaming, real-time
Bandwidth usage Spiky Flat
Efficiency High (bits go where needed) Low (bits wasted on easy scenes)

Example scenario: A 10-minute video with 5 minutes of a static presenter and 5 minutes of rapid action footage.

  • CBR at 5 Mbps: The static portion looks excellent (more bits than needed), the action portion looks mediocre (not enough bits). Total: 375 MB.
  • CRF 23: The static portion uses maybe 2 Mbps (still looks excellent), the action portion uses maybe 8 Mbps (looks excellent). Total: perhaps 300 MB with better overall quality.

CRF vs Variable Bitrate (VBR)

Two-pass VBR shares CRF's ability to vary bitrate by scene complexity, but it targets a specific average bitrate (and thus a predictable file size) rather than a quality level.

Aspect CRF Two-Pass VBR
Quality consistency High High
File size predictability Low High
Encoding passes 1 2
Encoding speed Faster Slower (2x)
Bitrate target None (quality target) Specified average bitrate
Best for Quality-first encoding File size-constrained encoding

When to choose VBR over CRF: When you need to hit a specific file size (email attachment limits, storage quotas) or a specific average bitrate (bandwidth planning for CDN delivery).

CRF vs Constant QP (CQP)

Constant QP applies the same quantization parameter to every frame, without any quality-adaptive logic.

Aspect CRF Constant QP
Quality distribution Optimized across scenes Uniform QP everywhere
Perceptual quality Consistent Varies by scene complexity
Compression efficiency Higher Lower
Use case General encoding Testing, benchmarking
mbtree support Yes No

In practice, there is almost no reason to use constant QP over CRF for production encoding. CQP is mainly used in academic research and codec benchmarking where consistent quantization (rather than consistent quality) is the goal.

Decision Flowchart

Is this for live streaming or real-time delivery?
  Yes -> Use CBR at platform-recommended bitrate
  No  -> Do you need a specific file size?
           Yes -> Use two-pass VBR with target bitrate
           No  -> Do you need a bitrate ceiling?
                    Yes -> Use constrained CRF (CRF + maxrate + bufsize)
                    No  -> Use CRF

How Preset Affects CRF Output

A common misconception is that CRF alone determines the output file size. In reality, the encoder preset has a significant impact.

The preset controls how much computational effort the encoder invests in finding optimal compression. Slower presets find better ways to represent the same quality, resulting in smaller files at the same CRF value.

Preset Impact on File Size (H.264, CRF 23, 1080p, 60 seconds)

Preset Encoding Speed Approximate File Size Size vs Medium
ultrafast 10x 65 MB +85%
superfast 7x 55 MB +57%
veryfast 5x 48 MB +37%
faster 3.5x 42 MB +20%
fast 2.5x 38 MB +8%
medium 1x (baseline) 35 MB --
slow 0.5x 32 MB -8%
slower 0.3x 30 MB -14%
veryslow 0.15x 28 MB -20%
placebo 0.05x 27.5 MB -21%

Key observations:

  • The jump from ultrafast to medium is enormous (almost 2x file size reduction)
  • The jump from medium to veryslow is modest (about 20%)
  • placebo provides negligible improvement over veryslow at massive speed cost
  • For most workflows, medium or slow offers the best trade-off

Constrained CRF: Combining Quality and Bitrate Control

Constrained CRF is a hybrid approach that uses CRF as the primary quality target but enforces a maximum bitrate ceiling. This is useful for streaming scenarios where you want quality-adaptive encoding but cannot exceed a certain bandwidth.

ffmpeg -i input.mp4 -c:v libx264 -crf 22 -maxrate 6M -bufsize 12M output.mp4

How constrained CRF behaves:

  • Most of the time, the encoder operates in pure CRF mode
  • When the CRF target would exceed -maxrate, the encoder increases QP to stay within the limit
  • Scenes that would normally spike above 6 Mbps are compressed more aggressively
  • Simple scenes that naturally fall below 6 Mbps are encoded at full CRF quality
  • -bufsize determines how quickly the encoder reacts to bitrate violations (typically set to 2x maxrate)

CRF for Different Content Types

Different types of video content respond differently to CRF encoding. The optimal CRF value depends on the content characteristics.

High-Motion Content (Sports, Gaming, Action)

High-motion content requires more bits per frame to maintain quality. At the same CRF, a sports video will produce a larger file than a talking-head video.

  • Use CRF 18-22 for H.264
  • Consider -tune film for live-action sports
  • Consider higher frame rates (60 fps) to reduce per-frame motion blur

Low-Motion Content (Presentations, Tutorials, Webcam)

Static content compresses extremely well with CRF. The encoder allocates very few bits to unchanged areas.

  • CRF 24-28 for H.264 often looks excellent
  • File sizes will be dramatically smaller than high-motion content at the same CRF
  • Consider -tune stillimage for screen recordings with text

Animation and Cartoons

Animated content has unique characteristics: large uniform color areas, sharp edges, and sometimes very rapid scene changes.

  • Use -tune animation with H.264
  • CRF 20-24 for H.264 works well
  • Animation often compresses better than live action at the same CRF

Film with Grain

Preserving film grain requires extra bits. Without proper handling, CRF encoding will either waste bits trying to preserve random noise or smooth out the grain entirely.

  • Use -tune grain with H.264 to preserve grain
  • Use CRF 18-22 for grain preservation
  • Alternatively, denoise before encoding and use a higher CRF

Measuring CRF Quality: VMAF, SSIM, and PSNR

To objectively compare CRF values, you can use quality metrics:

VMAF (Video Multi-Method Assessment Fusion): Developed by Netflix, VMAF correlates well with human perception. Scores range from 0-100, where 95+ is excellent and 70+ is generally acceptable.

SSIM (Structural Similarity Index): Measures structural similarity between frames. Scores range from 0-1, where 0.95+ is excellent.

PSNR (Peak Signal-to-Noise Ratio): The oldest metric, measured in dB. Higher is better, but PSNR correlates poorly with human perception compared to VMAF.

## Calculate VMAF between original and encoded
ffmpeg -i encoded.mp4 -i original.mp4 -lavfi libvmaf -f null -

Typical VMAF Scores by CRF (H.264, 1080p)

CRF Typical VMAF Perception
17 97-99 Visually lossless
20 95-97 Excellent
23 92-95 Very good
26 87-92 Good
30 80-87 Acceptable
35 70-80 Noticeable degradation

Common Pitfalls with CRF Encoding

Mismatched CRF Scales Between Codecs

The most common mistake is assuming CRF values are equivalent across codecs. CRF 23 in H.264 is "good quality," but CRF 23 in H.265 is "excellent quality" (and produces larger files than necessary). Always use codec-appropriate defaults.

Ignoring Preset Impact

Two encoders using "CRF 23" can produce files with vastly different sizes if one uses -preset ultrafast and the other uses -preset slow. Always specify and document the preset alongside the CRF value.

No Look-Ahead or mbtree

Some encoding pipelines disable mbtree or use zero look-ahead for speed. This significantly reduces CRF's ability to distribute bits intelligently, negating much of its advantage over constant QP.

Using CRF for Bandwidth-Critical Applications

CRF's variable bitrate can produce momentary spikes that overwhelm network buffers. For streaming, always use constrained CRF with -maxrate and -bufsize, or switch to CBR.

Simplify CRF Encoding with Vibbit

Understanding CRF values, presets, and codec-specific scales requires technical knowledge that most content creators should not need to worry about. Vibbit's video compressor automatically selects the optimal CRF value and encoder settings for your content type and quality target. Upload your video, choose a quality level, and get a perfectly compressed output. For format changes with optimal encoding, try our video converter.

Frequently Asked Questions

What does CRF stand for in video compression?

CRF stands for Constant Rate Factor. It is a rate control method that targets a consistent perceptual quality level throughout a video. Instead of specifying a bitrate, you specify a quality target (the CRF value), and the encoder varies the bitrate frame-by-frame to maintain that quality.

Is CRF better than bitrate encoding?

CRF produces better overall quality per byte than constant bitrate (CBR) encoding because it allocates bits where they are needed most. However, CRF is not suitable for all situations. Live streaming requires predictable bitrate (CBR or capped VBR), and file-size-constrained delivery requires two-pass VBR. For offline encoding where quality is the priority, CRF is almost always the best choice.

Why does my CRF encode produce different file sizes for different videos?

This is by design. CRF targets quality, not file size. A video with lots of motion and detail needs more bits to maintain quality, producing a larger file. A mostly static video needs fewer bits, producing a smaller file. If you need predictable file sizes, use two-pass VBR instead.

Can I compare CRF values between H.264 and H.265?

Not directly. The CRF scales use the same numerical range (0-51) but represent different quality levels. A rough conversion is: H.265 CRF is approximately H.264 CRF + 5. So H.264 CRF 23 corresponds roughly to H.265 CRF 28. However, the H.265 file will be significantly smaller because H.265 is a more efficient codec.

What CRF should I use for YouTube uploads?

For YouTube uploads, use CRF 17-20 with H.264 and the slow preset. YouTube will re-encode your video regardless, so uploading at higher quality gives YouTube better source material. There is no benefit to uploading at CRF 0 (lossless) since the file will be enormous and YouTube will compress it heavily anyway.

Does CRF work with hardware encoders (NVENC, QuickSync)?

Hardware encoders like NVIDIA NVENC and Intel QuickSync have their own CRF-like modes (often called "constant quality" or CQP mode), but they are not identical to software CRF. Hardware encoders lack features like mbtree analysis and sophisticated look-ahead, so they typically produce larger files at equivalent quality. For best CRF results, use software encoders (libx264, libx265, libsvtav1).

How do I find the optimal CRF for my specific content?

Encode a 30-60 second representative segment at several CRF values (for example, 20, 23, 26, 28 for H.264), compare quality visually and with VMAF scores, and check file sizes. Choose the highest CRF (smallest file) that still meets your quality requirements. This test takes only a few minutes and can save significant storage and bandwidth.

Tags

video compression methodscrf bitrate resizevideo compression crfconstant rate factorcrf vs bitratevideo resize compressionrate control methodscbr vs vbr vs crf