The Free Lossless Audio Codec (FLAC) is an open format for compressing digital audio so that decoding reproduces the original audio samples exactly. It is also the name of the associated software project, including a reference encoder, decoder, and programming libraries. Unlike lossy audio formats, FLAC does not discard information judged less audible: its reduction in file size comes from finding reversible representations of redundancy within the signal. It is therefore an application of lossless data compression specialized for audio.
FLAC is widely used for music distribution, personal collections, and preservation of recorded sound. Its importance rests on a combination of exact sample reconstruction, relatively inexpensive decoding, public specifications, royalty-free implementation, and support for descriptive information and cover artwork. The format separates choices made by an encoder—such as how extensively it searches for a good predictor—from the decoding rules required to reconstruct the sound. Consequently, different encoders and compression settings can produce different-sized files that decode to identical audio.
Origins, governance, and standardization
FLAC originated as a project led by Josh Coalson, with public development beginning in 2000 and version 1.0 released in July 2001. Its central aim was to provide an openly implementable lossless audio format suitable for ordinary playback as well as storage. At a time when several competing lossless formats were tied to particular vendors or operating environments, FLAC offered a published bitstream design and an implementation distributed as open-source software.
In 2003, FLAC became a project of the Xiph.Org Foundation, an organization associated with open multimedia technologies. This affiliation connected it with a broader ecosystem that included the Ogg container and the Vorbis audio format, while FLAC retained its own native file structure. A file ending in .flac normally uses that native structure; it is not necessarily an Ogg file. The existence of these separate arrangements is important because an audio coding format and a container format solve different problems.
The reference implementation developed around several components. The flac program encodes, decodes, and tests streams, while metaflac inspects and edits metadata. The libFLAC library exposes functionality to applications, and libFLAC++ provides a C++ interface. These components helped software developers add FLAC support without independently implementing every detail of the bitstream. They also established a common practical baseline against which other implementations could be tested.
FLAC's licensing distinguishes the core codec libraries from some accompanying programs. The reference libraries use a permissive BSD-style license, while the command-line tools are distributed under the GNU General Public License. The format is intended to be implemented without codec royalties. The licensing of a particular software component nevertheless remains separate from the specification of the file format: an independently written decoder does not become the reference software merely by reading the same files.
In 2024, the Internet Engineering Task Force published the FLAC specification as RFC 9639, providing a formal account of the bitstream and decoding requirements. Standardization documented a format already supported by a large installed base rather than introducing an unrelated replacement. FLAC's evolution has generally emphasized compatibility, broader implementation coverage, and improvements in encoding and decoding software. A newer encoder can find a more compact representation without requiring a new audio format, provided that its output remains within the established decoding rules.
Audio representation and the meaning of losslessness
FLAC represents audio as integer pulse-code modulation, commonly abbreviated PCM. Each channel consists of a sequence of signed amplitude values taken at a fixed sample rate. Three basic parameters describe the uncompressed audio: the sample rate, the number of channels, and the number of bits per sample. For conventional stereo CD audio, these values are 44,100 samples per second, two channels, and 16 bits per sample.
The nominal uncompressed data rate is
where is sample rate, is channel count, and is bit depth. Thus, CD-format stereo audio contains 1,411,200 bits per second of sample data, or 176,400 bytes per second. Five minutes contains 52,920,000 bytes before file headers or other overhead. FLAC reduces this sample-data representation by exploiting signal structure rather than by reducing the sample rate or bit depth.
The format can represent one to eight channels, integer sample resolutions from 4 to 32 bits, and sample rates up to 1,048,575 Hz. These are format capabilities, not a promise that every player accepts every legal combination. Particular hardware, software interfaces, or restricted decoding profiles may impose narrower limits. Multichannel interpretation also depends on agreed channel ordering; retaining eight streams of integers is not sufficient if their speaker assignments are misunderstood.
Losslessness refers specifically to the encoded audio samples. A correctly decoded FLAC stream reproduces those samples exactly, including the least significant bits. It does not establish that the source recording faithfully captured an acoustic event, that a disc was read without error, or that playback equipment will preserve the samples unchanged. Resampling, volume adjustment, equalization, and conversion to a different bit depth can all modify the signal outside the FLAC coding process.
This distinction also separates audio equivalence from file equivalence. A WAVE or AIFF source can contain application-specific chunks, text, padding, or other non-audio material. Encoding its audio as FLAC does not inherently preserve every byte of the source container. Some tools can retain additional container information, but that is a separate preservation feature. Two FLAC files can likewise contain identical audio while differing in tags, artwork, padding, or compression choices.
FLAC does not natively encode arbitrary floating-point samples or Direct Stream Digital bitstreams as those original numerical representations. Converting such material into integer PCM is a separate operation whose reversibility depends on the source and conversion method. The lossless guarantee begins with the actual integer samples supplied to the encoder, not with every earlier representation in a recording workflow.
Prediction and reversible channel transformations
The main compression process begins by dividing the audio into blocks and selecting a compact model for each channel within a block. Much audio is locally predictable: neighboring samples often resemble one another, and repeated patterns or smooth waveforms produce strong short-term relationships. Instead of storing every sample directly, an encoder can store a prediction rule together with the difference between each prediction and the actual sample.
If is a sample and its prediction, the residual is
Decoding recovers the sample through . The predictor need not be acoustically perfect or numerically approximate in a perceptual sense. Exact reconstruction follows because the complete residual is retained. A better predictor merely makes the residual values smaller or statistically easier to encode.
FLAC supports several subframe types. A constant subframe represents a block in which every sample has the same value. A verbatim subframe stores samples directly when prediction offers insufficient benefit. Fixed-predictor subframes use predetermined predictors of orders zero through four. For example, a first-order predictor uses the previous sample, while a second-order predictor extrapolates from the previous two:
These predictors are closely related to finite differences. They are especially effective on signals with locally simple variation and require little side information.
For more complex signals, linear predictive coding allows the encoder to describe a predictor using a set of coefficients. FLAC supports predictor orders up to 32. The encoder estimates useful coefficients, quantizes them to integers, and stores them with a shift parameter. The decoder then performs the specified integer computation. Initial samples, often called warm-up samples, are stored explicitly so that prediction can begin without depending on an earlier frame.
The search for coefficients may use floating-point calculations inside an encoder, but the stored representation and decoding procedure determine the exact reconstructed values. Different estimation methods can therefore produce different valid files. Selecting the predictor with the smallest prediction error is not always identical to selecting the smallest encoded subframe, because coefficients, warm-up samples, and residual-coding parameters also occupy space.
Stereo audio offers another source of redundancy: left and right channels often contain similar material. FLAC can encode them independently or use reversible left–side, right–side, or mid–side representations. A side channel expresses the difference between left and right. In mid–side coding, the specification's integer rounding and reconstruction rules preserve information that a naive averaged signal could lose. These transformations can greatly reduce redundant stereo content, but the encoder can choose independent channels when transformation provides no advantage.
Residual coding and the limits of compression
After prediction, FLAC usually has a sequence of signed residual values clustered around zero. These values are encoded using Golomb–Rice coding, a form of entropy coding particularly convenient for integers whose probabilities decrease with magnitude. Unlike Huffman coding, this method does not require a separately transmitted table assigning a codeword to every residual value.
A reversible signed-to-unsigned mapping places small positive and negative residuals near zero:
For a Rice parameter , the unsigned value is split into a quotient and a remainder:
The quotient is represented in unary form and the remainder in bits. Small residuals can therefore receive short codes while larger values remain representable without loss.
Choosing matters. If it is too small, large values require long unary quotients. If it is too large, many bits are spent on remainders even for small values. FLAC allows the residual sequence to be partitioned, with a separate coding parameter for each partition. This adapts the representation to changes in signal behavior within a block—for example, a quiet passage followed by a transient.
The bitstream provides residual-coding methods with different Rice-parameter ranges, together with escape representations for partitions better stored at a fixed residual width. These choices make coding more flexible without changing the predictor. The encoder can compare the space needed by several alternatives, including the parameter overhead, rather than assuming that one method works best everywhere.
FLAC can also exploit least significant bits that are zero throughout a subframe. These “wasted bits” are removed before coding and restored during decoding. A 24-bit recording containing sample values that are all exact multiples of 256, for example, has eight zero least significant bits per sample. Representing those repeated zeros explicitly would waste space even though the nominal source format still has 24-bit samples.
Compression ultimately depends on information content. Silence, repeated tones, and highly correlated channels can compress extremely well. Noise-like samples, especially when independent across channels and rich in low-order-bit variation, may offer little redundancy. A verbatim representation limits the disadvantage of an unsuitable predictor, but framing and metadata still impose overhead. No lossless algorithm can make every possible input smaller: a one-to-one reversible mapping cannot assign shorter distinct outputs to all equally sized inputs. FLAC's practical success comes from matching its coding tools to the statistical properties of common audio, not from circumventing that limit.
Native stream structure, framing, and seeking
A native FLAC stream begins with the four-byte marker fLaC, followed by metadata blocks and then audio frames. This ordering gives a decoder access to essential stream properties before it processes sound. The metadata sequence has an explicit indication of its final block, after which frame parsing begins. A normal audio frame contains a header, one subframe for each coded channel, alignment padding where required, and a frame checksum.
The frame header identifies such properties as block size, sample rate, channel assignment, and sample resolution, sometimes by referring back to values in the stream metadata. It also contains a frame number or a sample number, depending on the blocking strategy. FLAC distinguishes fixed-block-size streams from variable-block-size streams; the final block can be shorter than the preceding blocks. Individual blocks can contain up to 65,535 samples per channel.
A larger block can spread predictor and framing overhead across more samples, but it may fit a changing signal less well. A smaller block can adapt more quickly to transients or changes in channel relationships, at the cost of more frequent headers and predictor descriptions. Block selection is therefore an encoding trade-off rather than a direct audio-quality control. It also affects buffering and the granularity with which applications can access portions of the recording.
Frames are independently decodable once the necessary stream parameters are known. Predictor state does not continue indefinitely across frame boundaries: each predictive subframe supplies its own warm-up samples. This structure supports seeking and limits the propagation of ordinary data damage. If a frame is corrupted, a decoder may be able to identify a later frame and resume decoding there, although lost samples cannot thereby be recovered.
FLAC uses cyclic redundancy checks at two levels: an 8-bit check on the frame header and a 16-bit check covering the frame. A synchronization pattern helps locate candidate frame boundaries, while structural checks and checksums help distinguish genuine frames from accidental byte patterns. These measures detect many forms of corruption; they are not an error-correcting code capable of reconstructing missing information.
An optional seek table stores points relating sample positions to byte offsets and frame sample counts. It speeds random access by allowing a player to jump near a requested time and decode forward. Files without such tables remain valid, and players can use other searching strategies. FLAC's independent frames and modest decoding requirements are useful for playback over a network, but the codec alone does not provide adaptive bitrate selection, packet retransmission, or the timing behavior of a complete streaming system.
Metadata, artwork, and integrity information
FLAC's metadata system separates information about the recording from the compressed sample data. Each metadata block has a type and length, allowing software to skip block types it does not need to interpret. The mandatory STREAMINFO block comes first and records essential properties, including sample rate, channel count, sample resolution, block-size information, total sample count when known, and an audio checksum. Other metadata blocks are optional.
Descriptive tags are normally stored in a Vorbis-comment block. These are length-prefixed UTF-8 strings, commonly written as FIELD=value, with conventional field names such as TITLE, ARTIST, and ALBUM. Their flexibility supports multiple values and specialized cataloging practices, but it also permits inconsistent spelling, naming, and interpretation between applications. The presence of a field does not guarantee that all players display it or assign it the same meaning.
A picture block stores an image together with information such as its media type, description, dimensions, and picture role. Cover art can therefore travel with the audio rather than depending on a separate directory file. Because a picture is independent of the sample coding, replacing artwork changes the FLAC file without changing the decoded sound. Large embedded images can also account for a substantial part of the size of short recordings.
Other block types serve more specialized purposes. A cue sheet can describe track and index positions, including conventions useful for CD-related workflows. An application block provides a place for application-specific data identified by an application identifier. Padding reserves unused metadata space, allowing some later tag edits to be made without relocating all the audio frames. The seek table is also metadata, although its purpose concerns access rather than description.
The checksum in STREAMINFO uses MD5 over a specified representation of the uncompressed samples. A decoder or testing utility can recompute it after decoding and compare the result. An all-zero value indicates that the checksum was not supplied. This mechanism is useful for detecting accidental changes to the decoded audio and is distinct from frame-level checks, which operate on the encoded stream.
An audio checksum is not a complete preservation or security record. It does not cover tags and artwork, and MD5 is unsuitable as a modern adversarial authenticity mechanism because of known collision weaknesses. A whole-file hash computed with a suitable modern algorithm serves a different purpose: detecting changes to the entire stored object. A digital signature can additionally associate data with a signing key. Neither facility is automatically supplied by the FLAC audio checksum, and metadata assertions such as an artist name remain ordinary stored text rather than verified provenance.
Compression settings, computational cost, and implementations
FLAC deliberately permits a relatively complex encoder to produce a stream that a much simpler decoder can reconstruct. Encoding can involve testing channel assignments, block models, predictor orders, coefficient precisions, and residual partitions. Decoding follows the selected representation rather than repeating the search. This asymmetry is valuable when a recording is encoded once but played many times, particularly on portable devices.
The reference command-line encoder exposes numbered compression presets, conventionally from 0 through 8. Higher settings generally spend more effort looking for a smaller file, but the exact search configuration is an implementation detail that can change between software versions. These numbers are not standardized bitstream quality levels. All settings are lossless when the same input samples are encoded correctly, and a higher setting does not restore information absent from the source.
It is also not mathematically guaranteed that a higher preset produces the smallest result on every individual input. Presets select different combinations of practical search strategies, not an exhaustive global optimization over every valid FLAC stream. Specialized encoders may use still broader searches or other heuristics. Their output can remain compatible with ordinary decoders as long as it obeys the applicable format constraints.
Typical music often compresses to roughly one-half to two-thirds of its uncompressed PCM size, but the range is wide and should not be treated as a specification. The outcome depends on musical content, mastering, channel correlation, sample rate, bit depth, and encoder behavior. A comparison is also ambiguous unless “compression ratio” is defined: an output-to-input ratio of 0.6 means a 40 percent reduction, whereas some descriptions report the inverse ratio or quote only the percentage saved.
Audio properties can matter more than the preset. Quiet and spectrally simple material often predicts well. Dense, noise-like content may not. Higher sample rates can increase correlation between adjacent samples, while higher sample precision can add low-order variation that is difficult to compress. These factors interact, so neither nominal resolution nor musical genre alone reliably determines final file size.
The reference libraries are written primarily in the C programming language and provide an application programming interface for integration into players, editors, and conversion tools. Independent implementations also exist. Performance can vary with processor-specific optimizations, input handling, memory allocation, and output conversion. The format's “streamable subset” constrains selected coding parameters to simplify bounded-resource implementations, especially hardware devices. A stream outside that subset can still be valid FLAC, but support for it may be less universal among restricted decoders.
Relationship to containers and other audio formats
FLAC is an audio coding format with a native stream structure, but it can also be carried inside other containers. An Ogg mapping wraps FLAC data in Ogg pages, while Matroska can combine FLAC audio with video, subtitles, and other tracks. These arrangements preserve FLAC's lossless audio coding while changing how the stream is packaged, indexed, and associated with other media.
The distinction explains why file extensions alone do not describe the entire technical situation. A native .flac file normally contains metadata followed by FLAC frames. A Matroska file containing FLAC must first be processed by a Matroska demultiplexer. An application's ability to decode native FLAC does not automatically establish support for every container that can carry it, and container support does not automatically establish support for all embedded audio codecs.
WAVE and AIFF commonly store uncompressed PCM, although those container families can also carry other encodings. Comparing FLAC with “WAV” therefore often means comparing compressed FLAC audio with uncompressed PCM in a WAVE container. When both represent the same sample sequence, they can produce identical digital audio after decoding. The differences concern file size, metadata conventions, software compatibility, and container-specific information rather than an inherent improvement in sound.
Lossy formats such as MP3 and Advanced Audio Coding serve a different purpose. They reduce data rates partly by discarding information under perceptual coding models. This can achieve much smaller files than lossless compression at useful listening quality, but decoding does not reproduce the original samples. Converting an MP3 recording to FLAC preserves the samples produced by the MP3 decoder; it does not reconstruct the information discarded during the original MP3 encoding.
Other lossless codecs include the Apple Lossless Audio Codec, commonly stored in MPEG-4 containers, and WavPack, which supports additional representation modes and workflows. Differences among these formats include licensing history, supported sample representations, metadata practice, compression performance, and hardware adoption. No single file-size ranking applies uniformly to all recordings and encoder configurations.
General-purpose compressors can also compress raw PCM or uncompressed audio files. They may discover repeated byte patterns, but they usually lack FLAC's combination of audio prediction, channel decorrelation, independent frames, and audio-oriented seeking. Conversely, FLAC is not a general-purpose replacement for archive compressors: it expects supported audio samples rather than arbitrary documents or executable programs. Its specialized design exchanges broad input flexibility for convenient, predictable handling of a particular kind of data.
Distribution, preservation, and operational limitations
FLAC is used for downloadable music because it provides a compact representation from which the original delivered PCM can be recovered. A distributor can supply one lossless source suitable for playback or later conversion into device-specific formats. Listeners can edit tags, replace artwork, and reorganize collections without re-encoding the audio, although the behavior of particular tagging applications depends on their implementation.
For preservation institutions, exact sample reconstruction and public documentation are important advantages. FLAC can reduce storage and transfer demands while avoiding the repeated information loss associated with successive lossy conversions. Its checksums and independent frames also assist validation and diagnosis. These properties explain its use in collections where retaining the audio signal matters more than retaining the original container byte for byte.
Nevertheless, a preservation master may require more than an audio stream. Broadcast WAVE files, for example, can carry production metadata, timing references, and institutional records in established chunks. Moving their samples into FLAC does not automatically reproduce every such structure or preserve its operational meaning. Preservation workflows therefore distinguish the intellectual content of the recording, its sample representation, its descriptive metadata, and the original digital object.
FLAC itself cannot establish that acquisition was accurate. In optical-disc extraction, read errors, incorrect offsets, or problems at track boundaries can be faithfully encoded as part of the supplied PCM. A valid FLAC checksum would then confirm consistency with that encoded audio, not with the disc's intended data. Similarly, a lossless file created from an already lossy source remains lossless only relative to its immediate decoded input.
High sample rates and large bit depths are also independent of the lossless property. A 16-bit, 44.1 kHz FLAC file can be perfectly lossless, while a nominally higher-resolution file may originate from upsampling or another conversion. FLAC does not certify recording resolution, mastering provenance, or perceptual superiority. Those claims require information beyond the compressed bitstream.
Long-term storage also involves concerns outside the codec: redundant copies, backup procedures, whole-file integrity records, metadata consistency, and migration between storage systems. Decoder security is another separate issue. A malformed file can target flaws in software parsing lengths, allocating buffers, or processing embedded pictures, even though the mathematical coding scheme is lossless. Implementations must treat externally supplied files as untrusted input. In practical collections, the durability of a FLAC recording depends both on the openness of its format and on the systems that preserve, identify, validate, and interpret it.