{
  "schemaVersion": "1.0",
  "canonicalPage": "https://fileformat.co/ext/avif",
  "inspectorUrl": "https://fileformat.co/inspect",
  "spec": {
    "slug": "avif",
    "extension": ".avif",
    "aliases": [],
    "name": "AVIF (AV1 Image File Format)",
    "shortName": "AVIF",
    "category": "media-3d",
    "tier": 1,
    "summary": "Royalty-free HDR & wide-gamut next-gen web image format wrapping AV1 keyframes inside an ISO Base Media (`ftyp`) container (`major_brand` = `avif` or `avis`).",
    "technicalNotes": "Shares the ISOBMFF box container with HEIC and MP4; requires reading offset `0x08` (`avif` for still images, `avis` for animated image sequences).",
    "mimeTypes": [
      "image/avif"
    ],
    "identifiers": {
      "specUrl": "https://aomediacodec.github.io/av1-avif/"
    },
    "binarySignature": {
      "endianness": "big",
      "magicBytes": [
        {
          "offset": 4,
          "hex": "66 74 79 70 61 76 69",
          "ascii": "ftypavi",
          "description": "ISOBMFF ftyp box with 'avif' or 'avis' brand prefix"
        }
      ],
      "containerFamily": "isobmff",
      "headerLayout": [
        {
          "offset": "0x00 - 0x03",
          "byteOffset": 0,
          "byteLength": 4,
          "lengthLabel": "4 B",
          "dataType": "uint32_be",
          "fieldName": "ftyp_size",
          "description": "Box byte length"
        },
        {
          "offset": "0x04 - 0x07",
          "byteOffset": 4,
          "byteLength": 4,
          "lengthLabel": "4 B",
          "dataType": "char[4]",
          "fieldName": "box_type",
          "description": "'ftyp' FourCC"
        },
        {
          "offset": "0x08 - 0x0B",
          "byteOffset": 8,
          "byteLength": 4,
          "lengthLabel": "4 B",
          "dataType": "char[4]",
          "fieldName": "major_brand",
          "description": "'avif' (still) or 'avis' (sequence)"
        }
      ]
    },
    "securityProfile": {
      "riskLevel": "low",
      "allowsArbitraryCodeOrMacros": false,
      "xxeRisk": false,
      "polyglotPrependRisk": false,
      "pickleDeserializationRisk": false,
      "uploadValidationNotes": "Inspect `ispe` box dimensions before full pixel decoding to block decompression bombs (e.g. 65000x65000px 10KB solid-color AV1 frames)."
    },
    "codeSnippets": {
      "python": "import struct, sys\nwith open(sys.argv[1], \"rb\") as f:\n    sz, box, brand = struct.unpack(\">I4s4s\", f.read(12))\n    assert box == b\"ftyp\" and brand in (b\"avif\", b\"avis\")\n    print(f\"AVIF brand={brand.decode()}\")",
      "typescript": "export async function isAvif(file: File) {\n  const txt = new TextDecoder().decode(await file.slice(4, 12).arrayBuffer());\n  return txt === 'ftypavif' || txt === 'ftypavis';\n}",
      "rust": "use std::{fs::File, io::Read};\nfn main() -> std::io::Result<()> {\n    let mut b = [0u8; 12];\n    File::open(std::env::args().nth(1).expect(\"usage: <prog> <file>\"))?.read_exact(&mut b)?;\n    println!(\"AVIF header: {}\", String::from_utf8_lossy(&b[4..12]));\n    Ok(())\n}",
      "go": "package main\nimport (\"fmt\"; \"io\"; \"os\")\nfunc main() {\n    f, err := os.Open(os.Args[1])\n    if err != nil {\n        fmt.Fprintln(os.Stderr, \"open:\", err)\n        os.Exit(1)\n    }\n    defer f.Close()\n    b := make([]byte, 12)\n    if _, err := io.ReadFull(f, b); err != nil {\n        fmt.Fprintln(os.Stderr, \"read:\", err)\n        os.Exit(1)\n    }\n    fmt.Println(string(b[4:12]))\n}"
    },
    "relatedFormats": [
      "heic",
      "webp",
      "png"
    ],
    "verifiedAt": "2026-11-14T16:09:03Z"
  },
  "samples": [
    {
      "id": "avif-minimal",
      "filename": "minimal-128x128.avif",
      "variant": "minimal",
      "title": "Minimal AVIF Still Image (128×128)",
      "description": "Real AVIF encoded by libavif via pillow-avif: ftyp avif, decodable AV1 primary item.",
      "localPath": "/fixtures/v1/avif/minimal-128x128.avif",
      "cdnUrl": "https://fileformat.co/fixtures/v1/avif/minimal-128x128.avif",
      "sizeBytes": 2446,
      "sha256": "c1d62b9cfb1ac1ef878cabf2033ef0bd25067ff3fcc032aa0dc5c2c833687918",
      "expectValid": true
    },
    {
      "id": "avif-realistic",
      "filename": "photo-640x480.avif",
      "variant": "realistic",
      "title": "640×480 AVIF Photo Fixture",
      "description": "Real AV1 Image File Format still encoded by libavif at 640×480.",
      "localPath": "/fixtures/v1/avif/photo-640x480.avif",
      "cdnUrl": "https://fileformat.co/fixtures/v1/avif/photo-640x480.avif",
      "sizeBytes": 40636,
      "sha256": "66e43e004db1ebc43bcf2b7e3f44198d43d83ec0d828b064a69e5ffa1254667e",
      "expectValid": true
    },
    {
      "id": "avif-edge-case",
      "filename": "truncated-box.avif",
      "variant": "edge-case",
      "title": "Truncated AVIF Payload Box",
      "description": "Real AVIF truncated inside the mdat payload — libavif decoder must raise.",
      "localPath": "/fixtures/v1/avif/truncated-box.avif",
      "cdnUrl": "https://fileformat.co/fixtures/v1/avif/truncated-box.avif",
      "sizeBytes": 2414,
      "sha256": "8fc0516c40d536a757998b236c6d6d96a4b5a36874d8b17c72a64829251e0ae4",
      "expectValid": false,
      "edgeCaseTag": "Truncated ISOBMFF Box"
    }
  ]
}