Best AVIF Settings for Sharp Retro Sprites
Preserving pixel art and retro game sprites in modern image formats requires careful encoder tuning, as traditional lossy compression algorithms tend to blur hard pixel boundaries and smear colors. While AVIF is known for photographic compression efficiency, it can also store crisp, high-contrast 2D art when configured correctly. This guide details the critical AVIF encoder parameters needed to maintain razor-sharp pixel edges, prevent color bleeding, and avoid unwanted smoothing artifacts.
1. Set Chroma Subsampling to 4:4:4 or RGB
The single most damaging default setting for pixel art is chroma subsampling (typically YUV 4:2:0). Subsampling halves the resolution of color information, causing bright pixels to bleed into adjacent dark pixels.
- Configuration: Set the pixel format to
yuv444p(4:4:4 subsampling) or directrgb(matrix coefficients set to identity). - Encoder Flag Example (ffmpeg/libavif):
-pix_fmt yuv444por--yuv 444
2. Use True Lossless or Near-Lossless Encoding
AV1 relies on transform blocks (such as the Discrete Cosine Transform) to discard imperceptible data. For pixel art, high-frequency edges cannot be discarded without introducing ringing (mosquito noise) around sprites.
- Lossless: Enable pure lossless mode if absolute
fidelity is required.
- Encoder Flag Example:
--lossless(libavif) or-crf 0(ffmpeg libsvtav1 / libaom-av1)
- Encoder Flag Example:
- Near-Lossless (If size is critical): If pure
lossless files are too large, use an extremely low quantization
parameter (QP) with a constant quality rate control mode.
- Encoder Flag Example:
-crf 10or lower, with minimum QP clamped close to zero.
- Encoder Flag Example:
3. Disable In-Loop Filtering (Deblocking and CDEF)
AV1 applies multiple filtering passes to smooth out block boundaries and noise in video frames, including the Deblocking Filter, Constrained Directional Enhancement Filter (CDEF), and Loop Restoration. When applied to sprites, these filters mistakenly recognize sharp pixel grids as compression artifacts and blur them.
- Configuration: Disable deblocking and restoration filters.
- Encoder Flag Example (libaom-av1):
--enable-cdef=0 --enable-restoration=0or-aom-params enable-cdef=0:enable-restoration=0
4. Enable Transform Block Partitioning Down to Small Sizes
Modern encoders default to large transform blocks (up to 64x64 or 128x128) to compress flat areas efficiently. For complex pixel arrangements, the encoder must be allowed to split blocks down to 4x4 pixels to capture intricate sprite details.
- Configuration: Set the minimum partition size to 4x4.
- Encoder Flag Example:
--min-partition-size=4
5. Set Full Color Range
Video standards often compress luminance values to standard broadcast ranges (16–235), crushing the dynamic range of retro graphics.
- Configuration: Force full-range color (0–255) to maintain deep blacks and bright primary colors common in 8-bit and 16-bit palettes.
- Encoder Flag Example:
-color_range pc(ffmpeg) or--range full(libavif)