Best CRF Values for Lossy AVIF Image Encoding

This guide provides a comprehensive overview of choosing the optimal Constant Rate Factor (CRF) values when encoding lossy AVIF images. AVIF offers superior compression efficiency compared to older formats like JPEG and WebP, but achieving the ideal balance between visual quality and file size relies heavily on properly configuring the CRF parameter. Below, you will find direct recommendations for target use cases, encoder-specific considerations, and actionable best practices to optimize your image pipeline.

Understanding the AVIF CRF Scale

In most AVIF encoders—such as libavif using the AOMedia codec (libaom)—the CRF scale ranges from 0 to 63:

Because the scale is logarithmic, small numeric adjustments produce noticeable changes in quality and byte size.

Factors Influencing Optimal CRF Selection

1. Image Resolution and Pixel Density

Higher-resolution images (such as 4K or high-DPI assets) can sustain higher CRF values (e.g., CRF 32–36) because the human eye cannot easily detect small compression flaws across a dense pixel grid. Conversely, lower-resolution images (such as 400x400 thumbnails) require lower CRF values (e.g., CRF 22–26) to prevent visible edge blur and loss of crucial structural details.

2. Image Content and High-Frequency Detail

3. Color Depth (8-bit vs. 10-bit)

Whenever possible, encode lossy AVIF images using 10-bit color depth (--depth 10 in avifenc), even for standard 8-bit source images. The 10-bit encoding space drastically reduces banding and visual artifacts, effectively allowing you to increase the CRF value by 2 to 4 points to achieve lower file sizes with better visual fidelity.

4. Chroma Subsampling

While CRF controls quantization, chroma subsampling dictates color resolution:

Best Practices for Implementation