All formats

AVIF (AV1 Image File Format)

Full nameAV1 Image File Format
Extensions.avif (also used for animated files; .avifs is rare)
MIME typeimage/avif, image/avif-sequence (animated)
Typeraster image, lossy and lossless compression (AV1), still and animated
Starts with?? ?? ?? ?? 66 74 79 70 61 76 69 66 (....ftypavif), ftypavis for animated files
SpecificationAV1 Image File Format (AVIF)
Based onHEIF (ISO/IEC 23008-12) and ISO base media file format (ISO/IEC 14496-12), AV1 bitstream
Maintained byAlliance for Open Media (AOM)
Licenseopen, 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#

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#

Command line with libavif’s tools:

Shell
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#

Software that opens AVIF files#

SoftwareWindowsmacOSLinuxWebCanNotes
SumatraPDF✓viewfree, open source; also opens AVIF inside archives and comic books
Web browsers✓✓✓✓viewChrome, Edge, Firefox, Safari 16 and later. Also on Android and iOS
Microsoft Photos✓viewbuilt into Windows; needs the free AV1 Video Extension
macOS Preview✓view, convertbuilt into macOS 13 and later
GIMP✓✓✓view, edit, create, convertfree, open source
Krita✓✓✓view, edit, createfree, open source
darktable✓✓✓create, convertfree, open source photo editor; exports AVIF
Paint.NET✓view, editfree; needs the AV1 Video Extension
IrfanView✓view, convertfree for non-commercial use; needs the plugins pack
XnView MP✓✓✓view, convertfree for private use
ImageMagick✓✓✓convert, createcommand line, open source
libavif (avifenc, avifdec)✓✓✓create, convertreference command line tools
FFmpeg✓✓✓convert, createcommand line; still and animated AVIF
Squoosh✓convertcompare 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
Gogen2brain/avif
PythonPillow, pyvips
Rubyruby-vips
Rustimage, ravif
PHPGD, Imagick