Format:FLAC
| Developer | Xiph.Org Foundation |
|---|---|
| Magic | 66 4C 61 43 ("fLaC") |
| Extensions | .flac, .fla |
| Endianness | big |
| Website | https://xiph.org/flac/ |
| On this wiki | Facts · Code · Notes · Topics |
Xiph.Org's lossless audio format (.flac): the marker 'fLaC', metadata blocks (STREAMINFO first, 34 bytes, with rate, channels, bits per sample, total samples and an MD5 of the PCM), then frames that start with the 14-bit sync 0x3FFE; also mapped into Ogg.
Overview
A native FLAC stream is the 4-byte marker fLaC (0x664C6143), one or more metadata blocks and then audio frames. The first metadata block must be STREAMINFO. Everything is big endian and bit packed. ID3v2 tags are sometimes prepended; decoders skip them (see Format:MPEG audio#ID3v2).
Metadata block header
4 bytes: 1 bit last-block flag, 7 bits block type, 24 bits length of the block body. Types (libFLAC include/FLAC/format.h): 0 STREAMINFO, 1 PADDING, 2 APPLICATION (4-byte id first), 3 SEEKTABLE (18-byte points: sample number u64, stream offset u64, frame samples u16), 4 VORBIS_COMMENT (little-endian lengths, same layout as Format:Vorbis comments), 5 CUESHEET, 6 PICTURE, 7 and above undefined, 127 invalid.
STREAMINFO (34 bytes)
| Bits | Field |
|---|---|
| 16 | minimum block size (samples) |
| 16 | maximum block size |
| 24 | minimum frame size (bytes, 0 unknown) |
| 24 | maximum frame size |
| 20 | sample rate (Hz) |
| 3 | channels minus 1 |
| 5 | bits per sample minus 1 |
| 36 | total samples per channel (0 unknown) |
| 128 | MD5 of the unencoded PCM |
The field widths are the FLAC__STREAM_METADATA_STREAMINFO_*_LEN constants of libFLAC.
Frame header
Each frame starts with a 14-bit sync code 0x3FFE (FLAC__FRAME_HEADER_SYNC), so a frame begins with the bytes FF F8 (fixed block size) or FF F9 (variable block size), then block size code, sample rate code, channel assignment, sample size, a UTF-8 style coded frame or sample number, optional explicit block size and rate, and a CRC-8; each frame ends with a CRC-16. Unverified: the layout after the sync was written from the format specification from memory.
In Ogg
Ogg FLAC puts a first packet 7F 46 4C 41 43 (0x7F "FLAC"), mapping version 1.0, a 16-bit big-endian header-packet count, fLaC and the STREAMINFO block; see Format:Ogg#Codec identification.
Reversing notes
- Game archives that store FLAC whole are found by scanning for
fLaCfollowed by a block header byte 0x00 or 0x80 and length 00 00 22. - Total samples / sample rate gives the duration without decoding; if total samples is 0 (streamed encode), seek to the last frame.
Code & repositories
See the repository linked on this page (libFLAC sources, include/FLAC/format.h, doc/).
- https://github.com/xiph/flac @
e94ff9f68b8e7dbd3e9f8b1ac18a8eca1914f181· license: GFDL-1.3
libFLAC reference encoder/decoder and flac tools (include/FLAC/format.h holds the stream marker, metadata types and field widths; doc/ has foreign metadata notes).
Tested on: source read, not run: Read include/FLAC/format.h at this commit. Not built. · checked 2026-10-18; last activity 2026-07-19