Best AVIF Settings for Code Screenshots

Capturing computer screenshots of code demands distinct encoder configurations because standard AV1 presets prioritize natural photographic content, often causing blurry monospace typography and color bleeding across syntax highlighting. This guide details the essential AVIF encoder tuning options—primarily full chroma subsampling, screen-content tuning, quantizer controls, and edge-preservation settings—necessary to produce lightweight, pixel-perfect images of terminal and IDE windows.

1. Enforce YUV 4:4:4 Chroma Subsampling

By default, image and video encoders use YUV 4:2:0 subsampling, which halves color resolution horizontally and vertically to save bandwidth. For code screenshots with multi-colored text on dark or light backgrounds, 4:2:0 results in severe color bleeding, fringing around characters, and unreadable punctuation.

2. Set the Encoder Tuning Flag to Screen or SSIM

Most AV1 encoders (such as libaom, SVT-AV1, and rav1e) default to perceptual metrics like VMAF or visual psychovisual models that blur high-frequency noise. Because code consists entirely of high-frequency sharp edges, standard perceptual tuning degrades text legibility.

3. Use 10-Bit Color Depth

Even when your source screenshot is 8-bit sRGB, encoding the output as 10-bit (yuv444p10le) significantly improves the compression efficiency of the AV1 format.

4. Optimize Quantization (CRF / CQ Levels)

Screenshots of code contain large areas of flat color mixed with isolated high-contrast pixels. Avoid aggressive compression that triggers discrete cosine transform (DCT) ringing artifacts around character glyphs.

5. Disable Filtering and Adaptive Smoothing

Video-oriented AV1 features attempt to soften grain and sharp lines to make motion appear smoother. For static code captures, these mechanisms must be suppressed:

Practical Implementation

Using the reference tool avifenc (libaom-based), the optimal command for a code screenshot is:

avifenc --min 15 --max 25 -d 10 -y 444 --tune ssim -s 4 screenshot.png code_optimized.avif

Using ffmpeg with libaom-av1:

ffmpeg -i screenshot.png -c:v libaom-av1 -crf 20 -b:v 0 -pix_fmt yuv444p10le -cpu-used 4 -aom-params tune=ssim:enable-rect-partitions=1 code_optimized.avif

These parameters balance encoding time, keep file sizes far below comparable PNGs, and guarantee legible, artifact-free code rendering.