Handling Multiple Image Items in libavif

This article explains how the libavif library processes AVIF files containing multiple independent image items. It details how the decoder identifies the primary image, how it distinguishes between image sequences and static collections, and what happens to secondary or alternate images during the decoding process.

In the AVIF specification—which is built upon the High Efficiency Image File Format (HEIF) and the ISO Base Media File Format (ISOBMFF)—a single file can package multiple independent image items. These items can represent alternate resolutions, different crops, or entirely distinct images grouped together.

Primary Item Identification

When libavif parses an AVIF file containing multiple independent items, its default behavior is guided by the pitm (Primary Item) box in the file’s metadata.

Image Sequences vs. Image Collections

libavif distinguishes between multiple images based on how they are structured within the container:

Accessing Non-Primary Independent Items

If an AVIF file contains multiple independent static images and you need to access an item other than the primary one, the high-level libavif decoder API has specific design limitations: