How to Check AVIF Chroma Subsampling (4:2:0 or 4:4:4)
This guide explains how developers can inspect an AVIF image to
determine its chroma subsampling scheme, specifically distinguishing
between 4:2:0 and 4:4:4 formats. Because AVIF relies on the AV1 video
codec packaged inside an ISOBMFF container, standard image viewers often
hide color layout details. You will learn how to verify subsampling data
using command-line utilities such as FFprobe, avifdec, and
ExifTool.
1. Using FFprobe (FFmpeg)
FFprobe provides a reliable way to inspect the internal pixel format of an AVIF file. It reports the AV1 video stream's pixel format directly.
Run the following command:
ffprobe -v error -select_streams v:0 -show_entries stream=pix_fmt -of default=noprint_wrappers=1:nokey=1 image.avifInterpretation:
yuv420poryuv420p10le: The image uses 4:2:0 subsampling (8-bit or 10-bit).yuv444poryuv444p10le: The image uses 4:4:4 subsampling (full color resolution).yuv422p: The image uses 4:2:2 subsampling.
2. Using avifdec
(libavif)
The official reference library for AVIF, libavif,
includes a command-line tool named avifdec. It offers an
--info flag that reads container metadata without fully
decoding the image pixels.
Run the following command:
avifdec --info image.avifLook for the Format line in the output:
Format : YUV420indicates 4:2:0.Format : YUV444indicates 4:4:4.
3. Using ExifTool
Phil Harvey's ExifTool parses ISOBMFF box structures directly and
extracts color configuration records, such as the av1C (AV1
Configuration Box) or colr boxes.
Run the following command:
exiftool -ChromaSubsampling image.avifAlternatively, to view all color-related tags:
exiftool -s -G image.avif | grep -i subsamplingInterpretation:
YCbCr4:2:0or values indicating vertical and horizontal subsampling factors of2 2indicate 4:2:0.YCbCr4:4:4or factors of1 1indicate 4:4:4.
4. Inspecting via
Node.js (image-size or sharp)
If you need to inspect files programmatically in JavaScript or
TypeScript, you can use the sharp library:
const sharp = require('sharp');
async function checkSubsampling(filePath) {
const metadata = await sharp(filePath).metadata();
console.log(`Chroma Subsampling: ${metadata.chromaSubsampling}`);
}
checkSubsampling('image.avif');Sharp will return strings such as '4:2:0' or
'4:4:4' within the metadata object.