AVI file structure

How an AVI file is laid out as RIFF chunks: hdrl headers, stream lists, the movi data list, idx1 index and OpenDML extensions.

The top level

An AVI file is a RIFF file with form type AVI (with a trailing space). The sample is a 16 × 16 MJPEG clip with two frames at 5 frames per second and an 8 kHz audio track, written by ffmpeg. These are the chunks you will meet.

ChunkHolds
LIST hdrlThe main header and one stream list per stream
avihMain AVI header: frame duration, frame count, stream count, width and height
LIST strlOne per stream
strhStream header: type (vids or auds), codec FourCC, scale, rate and length
strfStream format: BITMAPINFOHEADER for video, WAVEFORMATEX for audio
JUNKPadding that readers skip
LIST moviThe video frames and audio blocks
idx1Index with one entry per chunk in movi
ID4 bytes0Size4 bytes4Datasize bytes8Pad1 if size odd8 + size
One chunk. The size counts only the data, not the 8-byte header or the pad byte.

Chunk names inside movi

Each data chunk ID is a two-digit stream number followed by a two-letter type: dc for a compressed video frame, db for an uncompressed frame, wb for audio and pc for a palette change. 00dc is a frame from stream 0 and 01wb is audio from stream 1. The sample interleaves them: one 00dc, two 01wb, then the same again.

Reading avih

In the hex view, offsets count from the start of the selected chunk, so the first payload byte is at 0x08, after the 4-byte ID and the 4-byte size. In the sample, avih gives 200000 microseconds per frame (5 frames per second), 2 total frames, 2 streams and a 16 × 16 picture. Flags 0x910 combine AVIF_HASINDEX (0x10), AVIF_ISINTERLEAVED (0x100) and AVIF_TRUSTCKTYPE (0x800).

Hex viewField
0x08Microseconds per frame
0x0CMaximum bytes per second
0x10Padding granularity
0x14Flags
0x18Total frames
0x1CInitial frames
0x20Streams
0x24Suggested buffer size
0x28Width
0x2CHeight
0x30Reserved, 16 bytes

Finding the codec

In a video strh, the stream type is at 0x08 and the codec FourCC at 0x0C; the sample reads vids then MJPG. The frame rate is the rate at 0x20 divided by the scale at 0x1C: 5 / 1. In the matching strf, the BITMAPINFOHEADER compression field at 0x18 also reads MJPG.

The idx1 index

Each idx1 entry is 16 bytes: chunk ID, flags (0x10 marks a keyframe), offset and size. Offsets usually count from the movi form type, though some writers use offsets from the start of the file. The sample index is 96 bytes, one entry for each of its six data chunks.

Large files and OpenDML

OpenDML (AVI 2.0) extends the format past the limits of a single RIFF chunk. It adds LIST odml with a dmlh header, indx and ix## index chunks, and continues the data in further RIFF AVIX chunks after the first. The viewer parses only the first RIFF chunk and warns when more follow.

Questions

How do I find out which codec an AVI uses?

Select the video stream’s strh and read the FourCC at 0x0C in the ASCII column, for example MJPG, XVID or H264.

Why does my AVI contain JUNK chunks?

They are padding. Writers reserve space or align data with them, and readers skip them.

What happens if an AVI has no idx1 index?

Players that rely on the index may not seek or may refuse the file. Remuxing with ffmpeg -i in.avi -c copy out.avi writes a new index. You can remux the AVI in the FFmpeg Runner without installing anything.

Can I play the AVI here?

No. The viewer shows the container structure only. For a file most players accept, convert the AVI to MP4.

Open the RIFF Viewer with your own file, or download the sample used above.