{
  "schemaVersion": 1,
  "contentVersion": "ca42e61ede0a24f789d7287a0001244ad22f4abf",
  "id": "docs/containers/avi",
  "collection": "docs",
  "title": "AVI",
  "description": "AVI is Microsoft's 1992 RIFF-based container; this page explains what it can and cannot do, and how to move old AVI files into MKV or MP4.",
  "canonicalUrl": "https://encode.wiki/containers/avi/",
  "apiUrl": "https://encode.wiki/api/v1/documents/docs/containers/avi.json",
  "markdownUrl": "https://encode.wiki/api/v1/markdown/docs/containers/avi.md",
  "status": "current",
  "tags": [
    "containers",
    "legacy"
  ],
  "license": "CC BY-SA 4.0",
  "dates": {
    "lastVerified": "2026-10-08T00:00:00.000Z"
  },
  "authors": [],
  "sources": [
    {
      "title": "Microsoft — AVI RIFF file reference",
      "url": "https://learn.microsoft.com/en-us/windows/win32/directshow/avi-riff-file-reference",
      "accessedAt": "2026-10-08T00:00:00.000Z"
    },
    {
      "title": "FFmpeg formats documentation — avi muxer",
      "url": "https://ffmpeg.org/ffmpeg-formats.html#avi",
      "accessedAt": "2026-10-08T00:00:00.000Z"
    },
    {
      "title": "FFmpeg bitstream filters — mpeg4_unpack_bframes",
      "url": "https://ffmpeg.org/ffmpeg-bitstream-filters.html#mpeg4_005funpack_005fbframes",
      "accessedAt": "2026-10-08T00:00:00.000Z"
    }
  ],
  "headings": [
    {
      "depth": 2,
      "text": "What AVI cannot do well",
      "anchor": "what-avi-cannot-do-well"
    },
    {
      "depth": 2,
      "text": "Convert AVI to MKV or MP4",
      "anchor": "convert-avi-to-mkv-or-mp4"
    }
  ],
  "sections": [
    {
      "id": "_preamble",
      "title": "Page introduction",
      "depth": 0,
      "canonicalUrl": "https://encode.wiki/containers/avi/",
      "apiUrl": "https://encode.wiki/api/v1/sections/docs/containers/avi/_preamble.json",
      "markdownUrl": "https://encode.wiki/api/v1/sections/docs/containers/avi/_preamble.md",
      "checksum": "f89bcaec25130634363f79947eb91f2f91b6db88f3465dd5ebe7878f6a304721",
      "bytes": 345
    },
    {
      "id": "what-avi-cannot-do-well",
      "title": "What AVI cannot do well",
      "depth": 2,
      "anchor": "what-avi-cannot-do-well",
      "canonicalUrl": "https://encode.wiki/containers/avi/#what-avi-cannot-do-well",
      "apiUrl": "https://encode.wiki/api/v1/sections/docs/containers/avi/what-avi-cannot-do-well.json",
      "markdownUrl": "https://encode.wiki/api/v1/sections/docs/containers/avi/what-avi-cannot-do-well.md",
      "checksum": "c3bbba5e691a84cbbedcec88e78966fa9474e4fbf13239b62d50fc7529f05a97",
      "bytes": 1217
    },
    {
      "id": "convert-avi-to-mkv-or-mp4",
      "title": "Convert AVI to MKV or MP4",
      "depth": 2,
      "anchor": "convert-avi-to-mkv-or-mp4",
      "canonicalUrl": "https://encode.wiki/containers/avi/#convert-avi-to-mkv-or-mp4",
      "apiUrl": "https://encode.wiki/api/v1/sections/docs/containers/avi/convert-avi-to-mkv-or-mp4.json",
      "markdownUrl": "https://encode.wiki/api/v1/sections/docs/containers/avi/convert-avi-to-mkv-or-mp4.md",
      "checksum": "92d3a1330ac5361f43820793d3e19bf273d46daa1cb1cdf2bb322c1fcff0a7d3",
      "bytes": 1309
    }
  ],
  "outboundReferences": [
    "/containers/matroska/",
    "/containers/mp4/"
  ],
  "checksum": "be7ab6d988b5ff764a297aaebc6b3d3fc16812939572fa1c77450c3dd4d18baf",
  "contentFormat": "markdown",
  "markdown": "AVI (Audio Video Interleave) is a RIFF-based container Microsoft introduced in 1992. It was the standard for DivX/Xvid files and old camcorders, and a great deal of legacy material is still stored in it. It works for playback of those files, but it is a poor target for anything new: use [MKV](/containers/matroska/) or [MP4](/containers/mp4/).\n\n## What AVI cannot do well\n\n- **No timestamps.** AVI stores a fixed frame rate in the stream header and each chunk is just \"the next frame\". There is no presentation time per frame.\n- **Variable frame rate** therefore has to be faked by inserting empty \"dropped frame\" chunks, or it is lost. Footage from phones and screen recorders often breaks, drifts, or gets retimed when put in AVI.\n- **B-frames** are a problem for the same reason: a decoder cannot derive presentation order from timestamps that are not there. MPEG-4 ASP (DivX/Xvid) used a \"packed bitstream\" workaround, which can confuse some remuxers; H.264 in AVI is non-standard, and many players mishandle it. Avoid B-frames in AVI-bound encodes, or better, do not use AVI.\n- **Limited codecs and features.** AVI has no standard place for modern codecs, multiple audio languages, subtitles (beyond non-portable hacks), chapters, or HDR/colour metadata. AAC and Opus audio are not reliably supported, and the format predates VBR audio, so VBR MP3 in AVI often seeks badly.\n- **Size.** Original AVI files are limited to 2 GB. The OpenDML extension (also called AVI 2.0) lifts that limit and is written by current tools, but very old players do not read it.\n\n## Convert AVI to MKV or MP4\n\nIf the streams are acceptable to the target, copy them:\n\n```sh\nffmpeg -i input.avi -c copy output.mkv\nffmpeg -i input.avi -c copy output.mp4\n```\n\nOld AVI files commonly contain MPEG-4 ASP (DivX/Xvid), MP3 or AC-3, which can be stream-copied to either container. Two things go wrong with B-frame files:\n\n- FFmpeg stops with \"Can't write packet with unknown timestamp\" because the AVI has no presentation times. Add `-fflags +genpts` before `-i` so FFmpeg generates them: `ffmpeg -fflags +genpts -i input.avi -c copy output.mkv`. `mkvmerge -o output.mkv input.avi` handles these files without extra options.\n- If FFmpeg warns about \"packed B-frames\" (the DivX/Xvid packed bitstream), add `-bsf:v mpeg4_unpack_bframes` to store them normally.\n\nIf the remux shows A/V desync or stuttering, the timing was damaged in the AVI; re-encoding the video usually fixes it:\n\n```sh\nffmpeg -i input.avi -c:v libx264 -crf 20 -c:a aac -b:a 192k output.mp4\n```\n\nRe-encoding lossy sources such as DivX adds a generation of loss, so use a low CRF and only when you have to. Do not use AVI to hold new H.264/HEVC/AV1 content. The one place AVI is still reasonable is uncompressed or lossless intermediates (for example Lagarith or UT Video from old Windows tools), but those fit just as well in MKV.\n"
}
