AVIF (AV1 Image File Format)
| Full name | AV1 Image File Format |
|---|---|
| Extensions | .avif (also used for animated files; .avifs is rare) |
| MIME type | image/avif, image/avif-sequence (animated) |
| Type | raster image, lossy and lossless compression (AV1), still and animated |
| Starts with | ?? ?? ?? ?? 66 74 79 70 61 76 69 66 (....ftypavif), ftypavis for animated files |
| Specification | AV1 Image File Format (AVIF) |
| Based on | HEIF (ISO/IEC 23008-12) and ISO base media file format (ISO/IEC 14496-12), AV1 bitstream |
| Maintained by | Alliance for Open Media (AOM) |
| License | open, royalty-free (AOM patent license) |
AVIF stores images compressed with the AV1 video codec inside a HEIF container, the same box-based container that HEIC uses for HEVC images. At the same visual quality an AVIF photo is usually 30-50% smaller than JPEG and smaller than WebP. AVIF supports 8, 10 and 12 bits per channel, HDR (PQ and HLG transfer functions, BT.2020 color), wide color gamut, full alpha transparency, lossless compression and animation.
All current web browsers display AVIF, and Windows, macOS, iOS and Android can open it. Its main costs are slow encoding (much slower than JPEG or WebP at good settings) and a limit on frame size in each AV1 profile, so very large images are split into a grid of tiles.
When to use AVIF#
- Use for photos and complex images on the web: the smallest files of the formats all browsers support.
- Use for HDR and 10-bit images that must display in a browser.
- Use for images with transparency where PNG is too large and lossy compression is acceptable.
- Use instead of animated GIF: an animated AVIF is a fraction of the size.
- Avoid when encoding speed matters (on-the-fly thumbnails on a busy server, camera capture): JPEG, WebP or JPEG XL encode much faster.
- Avoid for lossless images: AVIF lossless is often larger than PNG optimized with oxipng, and larger than lossless WebP or JPEG XL.
- Avoid for very large images or when you need progressive decoding: JPEG XL handles both better.
- Avoid as an editing or archival master: use PNG, TIFF or the camera’s raw format.
File structure#
An AVIF file is an ISO base media file format (ISOBMFF) file: a sequence of boxes. Every box starts with a 4-byte big-endian size (including the 8-byte header) and a 4-byte ASCII type. A size of 1 means a 64-bit size follows the type; a size of 0 means the box runs to the end of the file. A “full box” adds 1 byte of version and 3 bytes of flags after the type.
A still AVIF has 3 top-level boxes:
ftyp file type: brands
meta metadata about the items (full box)
hdlr handler: 'pict' (image)
pitm primary item ID: the image to show
iinf item info: one 'infe' per item (ID and type)
infe item 1, type 'av01' (the color image)
infe item 2, type 'av01' (the alpha image)
infe item 3, type 'Exif'
iref references between items: 'auxl', 'cdsc', 'dimg'
iloc item location: offset and length of each item's data
iprp item properties
ipco property container: ispe, av1C, pixi, colr, auxC, irot, ...
ipma property association: which properties belong to which item
mdat media data: the AV1 bitstreams and metadata blobs
ftyp: file type#
The first box. A reader identifies AVIF by the brands in it:
00 00 00 20 box size: 32 bytes
66 74 79 70 type: ftyp
61 76 69 66 major brand: avif
00 00 00 00 minor version: 0
61 76 69 66 compatible brand: avif
6D 69 66 31 compatible brand: mif1 (HEIF image)
6D 69 61 66 compatible brand: miaf (MIAF)
4D 41 31 42 compatible brand: MA1B (AVIF Baseline profile)
| Brand | Meaning |
|---|---|
avif |
AVIF still image |
avis |
AVIF image sequence (animated) |
mif1, msf1 |
HEIF still image / image sequence |
miaf |
conforms to MIAF (Multi-Image Application Format) |
MA1B |
AVIF Baseline profile: AV1 Main profile, level 5.1 or lower |
MA1A |
AVIF Advanced profile: AV1 High profile, level 6.0 or lower |
Some encoders write mif1 as the major brand and list avif only as a compatible brand. Check all brands, not just the major one.
meta: items#
HEIF describes content as items, each with a numeric ID. The hdlr box must have handler type pict. pitm gives the ID of the primary item, the one a viewer shows. iinf lists each item and its type:
| Item type | Content |
|---|---|
av01 |
an image coded as one AV1 frame |
grid |
a derived image assembled from a grid of tiles (other av01 items) |
Exif |
Exif metadata |
mime |
XMP metadata (content type application/rdf+xml) |
tmap |
tone-mapped derived image (gain map, AVIF 1.2) |
iref connects items: auxl links an alpha or depth image to its color image, cdsc links metadata to the image it describes, dimg links a grid to its tiles. iloc gives, for each item, the byte offset and length of its data, usually inside mdat.
iprp: item properties#
ipco holds the properties; ipma maps each item ID to a list of property indexes, with an “essential” flag for properties a reader must understand.
| Property | Purpose |
|---|---|
ispe |
image spatial extents: width and height in pixels. Required |
av1C |
AV1 codec configuration: profile, level, bit depth, chroma subsampling, and the AV1 sequence header OBU. Required for av01 items |
pixi |
pixel information: number of channels and bits per channel |
colr |
color: nclx (CICP color primaries, transfer characteristics, matrix coefficients, full/limited range) or an ICC profile (prof, rICC) |
auxC |
auxiliary type: urn:mpeg:mpegB:cicp:systems:auxiliary:alpha marks an alpha plane |
irot, imir |
rotation (multiples of 90°) and mirroring, applied after decoding |
clap |
clean aperture (crop) |
pasp |
pixel aspect ratio |
clli, mdcv |
HDR content light level and mastering display color volume |
Image data#
Each av01 item’s data is one AV1 frame (a sequence of OBUs: open bitstream units), coded as an intra frame. AV1 supports 4:2:0, 4:2:2 (Professional profile), 4:4:4 and monochrome. Lossless AVIF uses 4:4:4 with the identity matrix (RGB coded directly) and quantizer 0.
Alpha is a separate monochrome av01 item, linked to the color item with an auxl reference and tagged with an auxC property. It’s coded separately, so it can use different quality from the color.
Large images: the AV1 levels used by the profiles limit the frame size (8192 x 4352 pixels for level 5.1). Bigger images, and images encoded in parallel, are stored as a grid item whose tiles are separate av01 items.
Animated AVIF#
An image sequence has brand avis and adds a moov box with a track (handler pict) like an MP4 video: sample tables in moov point to AV1 frames in mdat, and frames can use inter prediction. The track can have an alpha auxiliary track. Most animated files also have a meta box with a still primary image, so readers that don’t support sequences show the first frame.
Encoding settings#
- Quality: libavif, Pillow, GD and most tools use a 0-100 scale (higher is better); AV1 quantizer values (0-63, lower is better) are an older interface. Quality 50-65 is typical for web photos.
- Speed (effort): 0-10 in libavif/aomenc, lower is slower and gives smaller files. Speed 6 is a common default; speeds 0-3 can take minutes for a large photo.
- Chroma subsampling: 4:2:0 for photos; 4:4:4 for images with sharp colored edges, text or screenshots.
- Bit depth: 10-bit gives slightly better compression than 8-bit even for 8-bit sources, and is required for HDR.
- Encoders: libaom (reference, best quality per byte), SVT-AV1 (fast, parallel), rav1e (Rust). Decoders: dav1d (fastest), libaom, libgav1.
Command line with libavif’s tools:
avifenc -q 60 -s 6 photo.jpg photo.avif # quality 60, speed 6
avifenc --lossless image.png image.avif # lossless
avifdec photo.avif photo.png # decode to PNG
ffmpeg -i clip.mp4 -c:v libaom-av1 -crf 30 anim.avif # animated
Specifications and documentation#
- AV1 Image File Format (AVIF): the AVIF specification (AOM)
- AV1 Bitstream and Decoding Process Specification: the AV1 codec
- AV1 Codec ISO Media File Format Binding: the
av1Cbox and AV1 in ISOBMFF - ISO/IEC 23008-12: HEIF (paid)
- ISO/IEC 14496-12: ISO base media file format (paid)
- libavif: reference library, with
avifencandavifdec - av1-avif test files: sample files for decoders
- AVIF on Wikipedia
Software that opens AVIF files#
| Software | Windows | macOS | Linux | Web | Can | Notes |
|---|---|---|---|---|---|---|
| SumatraPDF | ✓ | view | free, open source; also opens AVIF inside archives and comic books | |||
| Web browsers | ✓ | ✓ | ✓ | ✓ | view | Chrome, Edge, Firefox, Safari 16 and later. Also on Android and iOS |
| Microsoft Photos | ✓ | view | built into Windows; needs the free AV1 Video Extension | |||
| macOS Preview | ✓ | view, convert | built into macOS 13 and later | |||
| GIMP | ✓ | ✓ | ✓ | view, edit, create, convert | free, open source | |
| Krita | ✓ | ✓ | ✓ | view, edit, create | free, open source | |
| darktable | ✓ | ✓ | ✓ | create, convert | free, open source photo editor; exports AVIF | |
| Paint.NET | ✓ | view, edit | free; needs the AV1 Video Extension | |||
| IrfanView | ✓ | view, convert | free for non-commercial use; needs the plugins pack | |||
| XnView MP | ✓ | ✓ | ✓ | view, convert | free for private use | |
| ImageMagick | ✓ | ✓ | ✓ | convert, create | command line, open source | |
| libavif (avifenc, avifdec) | ✓ | ✓ | ✓ | create, convert | reference command line tools | |
| FFmpeg | ✓ | ✓ | ✓ | convert, create | command line; still and animated AVIF | |
| Squoosh | ✓ | convert | compare quality settings in the browser |
Libraries#
Open-source libraries that read and write AVIF. See all AVIF libraries for a comparison.
| C/C++ | libavif, libheif |
|---|---|
| C# | Magick.NET, NetVips |
| Go | gen2brain/avif |
| Python | Pillow, pyvips |
| Ruby | ruby-vips |
| Rust | image, ravif |
| PHP | GD, Imagick |
Related formats#
- WebP: older, encodes faster, slightly larger files; also lossy, lossless, alpha and animation
- HEIC: the same HEIF container with HEVC compression, used by iPhone cameras
- JPEG XL: faster encoding, lossless JPEG recompression, progressive decoding
- JPEG: universal, much larger files at the same quality
- PNG: lossless; better for screenshots and line art
- MP4: the ISOBMFF container that animated AVIF borrows its track structure from