Embedding EXIF Metadata in AVIF Containers

Embedding Exchangeable Image File Format (EXIF) metadata into an AV1 Image File Format (AVIF) container requires adhering strictly to the ISO Base Media File Format (ISOBMFF) and HEIF (ISO/IEC 23008-12) specifications. This technical overview details the required structural boxes, data formatting, item associations, and binary payload constraints needed to correctly package EXIF data within an AVIF file so that decoders and parsers can extract it without errors.

1. The Metadata Box (meta) Structure

All metadata in an AVIF container must reside inside the top-level meta box (FourCC: meta). Within this container, the file must define a Handler Box (hdlr) with a handler_type set to 'pict', signaling that the metadata box manages image-related items.

2. Item Information Entry (infe)

The EXIF data block must be registered as an item in the Item Information Box (iinf):

  • Item Type: The item_type field must be explicitly set to 'Exif' (case-sensitive).
  • Item ID: It must be assigned a unique numeric item_ID (16-bit or 32-bit depending on the box version) that does not collide with any image item IDs.
  • Item Protection: The item protection index must be set to 0 unless the metadata payload is encrypted.

3. Item Reference Box (iref)

Because metadata belongs to a specific image, you must establish an explicit structural link between the EXIF item and the target image item:

  • The iref box must contain a reference entry with a reference type of 'cdsc' (content describes).
  • The from_item_ID must point to the EXIF item_ID.
  • The to_item_ID must match the primary image item_ID (typically the master AV1 item specified in the pitm box).

4. Binary Payload Format and the TIFF Header Offset

The raw binary payload of the EXIF item does not follow the traditional JPEG structure. Decoders expect the following byte configuration:

  • The 4-Byte Offset Indicator: The first 4 bytes of the EXIF data payload must be a 32-bit unsigned integer (big-endian) representing exif_tiff_header_offset.
  • TIFF Header Location: This offset defines the byte position within the payload where the TIFF header begins:
    • If the payload begins immediately with the TIFF header, the first 4 bytes must be 0x00000000.
    • If legacy prefixes such as the 6-byte string Exif\0\0 are included, the offset must accurately point to the index immediately following that prefix (e.g., 0x00000006). The recommended practice is to omit the prefix and set the offset to 0.
  • TIFF Header: At the specified offset, the data must begin with the standard TIFF header:
    • Either Little-Endian (0x49 0x49 0x2A 0x00 / II*.) or Big-Endian (0x4D 0x4D 0x00 0x2A / MM.*).
    • A 4-byte offset pointing to the primary Image File Directory (IFD0).
  • No JPEG Markers: Standard JPEG markers such as 0xFFE1 (APP1 marker) and stream length indicators must be stripped out.

5. Item Location (iloc)

The physical location and length of the EXIF payload must be declared inside the Item Location Box (iloc):

  • The entry corresponding to the EXIF item_ID specifies the construction method, data reference index, offset within the file, and total length in bytes.
  • The length must encompass the 4-byte offset indicator plus the entire EXIF/TIFF payload.