Format:AVI
| Developer | Microsoft |
|---|---|
| Magic | 52 49 46 46 xx xx xx xx 41 56 49 20 ("RIFF", size, "AVI ") |
| Extensions | .avi |
| Endianness | little |
| On this wiki | Facts · Code · Notes · Topics |
Microsoft's RIFF-based video container (.avi): RIFF form type 'AVI ' with an hdrl list (avih main header, one strl per stream), a movi list of numbered stream chunks such as 00dc and 01wb, and an idx1 index; OpenDML adds AVIX continuation RIFFs and a super index for files over 1 GiB.
Overview
AVI is a RIFF file whose form type is AVI (with a trailing space). Its top-level layout is:
LIST hdrl:avih(the 56-byte MainAVIHeader: microseconds per frame, max bytes per second, padding, flags, total frames, initial frames, streams, suggested buffer size, width, height, 4 reserved dwords), then oneLIST strlper stream holdingstrh(stream header: typevids/auds/txts, handler FourCC, flags, scale, rate, start, length ...),strf(stream format: a BITMAPINFOHEADER for video, a WAVEFORMATEX for audio, see Format:RIFF WAVE#fmt chunk) and optionallystrd,strn,indx; an OpenDMLLIST odmlwithdmlh(true total frame count) may follow.LIST movi: the data chunks. Chunk ids are two decimal digits of the stream number plus a two-letter type:00dccompressed video frame,00dbuncompressed (DIB) video,00pcpalette change,01wbaudio data,02txtext.LIST recgroups interleaved chunks.idx1: an array of 16-byte entries (chunk id, flags, offset, size). Offsets are relative to the start of themovilist data in most files, but some writers use absolute file offsets, so players test both.
Flags
From FFmpeg libavformat/avi.h: main header flags AVIF_HASINDEX 0x10, AVIF_MUSTUSEINDEX 0x20, AVIF_ISINTERLEAVED 0x100, AVIF_TRUSTCKTYPE 0x800, AVIF_WASCAPTUREFILE 0x10000, AVIF_COPYRIGHTED 0x20000; stream flag AVISF_VIDEO_PALCHANGES 0x10000; index flags AVIIF_INDEX (keyframe) 0x10 and AVIIF_NO_TIME 0x100. FFmpeg limits an AVI to 100 streams and splits RIFF chunks at 0x40000000 bytes (AVI_MAX_RIFF_SIZE).
OpenDML (AVI 2.0)
Files over 1 GiB continue in additional top-level RIFF AVIX chunks, each holding another LIST movi. The stream's indx chunk is a super index pointing to per-segment standard indexes (ix00 for stream 0); idx1 then covers only the first RIFF. FFmpeg's avidec.c parses these (read_odml_index) with a recursion limit.
Codec identification
Video: the compression FourCC in strf (BITMAPINFOHEADER) and the handler in strh name the codec (DIB, MJPG, DIV3, DX50, XVID, cvid, IV50 ...). Audio: the wFormatTag of the WAVEFORMATEX. Game cutscenes in AVI frequently use an obscure FourCC for a proprietary codec; the FourCC is then the only lead.
Reversing notes
- If idx1 is missing or damaged, scan
movifor theNNxxchunk ids; pad bytes keep chunks word aligned. - JUNK chunks are normal: FFmpeg's AVI muxer writes a zero-filled
JUNKchunk beforeLIST movias padding for tag editing (default 1016 bytes when no padding is requested, avienc.c ~lines 584-590) and aJUNKplaceholder for the OpenDML super index (indx) and odml list; its resync scan in avidec.c skipsJUNK,idx1,indxandix##chunks while searching for data. Unverified: that some other tools pad movi to a 2048-byte boundary (not found in FFmpeg); check offsets rather than assume.
Code & repositories
See Library:FFmpeg (libavformat/avidec.c, avi.h, riff.c).
- https://github.com/FFmpeg/FFmpeg @
7045cc9b8020ebaae156f4947baa752625056f90· license: LGPL-2.1-or-later (declared by the contributor; GitHub's detector did not recognize LICENSE.md)
FFmpeg libavformat demuxers: riff.c (wFormatTag and FourCC tables), wavdec.c, avidec.c/avi.h, matroska.h (element ids), id3v2.h, isom.h/mov.c.
Tested on: source read, not run: Read riff.c tag table, wavdec.c probe, avi.h, matroska.h and id3v2.h at this commit (sparse checkout). Not built. · checked 2026-10-18