Constant rate factor

Also known as: CRF

On this page 7

Constant rate factor (CRF) is a quality-targeted rate control mode used by video codecs such as x264, x265 and several AV1 encoders, in which the user chooses a target quality level instead of a target bitrate. The encoder then spends as many bits as each scene needs, so the file size becomes the result rather than the input.

In video codecs, CRF sits beside constant bitrate, variable bitrate and constant quantizer as one of the main ways to decide how many bits each frame receives. It is the default mode for offline encoding in many tools because it delivers consistent visual quality with a single setting and a single encoding pass.

How constant rate factor allocates bits

CRF works by holding a rate factor steady and deriving the quantization parameter (QP) for each frame from it. The quantizer decides how coarsely transform coefficients are rounded: a higher QP discards more detail and produces fewer bits, while a lower QP preserves detail and costs more bits.

Unlike constant quantizer mode, CRF does not apply the same QP everywhere. The encoder measures scene complexity and motion, then raises the quantizer slightly in fast, complex frames where the eye notices less detail, and lowers it in calm frames where artifacts would be obvious. This psychovisual adjustment is the reason CRF usually looks better than a fixed QP at the same average size.

Several mechanisms work together inside a typical CRF encoder:

  • Lookahead analysis examines upcoming frames to estimate complexity and plan bit distribution.
  • Macroblock-tree or CU-tree logic gives more bits to blocks that later frames reference heavily.
  • Adaptive quantization shifts bits within a frame toward flat areas, where banding is most visible.
  • Frame-type offsets give I-frames a lower QP and B-frames a higher QP than P-frames.

CRF scales and typical values

The CRF scale is encoder-specific, so the same number does not mean the same quality across codecs. In x264 and x265 the scale runs from 0 to 51 for 8-bit content, where lower numbers mean higher quality and about 6 steps roughly double or halve the bitrate.

The following table lists commonly cited ranges for popular software encoders; the exact visual result also depends on preset, resolution and source quality.

EncoderScaleDefaultCommon working range
x264 (H.264)0 to 512318 to 28
x265 (H.265)0 to 512820 to 30
libaom (AV1)0 to 63Varies by build25 to 40
SVT-AV11 to 633525 to 45
libvpx-vp9 (VP9)0 to 63Requires bitrate of 015 to 35
Typical CRF ranges by encoder

In x264, CRF 0 is mathematically lossless for 8-bit input, CRF 17 to 18 is often described as visually transparent for most viewers, and values above 28 usually show visible softening. The encoder preset also matters: a slower preset at the same CRF produces a smaller file at similar quality, because it searches harder for efficient predictions.

Constant rate factor compared with other rate control modes

CRF is one of several rate control strategies, and each answers a different question: how good, how large, or how steady. The comparison below shows where CRF differs from its neighbors in the Topic.

ModeWhat the user setsWhat variesBest suited to
Constant rate factorTarget qualityBitrate and file sizeArchiving, on-demand files, personal encodes
Constant quantizerFixed QPBitrate and perceived qualityTesting and research
Constant bitrateFixed bitrateQualityLive broadcast and fixed channels
Two-pass variable bitrateAverage bitratePer-scene bitrateDelivery with a strict file size
Capped CRFQuality plus maximum rateBitrate up to a ceilingAdaptive streaming ladders
Rate control modes at a glance

The essential trade-off is predictable quality versus predictable size. CRF guarantees neither an exact file size nor a stable bitrate, which makes it unsuitable on its own for bandwidth-limited delivery. Two-pass variable bitrate reaches a target size with very similar efficiency but needs a second encoding pass.

Choosing and configuring CRF in practice

Choosing a CRF value means matching quality to the viewing context and the source. A practical method is to encode a short, demanding clip at several values, compare the results on the target display and select the highest CRF without visible artifacts.

SituationSuggested approachReason
Near-lossless mezzanineCRF 10 to 16 in x264Preserves detail for later re-encoding
High-quality archiveCRF 18 in x264 or 20 in x265Visually transparent for most material
Web on-demand uploadCRF 20 to 23 with a slow presetBalances size and quality
Streaming renditionCRF with maximum rate and buffer sizeLimits bitrate peaks for players
Grainy film sourceLower CRF or film grain tuningGrain consumes many bits
Suggested starting points for x264 and x265

For streaming, CRF is usually combined with VBV constraints, set as a maximum rate and a buffer size. This capped CRF approach keeps the quality-driven allocation but prevents bitrate spikes that would cause rebuffering on a constrained connection.

Limitations and common mistakes with CRF

CRF is easy to use, yet several misunderstandings lead to oversized files or disappointing quality. Most problems come from treating the number as universal or from ignoring delivery constraints.

SymptomLikely causeFix
File far larger than expectedNoisy or grainy sourceDenoise lightly or raise CRF
Same CRF looks worse in x265Scales differ between encodersCalibrate each encoder separately
Player stalls on mobileUncapped bitrate peaksAdd maximum rate and buffer size
Banding in dark gradientsToo high CRF on 8-bit outputLower CRF or encode in 10-bit
Unpredictable delivery sizeCRF used for a size targetUse two-pass variable bitrate
Frequent CRF problems and fixes

Another frequent error is assuming that CRF is identical to constant quality in hardware encoders. Hardware implementations such as NVENC offer constant quality modes with similar intent, but their scales, lookahead depth and psychovisual tools differ, so values do not transfer directly between software and hardware encoders.

In everyday language

Constant rate factor is a way of telling a video encoder how good the video should look, rather than how big the file should be. The encoder then decides on its own how much data each scene needs.

Think of packing a suitcase where every item must arrive undamaged. Fragile items get more padding, sturdy ones get less, and the suitcase ends up whatever size it needs to be. A quiet interview scene needs little data, while a fast football match needs much more. The key idea is steady quality with a flexible file size.

Seen in the real world

A small production company archives finished 1080p corporate videos for clients who may request copies years later. The editor exports a high-quality master from the editing system and then encodes an archive copy with x264 at CRF 18 and the slow preset, keeping the original audio.

A ten-minute talking-head video produces a file of roughly 600 MB, while a ten-minute event montage with handheld motion and confetti produces about 1.6 GB. Both look visually indistinguishable from the master on a calibrated monitor. When the same footage later goes to a streaming platform, the editor adds a maximum rate of 8 Mbps with a matching buffer, which keeps playback smooth while preserving the quality-first approach.