How AVIF Stores XMP Metadata with Image Data
The AV1 Image File Format (AVIF) leverages the flexible ISO Base Media File Format (ISOBMFF) architecture to store Extensible Metadata Platform (XMP) data alongside primary image bitstreams. Rather than embedding metadata directly into the AV1 video compression stream, the AVIF container isolates metadata into distinct structural items and establishes links between the metadata and the target image using standard container-level references. This architecture ensures that applications can access, parse, or discard descriptive metadata like copyright, licensing, and capture details without touching or decoding the underlying image data.
The Role of ISOBMFF Architecture
AVIF is not a standalone raw image format; it is an image profile built on top of the High Efficiency Image File Format (HEIF), which inherits its structure from ISOBMFF. In ISOBMFF, all data is organized into hierarchical blocks called "boxes" (or atoms).
Primary image content and metadata are treated as distinct entities
called "items" within the top-level Meta Box (meta). This
separation of concerns allows the container to handle multiple types of
data—such as image grids, alpha channels, Exif blocks, and XMP
packets—uniformly.
Identifying XMP Items in the Meta Box
To register an XMP payload inside the container, AVIF uses the Item
Information Box (iinf), which contains individual Item Info
Entry (infe) boxes for every item in the file.
- Item ID Assignment: The parser assigns a unique
numeric
item_IDto the primary image and a distinctitem_IDto the XMP metadata block. - Item Type Specification: For XMP, the
infebox specifies anitem_typeset tomime. - MIME Type String: The item entry defines the MIME
content-type string as
application/rdf+xml. This string explicitly signals to parsers that the item payload contains standard RDF/XML-encoded XMP data.
Linking Metadata to Image Data via References
Once the image and the XMP metadata are declared as separate items,
the container must define how they relate to one another. This
relationship is managed by the Item Reference Box
(iref).
The iref box creates directed links between items using
specific Four-Character Codes (FourCC). For XMP metadata:
- The container creates a reference of type
cdsc(Content Describes). - The reference identifies the XMP metadata item as the source and
points to the primary image item (
pitm) as the target. - This explicitly tells reading software that the payload of the metadata item describes the attributes of the referenced image item.
In cases where an AVIF file contains an image sequence or multiple
derived images (such as thumbnails or auxiliary depth maps), multiple
cdsc links can be created, or links can be directed
strictly to the primary image item to avoid redundant metadata
duplication.
Physical Storage in the Media Data Box
While the meta box provides the index, identifiers, and
relationship mappings, the actual raw XMP text is stored either directly
within an Item Data Box (idat) inside the meta
box or, more commonly, within the top-level Media Data Box
(mdat).
The Item Location Box (iloc) acts as the bridge between
the structural index and the physical bytes:
- It maps the XMP
item_IDto an explicit byte offset and byte length within the target data box. - Reading systems read the
ilocentry for the XMP item and immediately locate the exact byte range containing the serialized XMP packet without needing to scan the entire file sequentially.
Performance and Parsing Advantages
Handling XMP in this manner provides major performance benefits:
- Selective Extraction: Web crawlers, photo managers, and content registries can retrieve attribution and copyright data simply by parsing the container boxes, skipping the large image payload entirely.
- Streamability: Encoders can place the metadata at the beginning of the file, allowing user agents to read image properties and rights data before the full image frame has finished downloading.
- Lossless Editing: Metadata can be updated or
stripped by rewriting container offsets and the
mdatpayload without needing to recompress the AV1 image stream.