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

  1. 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.
  2. 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 RIFF with RF64 or BW64 and add a ds64 chunk, placed first, that holds 64-bit sizes. When the outer size or the data chunk size reads 0xFFFFFFFF, use the 64-bit value from ds64; 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.
  3. 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 JUNK placeholder ahead of the format chunk, and FFmpeg notes that such a chunk can confuse simplistic WAV readers.
  4. 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 , or WEBP, tells them apart. Large WAVE files that begin with RF64 or BW64 keep WAVE in 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

Turn media knowledge into a working pipeline

Connect uploads, processing, AI, storage, and delivery through one declarative API — with the encoding stack, scaling, and format churn handled for you.

Try Transloadit for free