A native FLAC stream is the four-byte marker, one or more metadata blocks, and then audio frames. Everything is big-endian except the lengths inside a Vorbis comment, which are little-endian as Vorbis comments always are. This page follows RFC 9639.
The marker
The stream starts with the four ASCII bytes fLaC
(66 4C 61 43). At least one metadata block follows, and the first must be
STREAMINFO.
Metadata block header
Each metadata block starts with a 4-byte header:
| Bits | Field | Meaning |
|---|---|---|
| 1 | Last block flag | 1 on the last metadata block; the audio frames follow it |
| 7 | Block type | See below |
| 24 | Block length | The bytes that follow this header, without the header itself, big-endian |
Block types
| Value | Block | Holds |
|---|---|---|
| 0 | STREAMINFO | Sample rate, channels, depth, length and the audio’s MD5. Always first, exactly one |
| 1 | PADDING | Spare room for later metadata edits. Any number of blocks |
| 2 | APPLICATION | Data for one application, by registered ID |
| 3 | SEEKTABLE | Places to jump to. At most one |
| 4 | VORBIS_COMMENT | Tags as name=value text. At most one |
| 5 | CUESHEET | Tracks and index points, as on a CD |
| 6 | PICTURE | A picture, such as a cover |
| 7 to 126 | Reserved | Not defined. A decoder that does not know a type skips it, using its length |
| 127 | Forbidden | Would make the header look like the start of a frame sync code |
The frames
After the block marked as last, the audio starts: a run of frames, in time order, each holding one block of samples. The stream has no index of them and no closing mark: frames run to the end of the file, and the seek table is optional.
Not part of the format
Some taggers put an ID3v2 tag in front of the marker. It is not part of FLAC, but its size is stated in its own header, so a reader can skip it, and many do. Likewise an ID3v1 or APEv2 tag sometimes follows the frames. A decoder ignores anything that is not a valid frame.
FLAC audio can also be carried in other containers, in which case this layout does
not apply: the Ogg mapping starts each stream with the packet 7F 46 4C 41 43
and puts each block and each frame in a packet of its own; Matroska uses the codec ID
A_FLAC and keeps the marker and blocks in its CodecPrivate data; MP4 has a
separate mapping document.