FLAC audio: high level bitstream overview

FLAC audio, which stands for Free Lossless Audio Codec, is a audio compression format that provides a lossless compression for digital audio. Josh Coalson designed FLAC to provide high-quality audio compression while preserving the original audio data without compromising sound quality. He developed it in 2000 and released the first stable version of FLAC in 2001. Over the time, FLAC gained popularity and started to gain recognition as a reliable and efficient audio compression format. One of the significant advantages of FLAC is that it achieves high compression ratios without losing any details of original audio. Lossless compression achieved by processing the audio in the way that enables perfect reconstruction of the original audio during decoding and playback. This makes FLAC a good choice for archiving, professional audio production, and high-quality audio playback.

This article provides a high level overview of FLAC audio bitstream syntax. We will use Virinext Bitstream Analyzer for analyzing FLAC files. You can download the evaluation version on the Download page. For license acquiring please check the Buy license page.

High level bitstream overview

Virinext Bitstream Analyzer with opened FLAC audio file

At the high level FLAC audio is the sequence of few metadata blocks followed by audio frames. Metadata blocks designed to provide information about the audio. The type of metadata to transmit may vary depending on the application or specific requirements, but it should include at least metadata describing stream parameters: sample rate, bit depth (representing the number of bits used in each sample of PCM audio data), number of channels, channel configuration (describing channel mapping for multi-channel audio), and the total number of samples in the audio file.

Screenshot below is a table from specification with metadata blocks types.

Table from FLAC specification with types of metadata blocks

The Streaminfo metadata block provides essential stream parameters, such as sample rate, number of channels, and bits per sample, among others.

Screenshot of STREAMINFO block in Virinext Bitstream Analyzer

The Padding metadata block allows for the insertion of arbitrary padding. It can be useful to accommodate future updates to specific metadata. Encoders could to incorporate some amount of padding, which will later be overwritten by specific metadata. The Application metadata block is intended for use by third-party applications. This block can store additional data paired with 4-byte identifiers (like FourCC). This enables the storage of any kind of application-level metadata.
The Seektable metadata block, while optional, serves to store seek points. It facilitates quick seeking and random access to specific sections of the audio without requiring the entire file to be decoded.
The Vorbis comment metadata block contains human-readable information in UTF-8 format. It consists of a vendor string followed by a number of fields, allowing for the inclusion of descriptive information about the audio.
The Picture metadata block within a FLAC file stores image data associated with the audio content. This image data is somehow connected to the audio contained in the FLAC file.

Immediately after the final metadata block, one or more frames are present. Each frame encompasses a frame header, one or more sub-frames, padding zero bits for achieving byte-alignment, and a frame footer. The number of sub-frames in each frame corresponds to the number of audio channels.

Screenshot of FRAME_HEADER bitstream element in Virinext Bitstream Analyzer

The frame starts with a 15-bit frame sync code of 0b111111111111100. Following the sync code is the blocking strategy bit, which remains unchanged throughout the audio stream. The sample_rate field indicates the sample rate of the audio within the current frame. The channel_assignment, also known as the channels bits code, determines both the number of audio channels and the channel configuration, defining the channel mapping for multi-channel audio. The subsequent field, sample_size, specifies the bit depth of the audio. Lastly, the coded_frame_number field denotes the frame number.
Following the frame header, sub-frames are present, which contain encoded audio data.

PCM data analyzer widget of Virinext Bitstream Analyzer.

Conclusion

FLAC has gained popularity over the years and is now recognized as a reliable and efficient lossless audio compression format. It has particularly captured the attention of music enthusiasts and professionals in the recording and music production industry. When it comes to analyzing FLAC audio files, the Virinext Bitstream Analyzer can be a valuable tool for you. This is tool offers analysis for various encoding standards, including FLAC audio. Whether you need in-depth analysis or a high-level overview, the Virinext Bitstream Analyzer has instruments to meet your requirements.