Force 4:4:4 Chroma Retention in libavif and cavif

By default, AVIF encoders use 4:2:0 chroma subsampling to maximize file size reduction, which often leads to color bleeding, blurry saturated edges, and degraded UI text. This article covers the explicit command-line flags required by both libavif (avifenc) and cavif to disable chroma subsampling and force 4:4:4 chroma retention, ensuring maximum color fidelity for graphics, text, and sharp illustrations.

Forcing 4:4:4 in libavif (avifenc)

In libavif, encoding is handled via the command-line utility avifenc. By default, avifenc targets 420 subsampling. To force full 4:4:4 chroma retention, use the -y or --yuv flag followed by 444.

Syntax and Example

avifenc -y 444 input.png output.avif

Or using the full argument name:

avifenc --yuv 444 input.png output.avif

Supported YUV Values in libavif

If you are performing lossless encoding using --lossless, avifenc automatically defaults to 444 to preserve all image information. However, when performing lossy compression, explicitly declaring -y 444 is required to prevent the encoder from dropping chroma resolution.


Forcing 4:4:4 in cavif

cavif is a standalone AVIF encoder written in Rust that utilizes the rav1e encoding engine. To dictate the pixel format and prevent chroma downsampling in cavif, use the --pixel-format flag.

Syntax and Example

cavif --pixel-format 444 input.png -o output.avif

Depending on the specific release build of cavif-rs, the argument can be specified as 444 or yuv444:

cavif --pixel-format=yuv444 input.png

Supported Pixel Formats in cavif


When to Use 4:4:4 Chroma