guide14 min read

FFmpeg CRF Examples: H.264, H.265, VP9 & AV1 (2026)

Copy-paste FFmpeg CRF commands with quality vs file size tables. Updated 2026. Best CRF values for H.264 (18–23), libx265 CRF (22–28), VP9 & AV1.

By Gisg

FFmpeg CRF Examples: The Definitive Guide

CRF (Constant Rate Factor) is the most popular rate control mode in FFmpeg for producing high-quality video encodes with efficient file sizes. Unlike constant bitrate encoding, CRF lets the encoder dynamically allocate bits where they are needed most, resulting in consistent perceptual quality throughout the video.

This guide provides practical, copy-paste FFmpeg CRF examples for every major codec, along with detailed tables comparing quality levels and file sizes. Whether you are encoding for streaming, archival, social media, or professional workflows, you will find the right CRF settings here.

If you are new to CRF and want to understand the concept before diving into commands, start with our CRF basics guide.

How CRF Works in FFmpeg

CRF assigns a single quality target to the entire encode. The encoder then varies the bitrate frame-by-frame to maintain that quality level. Scenes with complex motion or fine detail receive more bits, while static scenes receive fewer bits.

The key properties of CRF encoding:

  • Single-pass encoding: No need to analyze the video twice, making it faster than two-pass VBR
  • Quality-focused: The output targets a perceptual quality level, not a specific file size
  • Variable bitrate: The actual bitrate fluctuates based on content complexity
  • No bitrate cap by default: Without additional settings, file size is unpredictable (you can add -maxrate and -bufsize to constrain it)

CRF is ideal when you care about quality and are flexible on file size. For strict file size targets, use two-pass VBR instead. For a deeper comparison of these methods, see our video compression methods guide.

CRF Scales by Codec

Different codecs use different CRF scales. This is one of the most common sources of confusion -- a CRF of 23 in H.264 does not produce the same quality as a CRF of 23 in VP9.

Codec CRF Range Default CRF Visually Lossless Recommended Range Lower =
H.264 (libx264) 0-51 23 ~17-18 18-28 Better quality
H.265 (libx265) 0-51 28 ~20-22 22-32 Better quality
VP9 (libvpx-vp9) 0-63 31 ~15-20 20-40 Better quality
AV1 (libaom-av1) 0-63 32 ~18-23 20-40 Better quality
AV1 (libsvtav1) 0-63 35 ~20-25 22-45 Better quality

Important notes:

  • CRF 0 is lossless for H.264 and H.265 (produces extremely large files)
  • Lower CRF values always mean higher quality and larger files
  • The perceptual quality difference between adjacent CRF values is roughly 6% in file size for H.264

H.264 (libx264) CRF Examples

H.264 remains the most widely compatible codec. For a detailed comparison with H.265, see our H.264 vs H.265 guide.

Basic H.264 CRF Encode

ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k output.mp4

H.264 CRF with Preset Tuning

The -preset controls encoding speed vs compression efficiency. Slower presets produce smaller files at the same CRF value.

## Fast encoding, larger file
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset fast -c:a aac -b:a 128k output_fast.mp4

## Balanced (default)
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k output_medium.mp4

## Slow encoding, smaller file at same quality
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset slow -c:a aac -b:a 128k output_slow.mp4

## Very slow, best compression (for archival)
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset veryslow -c:a aac -b:a 128k output_veryslow.mp4

H.264 CRF Values for Different Use Cases

Use Case Recommended CRF Preset Notes
Archival / Master copy 17-18 veryslow Visually lossless, large files
High quality streaming 19-21 slow Excellent quality, moderate size
General purpose 22-24 medium Good balance of quality and size
Social media upload 23-26 medium Platforms will re-encode anyway
Bandwidth-constrained 26-28 medium Noticeable quality loss in complex scenes
Quick preview / draft 30-35 ultrafast Visible artifacts, very small files

H.264 CRF with Bitrate Cap (Constrained CRF)

When you need CRF quality targeting but want to prevent bitrate spikes:

## CRF 22 with max bitrate of 8 Mbps
ffmpeg -i input.mp4 -c:v libx264 -crf 22 -maxrate 8M -bufsize 16M -preset medium -c:a aac -b:a 128k output.mp4

H.264 CRF Output Size Comparison (1080p, 60 seconds)

CRF Value Approximate File Size Quality Description
17 85-120 MB Visually lossless
20 50-75 MB Excellent, nearly transparent
23 30-50 MB Very good, default quality
26 18-30 MB Good, minor artifacts in complex scenes
30 10-18 MB Acceptable, visible softness
35 5-10 MB Poor, obvious artifacts

File sizes vary significantly based on content complexity, resolution, and frame rate.

H.265 (libx265) CRF Examples

H.265 delivers approximately 50% better compression than H.264 at the same visual quality. See our comprehensive codec comparison for details.

Basic H.265 CRF Encode

ffmpeg -i input.mp4 -c:v libx265 -crf 28 -preset medium -c:a aac -b:a 128k -tag:v hvc1 output.mp4

The -tag:v hvc1 flag ensures compatibility with Apple devices and QuickTime.

H.265 CRF Values for Different Use Cases

Use Case Recommended CRF Preset Notes
Archival / Master copy 20-22 slow Visually lossless, ~40% smaller than H.264
High quality streaming 23-25 medium Excellent quality
General purpose 26-28 medium Good quality-to-size ratio
Storage-constrained 30-32 medium Noticeable compression
Mobile delivery 28-32 fast Balanced for mobile viewing

H.265 CRF with 10-bit Encoding

10-bit encoding reduces banding in gradients and often improves compression efficiency even for 8-bit source material:

ffmpeg -i input.mp4 -c:v libx265 -crf 26 -preset medium -pix_fmt yuv420p10le -c:a aac -b:a 128k -tag:v hvc1 output.mp4

H.265 CRF Output Size Comparison (1080p, 60 seconds)

CRF Value Approximate File Size Quality Description
20 45-65 MB Visually lossless
24 25-40 MB Excellent quality
28 15-25 MB Very good, default quality
32 8-15 MB Good, minor artifacts
36 4-8 MB Acceptable for previews

VP9 (libvpx-vp9) CRF Examples

VP9 is royalty-free and widely supported in web browsers. For a comparison with other web codecs, see our AV1 vs VP9 vs H.264 guide.

Basic VP9 CRF Encode

ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 31 -b:v 0 -c:a libopus -b:a 128k output.webm

The -b:v 0 flag is required for VP9 CRF mode. Without it, CRF will not work correctly.

VP9 Two-Pass CRF (Recommended for Best Results)

VP9 benefits significantly from two-pass encoding:

## Pass 1
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 -pass 1 -an -f null /dev/null

## Pass 2
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 -pass 2 -c:a libopus -b:a 128k output.webm

VP9 CRF Values for Different Use Cases

Use Case Recommended CRF Notes
High quality web delivery 20-25 Excellent quality
YouTube-style streaming 28-33 Good balance
General web video 31-36 Default range
Bandwidth optimization 38-42 Visible quality reduction

VP9 CRF with Row-Based Multithreading

Speed up VP9 encoding dramatically:

ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 -row-mt 1 -threads 8 -c:a libopus -b:a 128k output.webm

AV1 CRF Examples

AV1 offers the best compression efficiency of any widely supported codec. It is royalty-free and increasingly supported by hardware decoders.

AV1 with libaom (Reference Encoder)

## Basic AV1 CRF encode (slow but highest quality)
ffmpeg -i input.mp4 -c:v libaom-av1 -crf 30 -b:v 0 -cpu-used 4 -c:a libopus -b:a 128k output.webm

The -cpu-used parameter ranges from 0 (slowest, best quality) to 8 (fastest). Values of 4-6 offer a good balance.

AV1 with SVT-AV1 (Faster Encoder)

SVT-AV1 is significantly faster than libaom while producing competitive quality:

## SVT-AV1 encode (recommended for most users)
ffmpeg -i input.mp4 -c:v libsvtav1 -crf 30 -preset 6 -c:a libopus -b:a 128k output.webm

SVT-AV1 presets range from 0 (slowest) to 13 (fastest). Preset 6-8 provides a good speed-quality balance.

AV1 CRF Values for Different Use Cases

Use Case libaom CRF SVT-AV1 CRF Notes
Archival quality 18-22 20-25 Near-lossless
High quality streaming 25-30 28-33 Excellent for 4K content
Web delivery 30-35 33-38 Good balance
Bandwidth-constrained 38-45 40-48 Acceptable for mobile

AV1 CRF Output Size Comparison (1080p, 60 seconds)

CRF Value (SVT-AV1) Approximate File Size Quality Description
22 35-50 MB Near-lossless
28 18-30 MB Excellent quality
33 10-18 MB Very good
38 5-10 MB Good, efficient
45 2-5 MB Acceptable for previews

CRF Comparison Across All Codecs

To produce roughly equivalent visual quality (approximately "very good" general-purpose quality):

Codec Equivalent CRF Approx. File Size (1080p, 60s) Encoding Speed
H.264 (libx264) 23 35-50 MB Fast
H.265 (libx265) 28 18-28 MB Medium
VP9 (libvpx-vp9) 31 16-25 MB Slow
AV1 (libsvtav1) 33 12-20 MB Medium-Slow
AV1 (libaom-av1) 30 10-18 MB Very Slow

This table demonstrates why newer codecs exist: AV1 can produce files roughly 50-60% smaller than H.264 at equivalent visual quality. The trade-off is encoding speed and compatibility.

Advanced FFmpeg CRF Techniques

Constrained CRF for Streaming

When you need quality-targeted encoding that respects a maximum bitrate (for streaming or CDN delivery):

## H.264 constrained CRF for 1080p streaming
ffmpeg -i input.mp4 -c:v libx264 -crf 22 -maxrate 6M -bufsize 12M -preset slow -profile:v high -level 4.1 -c:a aac -b:a 128k output.mp4

## H.265 constrained CRF for 4K streaming
ffmpeg -i input.mp4 -c:v libx265 -crf 26 -maxrate 15M -bufsize 30M -preset medium -tag:v hvc1 -c:a aac -b:a 128k output.mp4

CRF with Encoding Tune Options

## Film content (live action)
ffmpeg -i input.mp4 -c:v libx264 -crf 22 -preset slow -tune film -c:a aac -b:a 128k output.mp4

## Animation / cartoon content
ffmpeg -i input.mp4 -c:v libx264 -crf 22 -preset slow -tune animation -c:a aac -b:a 128k output.mp4

## Grain preservation (for vintage/film grain content)
ffmpeg -i input.mp4 -c:v libx264 -crf 22 -preset slow -tune grain -c:a aac -b:a 128k output.mp4

## Zero-latency streaming
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset fast -tune zerolatency -c:a aac -b:a 128k output.mp4

CRF for Specific Resolutions

## 720p encode with appropriate CRF
ffmpeg -i input.mp4 -c:v libx264 -crf 22 -vf "scale=1280:720" -preset medium -c:a aac -b:a 128k output_720p.mp4

## 4K encode with H.265
ffmpeg -i input_4k.mp4 -c:v libx265 -crf 26 -preset medium -tag:v hvc1 -c:a aac -b:a 192k output_4k.mp4

For 720p-specific bitrate and compression guidance, see our 720p compression and bitrate guide.

Batch CRF Encoding

Encode all video files in a directory:

for f in *.mp4; do
  ffmpeg -i "$f" -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k "encoded_${f}"
done

CRF Testing Workflow

Before committing to a CRF value for a large batch, test with a short segment:

## Extract a 30-second test segment
ffmpeg -i input.mp4 -ss 00:01:00 -t 30 -c copy test_segment.mp4

## Encode at multiple CRF values
for crf in 20 23 26 28; do
  ffmpeg -i test_segment.mp4 -c:v libx264 -crf $crf -preset medium -c:a aac -b:a 128k "test_crf${crf}.mp4"
done

Compare the outputs visually and check file sizes to find the optimal CRF for your content.

Common CRF Mistakes to Avoid

Using the wrong CRF scale for the codec: A CRF of 23 is the default for H.264, but for H.265 the default is 28. Using 23 for H.265 produces unnecessarily large files.

Ignoring the preset: CRF alone does not determine file size. A faster preset at the same CRF produces larger files because the encoder spends less time finding efficient compression.

Forgetting -b:v 0 for VP9: VP9 requires -b:v 0 to enable true CRF mode. Without it, the encoder uses a different rate control algorithm.

Using CRF 0 for "best quality": CRF 0 produces lossless output with enormous file sizes. For visually lossless output, use CRF 17-18 for H.264 or CRF 20-22 for H.265.

Not adding -tag:v hvc1 for H.265: Without this tag, H.265 files will not play on Apple devices or in Safari.

Simplify Video Encoding with Vibbit

If FFmpeg command lines feel overwhelming, Vibbit's video compressor lets you achieve the same quality-focused compression with a visual interface. Upload your video, choose your target quality or file size, and let the tool handle the encoding parameters automatically. For format conversion with optimal settings, try our video converter.

Frequently Asked Questions

What is the best CRF value for FFmpeg?

There is no single "best" CRF value because it depends on your codec, content type, and quality requirements. For H.264 (libx264), CRF 22-24 is a good starting point for general-purpose encoding. For H.265 (libx265), CRF 26-28 produces equivalent quality. Always test with a short segment of your specific content to find the optimal value.

Does CRF affect encoding speed?

CRF itself does not affect encoding speed -- the -preset parameter does. A higher CRF (lower quality) will process slightly faster because the encoder has less work to do, but the difference is minimal compared to the impact of changing the preset from fast to slow.

Can I use CRF for live streaming?

CRF alone is not suitable for live streaming because it produces unpredictable bitrates. For streaming, use constrained CRF by adding -maxrate and -bufsize parameters, or use CBR/VBR rate control instead. The -tune zerolatency option also helps reduce encoding latency.

What CRF value gives the same quality as the original?

CRF 0 produces mathematically lossless output (identical to the source), but with enormous file sizes. For practically lossless output that is visually indistinguishable from the source, use CRF 17-18 for H.264, CRF 20-22 for H.265, or CRF 15-20 for VP9.

How do CRF values compare between H.264 and H.265?

A rough equivalence is: H.265 CRF = H.264 CRF + 4 to 5. So H.264 CRF 23 produces similar quality to H.265 CRF 27-28. However, the H.265 file will be approximately 40-50% smaller. This is because H.265 has more efficient compression algorithms, not because the CRF scales are directly comparable.

Should I use CRF or two-pass encoding?

Use CRF when you want consistent quality and do not need to hit a specific file size. Use two-pass encoding when you have a strict file size or bitrate target (for example, fitting a video under a 25 MB email attachment limit). CRF is simpler and faster since it only requires one pass.

What happens if I set CRF too high?

Setting CRF too high (for example, above 30 for H.264) results in visible compression artifacts: blocky areas in complex scenes, loss of fine detail, color banding in gradients, and smearing of textures. The exact threshold where artifacts become objectionable depends on your content -- high-motion sports footage degrades faster than talking-head videos.

Tags

ffmpeg crf examplescrf ffmpegffmpeg crf settingcrf value ffmpegbest crf valueffmpeg crf h264ffmpeg crf h265video compression ffmpegffmpeg encoding