What is a RIFF File?
Resource Interchange File Format (RIFF) is a chunk-based container structure developed by Microsoft and IBM. Its labeled, size-delimited chunks form the basis of formats including WAV and AVI.
How RIFF Files work
A RIFF file is a single outer chunk: the four-character code RIFF, a 32-bit size, and a four-character form type such as WAVE or AVI , followed by subchunks. Every chunk carries a four-character code, a 32-bit byte count, and its data. The 1991 specification lets only RIFF and LIST chunks contain other chunks, but later forms can define their own containers, such as WebP’s ANMF animation-frame chunk. The form type determines which chunks are mandatory, which are optional, and whether their order matters. Integers are little-endian; the 1991 specification also defines a big-endian counterpart, RIFX, but registered no RIFX form types. In a media pipeline, demuxers walk the chunk tree to locate samples, format descriptions, indexes, and metadata, skipping chunks they do not recognize by their declared size.
Key facts
- RIFF payloads are word-aligned: a chunk with an odd data length is followed by a zero pad byte that is not counted in that chunk’s declared size. A reader that advances by the declared size alone lands one byte early on the next chunk header.
- Sizes are 32-bit, so a plain RIFF file tops out near 4 GB, and the remedy depends on the form. For WAVE, EBU’s RF64 and its ITU successor BW64 replace the leading
RIFFwithRF64orBW64and add ads64chunk, placed first, that holds 64-bit sizes. When the outer size or thedatachunk size reads0xFFFFFFFF, use the 64-bit value fromds64; otherwise the 32-bit value stands. EBU now directs users to ITU-R BS.2088 instead of its own RF64 text. AVI uses the separate OpenDML extensions. FFmpeg’s WAV muxer documentation warns that RF64 support is not as universal as RIFF. - Do not locate audio or video at fixed offsets. The specification tells programs to expect and ignore unknown chunks in every RIFF form, and a form fixes only part of the order: a WAVE file must contain a format chunk and a data chunk, with the format chunk first, but other chunks can sit between or before them. Recorders that may later switch to RF64 or BW64 write a
JUNKplaceholder ahead of the format chunk, and FFmpeg notes that such a chunk can confuse simplistic WAV readers. - RIFF identifies a structure, not a media type. Ordinary WAV, AVI, and WebP files all begin with
RIFF; the four-character form type that follows the size field (bytes 8 through 11, counting from zero),WAVE,AVI, orWEBP, tells them apart. Large WAVE files that begin withRF64orBW64keepWAVEin that position. Chunk conventions can also differ by form: WebP, for example, does not follow RIFF’s uppercase convention for standard chunk codes.
When RIFF Files matter
Parse RIFF chunks when extracting metadata or media payloads from compatible files. Readers must honor chunk sizes and padding, because assuming a fixed order can break on valid files with optional or unknown chunks.
Sources
- IBM and Microsoft: Multimedia Programming Interface and Data Specifications, version 1.0 (August 1991), copy hosted by McGill University
- Library of Congress format description fdd000025: RIFF (Resource Interchange File Format)
- Microsoft Learn: AVI RIFF File Reference
- Microsoft Learn: Resource Interchange File Format Services
- Recommendation ITU-R BS.2088-2 (11/2025): Long-form file format for the international exchange of audio programme materials with metadata (BW64)
- EBU Tech 3306-2009 (July 2009): MBWF / RF64, an extended file format for audio
- EBU Tech 3306 v2 (June 2018): RF64, an extended file format for audio
- RFC 9649: WebP Image Format, section 2.3 RIFF File Format and section 2.4 WebP File Header
- Library of Congress format description fdd000059: AVI (Audio Video Interleaved) File Format
- FFmpeg Formats Documentation: wav muxer rf64 option