Recent from talks
Contribute something
Nothing was collected or created yet.
| Free Lossless Audio Codec | |
|---|---|
| Developers | Xiph.Org Foundation, Josh Coalson, Erik de Castro Lopo |
| Initial release | 20 July 2001 |
| Stable release | 1.5.0[1]
/ 11 February 2025 |
| Repository | |
| Written in | C, C++ |
| Operating system | Cross-platform |
| Type | Codec |
| License | Command-line tools: GNU GPL Libraries: BSD |
| Website | xiph |
| Free Lossless Audio Codec | |
|---|---|
| Filename extension |
.flac |
| Internet media type |
audio/flac |
| Uniform Type Identifier (UTI) | org.xiph.flac |
| Magic number | fLaC[2] |
| Type of format | Lossless audio |
| Standard | RFC 9639 |
| Open format? | Yes[3] |
| Free format? | Yes |
FLAC (/flæk/; Free Lossless Audio Codec) is an audio coding format for lossless compression of digital audio, developed by the Xiph.Org Foundation, and is also the name of the free software project producing the FLAC tools, the reference software package that includes a codec implementation. Digital audio compressed by FLAC's algorithm can typically be reduced to between 50 and 70 percent of its original size[4] and decompresses to an identical copy of the original audio data.
FLAC is an open format with royalty-free licensing and a reference implementation which is free software. FLAC supports metadata tagging, album cover art, and fast seeking.
History
[edit]Development was started in 2000 by Josh Coalson. The bitstream format was frozen with the release of version 0.9 of the reference implementation on 31 March 2001. Version 1.0 was released on 20 July 2001.[5]
On 29 January 2003, the Xiph.Org Foundation and the FLAC project announced the incorporation of FLAC under the Xiph.org banner. Xiph.org is home to other free compression formats such as Vorbis, Theora, Speex and Opus.[5][6][7]
Version 1.3.0 was released on 26 May 2013, at which point development was moved to the Xiph.org git repository.[8]
In 2019, FLAC was proposed as an IETF standard.[9]
In December 2024, FLAC was formally specified in and published as RFC 9639.[10]
Design
[edit]FLAC is a lossless encoding of linear pulse-code modulation data.[11]
File structure
[edit]A FLAC file consists of the magic number fLaC, metadata, and encoded audio.[11]
The encoded audio is divided into frames, each of which consists of a header, a data block, and a CRC16 checksum. Each frame is encoded independent of each other. A frame header begins with a sync word, used to identify the beginning of a valid frame. The rest of the header contains the number of samples, position of the frame, channel assignment, and optionally the sample rate and bit depth. The data block contains the audio information.[11]
Metadata in FLAC precedes the audio. Properties like the sample rate and the number of channels are always contained in the metadata. It may also contain other information, the album cover for example.[11] FLAC uses Vorbis comments for textual metadata like track title and artist name.
Encoding and decoding
[edit]
flac command-line softwareThe FLAC encoding algorithm consists of multiple stages. In the first stage, the input audio is split into blocks. If the audio contains multiple channels, each channel is encoded separately as a subblock. The encoder then tries to find a good mathematical approximation of the block, either by fitting a simple polynomial, or through general linear predictive coding. A description of the approximation, which is only a few bytes in length, is then written. Finally, the difference between the approximation and the input, called residual, is encoded using Rice coding. In many cases, a description of the approximation and the encoded residual takes up less space than using pulse-code modulation.[11]
The decoding process is the reverse of encoding. The compressed residual is first decoded.[12][13] The description of the mathematical approximation is then used to calculate a waveform. The result is formed by adding the residual and the calculated waveform.[14][15] As FLAC compresses losslessly, the decoded waveform is identical to the waveform before encoding.
For two-channel stereo, the encoder may choose to joint-encode the audio. The channels are transformed into a side channel, which is the difference between the two input channels, and a mid channel, the sum of the two input channels. In place of a mid channel, the left channel or the right channel may be encoded instead, which is sometimes more space-efficient.[16]
Even though the reference encoder uses a single block size for the whole stream,[11] FLAC allows the block size in samples to vary per block.
Compression
[edit]The amount of compression is determined by various parameters, including the order of the linear prediction model and the block size. Regardless of the amount of compression, the original data can always be reconstructed perfectly.
For the user's convenience, the reference implementation defines 9 compression levels, which are presets of the more technical parameters to the encoding algorithm. The levels are labeled from 0 to 8, with higher numbers resulting in a higher compression ratio, at the cost of compression speed. The meaning of each compression level varies by implementation.[17][18]
FLAC is optimized for decoding speed at the expense of encoding speed. A benchmark has shown that, while there is little variation in decoding speed as compression level increases, beyond the default compression level 5, the encoding process takes up considerably more time with little space saved compared to level 5.[19]
Implementation
[edit]Alongside the format, the FLAC project also contains a free and open-source reference implementation of FLAC called libFLAC. libFLAC contains facilities to encode and decode FLAC data and to manipulate the metadata of FLAC files. libFLAC++, an object-oriented wrapper around libFLAC for C++, and the command-line programs flac and metaflac, are also part of the reference implementation.
The FLAC format, along with libFLAC, are not known to be covered by any patents, and anyone is free to write their own implementations of FLAC.
Comparison to other formats
[edit]FLAC is specifically designed for efficient packing of audio data, unlike general-purpose lossless algorithms such as DEFLATE, which are used in ZIP and gzip. While ZIP may reduce the size of a CD-quality audio file by 10–20%, FLAC is able to reduce the size of audio data by 40–50% by taking advantage of the characteristics of audio.[citation needed]
The technical strengths of FLAC compared to other lossless formats lie in its ability to be streamed and decoded quickly, independent of compression level.[citation needed]
Since FLAC is a lossless scheme, it is suitable as an archive format for owners of CDs and other media who wish to preserve their audio collections. If the original media are lost, damaged, or worn out, a FLAC copy of the audio tracks ensures that an exact duplicate of the original data can be recovered at any time. An exact restoration from a lossy copy (e.g., MP3) of the same data is impossible. FLAC's being lossless means it is highly suitable for transcoding e.g. to MP3, without the normally associated transcoding quality loss between one lossy format and another. A CUE file can optionally be created when ripping a CD. If a CD is read and ripped perfectly to FLAC files, the CUE file allows later burning of an audio CD that is identical in audio data to the original CD, including track order and pregap, but excluding additional data such as lyrics and CD+G graphics.[20] But depending on the burning program used, CD-Text may be recovered from the metadata stored in the CUE sheet and burned back to a new copy on blank CD-R media.
Adoption and implementations
[edit]Reference implementation
[edit]The reference implementation of FLAC is implemented as the libFLAC core encoder & decoder library, with the main distributable program flac being the reference implementation of the libFLAC API. This codec API is also available in C++ as libFLAC++. The reference implementation of FLAC compiles on many platforms, including most Unix (such as Solaris, BSD) and Unix-like (including Linux), Windows, BeOS, and OS/2 operating systems. There are build-systems for autoconf/automake, MSVC, Watcom C, and Xcode. There is currently no multicore support in libFLAC, but utilities such as GNU parallel and various graphical frontends can be used to spin up multiple instances of the encoder.
Hardware and software
[edit]FLAC playback support in portable audio devices and dedicated audio systems is limited compared to formats such as MP3[21] or uncompressed PCM. FLAC support is included by default in Windows 10,[22] Android,[23] macOS and iOS.[24]
| Microsoft Windows | macOS | Android | iOS | |
|---|---|---|---|---|
| Codec support | Yes | Yes | Yes | Yes |
| Container support | FLAC (.flac) Matroska (.mka, .mkv) Ogg (.oga)[25] |
FLAC (.flac) Core Audio Format (.caf) |
FLAC (.flac) | FLAC (.flac) Core Audio Format (.caf) |
| Notes | Support introduced in Windows 10. Windows Media Player (2022) also supports FLAC in an Ogg container for live streams (e.g. Icecast internet radio).[26] |
Support introduced in macOS 10.13 High Sierra. | Support introduced in Android 3.1. Android natively supports regular FLAC (.flac), but not Ogg FLAC (.oga).[27] However, support for both regular FLAC and Ogg FLAC were later added to the Files (Google) file manager. |
Support introduced in iOS 11 (but depends on hardware). |
Various other containers are supported, independently from used operating system, depending on used playback software.
Use in archives
[edit]The standardization process of the FLAC format into RFC 9639 was driven by the specific use case of archival and preservation in mind.[28] The National Archives and Records Administration of the United States has FLAC listed as a preferred format for digital audio.[29]
See also
[edit]References
[edit]- ^ "FLAC 1.5 Finally Delivers Multi-Threaded Encoding". 11 February 2025. Retrieved 11 February 2025.
- ^ Coalson, Josh. "FLAC – format". Xiph.Org Foundation. Retrieved 4 April 2013.
"fLaC", the FLAC stream marker in ASCII, meaning byte 0 of the stream is 0x66, followed by 0x4C 0x61 0x43
- ^ "PlayOgg!". Free Software Foundation. 17 March 2010. Retrieved 1 October 2013.
- ^ "Looking at Flac Compression Ratios". Steven Pigeon. 7 February 2012. Retrieved 10 May 2018.
- ^ a b "Features". Xiph.Org Foundation. Retrieved 23 November 2023.
- ^ "FLAC Joins Xiph.org". Xiph.org Foundation. 29 January 2003. Retrieved 31 August 2009.
- ^ Plant, Emmett. "FLAC Joins Xiph!". Xiph.org Foundation. Archived from the original on 29 May 2008. Retrieved 31 August 2009.
- ^ "FLAC – changelog". Xiph.org Foundation. Retrieved 15 October 2013.
- ^ van Beurden, Martijn; Weaver, Andrew. Free Lossless Audio Codec. I-D draft-ietf-cellar-flac. Retrieved 14 May 2023.
- ^ Coalson, Josh. "FLAC - FLAC is now formally specified in RFC 9639". xiph.org. Retrieved 12 February 2025.
- ^ a b c d e f Coalson, Josh. "About the FLAC Format". Retrieved 13 February 2022.
- ^ "stream_decoder.c". libFLAC. Retrieved 19 February 2022.
- ^ libFLAC/stream_decoder.c, line 2734.
- ^ "lpc.c". libFLAC. Retrieved 19 February 2022.
- ^ libFLAC/lpc.c, lines 813–820.
- ^ "FLAC Format Specification". FLAC. Retrieved 19 February 2022.
- ^ "CUETools FLAC encoders comparison". CUETools Wiki. Retrieved 27 May 2013.
- ^ "Encoding Settings". JRiver Media Centre. Retrieved 27 May 2013.
- ^ "Lossless Codec Comparison". Synthetic-soul.co.uk. Archived from the original on 2 February 2009. Retrieved 26 November 2016.
- ^ "FAQ". FLAC. Retrieved 23 September 2014.
- ^ "Links". FLAC. Retrieved 24 March 2009.
- ^ "Audio snobs rejoice: Windows 10 will have system-wide FLAC support". PC World. Retrieved 10 July 2015.
- ^ "Android Supported Media Formats". Android.com. 27 September 2024. Retrieved 20 December 2024.
- ^ "iOS 11 brings lossless FLAC audio playback to iPhone and iPad". idownloadblog.com. 9 June 2017. Retrieved 26 September 2017.
- ^ "MIME Types and File Extensions - XiphWiki".
- ^ "FLAC vs Ogg FLAC".
- ^ "The Android Platform Doesn't Fully Support OGG Container Formats (OGA) [36906426] - Visible to Public - Issue Tracker".
- ^ "Codec Encoding for LossLess Archiving and Realtime transmission".
- ^ "Appendix A: Tables of File Formats | National Archives".
External links
[edit]- Official website
- Lossless audio formats comparison: measuring FLAC against five other lossless audio formats
- Lossless comparison: FLAC against seven other lossless audio formats on Hydrogenaudio
- GSMArena Phone Finder: all phones & tablets with FLAC support
History
Development Origins
FLAC was founded in 2000 by software engineer Josh Coalson as an open-source alternative to proprietary lossless audio compression formats such as Shorten and Monkey's Audio, which lacked transparent development and free licensing. Coalson initiated the project to create a freely available codec that could compress audio data without any loss of quality, addressing the limitations of closed-source tools that dominated the nascent field of lossless audio archiving and distribution. The development began with early experimentation on SourceForge, where Coalson released initial versions to gather feedback from the audio enthusiast community.[8][9] The initial goals of FLAC emphasized achieving compression ratios superior to general-purpose algorithms like ZIP—typically 40-60% reduction for audio files—while ensuring bit-perfect decoding to guarantee identical output to the input on every playback. Coalson prioritized an open licensing model under a BSD-like permissive license for the reference libraries, allowing broad adoption without restrictive terms, and designed the format to be patent-free to encourage widespread implementation. Early prototypes from 2000 to 2001 involved rigorous testing against benchmarks from existing formats, focusing on encoding efficiency and decoding speed to refine the core algorithm before the first public release in July 2001.[3][10][11] Specific technical motivations drove the design choices, including support for seekable streams to enable quick navigation in large audio files without full decompression, integrated error detection through MD5 checksums of the entire decoded audio for integrity verification, and compatibility with high-resolution audio up to 32-bit depth and sampling rates exceeding 192 kHz to future-proof the format for professional and archival use. In January 2003, the project transitioned under the sponsorship of the Xiph.Org Foundation, which provided infrastructure for mailing lists and development coordination, fostering greater community involvement and aligning FLAC with other open multimedia codecs like Vorbis. Josh Coalson led development until 2009, after which maintenance passed to the Xiph.Org Foundation, with Erik de Castro Lopo becoming the primary maintainer in 2012.[12][3][2][13]Key Milestones and Releases
The Free Lossless Audio Codec (FLAC) achieved its initial official release as version 1.0 on July 20, 2001, introducing core support for lossless compression of 16-bit and 24-bit PCM audio streams along with flexible metadata blocks for tags, cuesheets, and seek tables.[14][15] Version 1.1.0 was released on January 26, 2003. Shortly thereafter, on January 29, 2003, FLAC was incorporated into the Xiph.Org Foundation, which incremented the minor version number and laid groundwork for subsequent enhancements in compatibility and performance.[16][2][14] Version 1.1.2 followed on February 5, 2005, delivering decoding speedups across platforms, encoding optimizations in non-LPC modes, improved Ogg FLAC support, and streaming capabilities in plugins like XMMS.[17] In 2007, FLAC integrated into FFmpeg, enabling broader multimedia processing support, coinciding with the release of version 1.2.1 on October 21, 2007, which added comprehensive handling of RIFF/WAVE and AIFF metadata, including Broadcast Wave Format (BWF) extensions.[18] Version 1.3.0 arrived on May 26, 2013—the first major update in six years—shifting development to the Xiph.Org Git repository and introducing support for RF64 and Wave64 formats, enhanced cuesheet handling for non-integer index points, improved seeking precision, and 24-bit dithering options.[19] In December 2024, the FLAC format was formalized as an IETF standard in RFC 9639.[12] FLAC 1.4.0 was released on September 9, 2022, focusing on performance optimizations such as AArch64 assembly accelerations, x86_64 FMA instructions for faster processing, slight compression improvements for presets 3-8, alongside support for sample rates up to 1,048,575 Hz and encoding/decoding of 32-bit integer samples.[20][21] This was followed by version 1.4.3 on June 23, 2023, which emphasized tool enhancements for flac and metaflac, including better foreign metadata restoration, numerous fuzzing-discovered bug fixes, and security-related patches for robustness against overflows and malformed inputs.[22][23] Under ongoing maintenance by Xiph.Org through its central repository, FLAC reached version 1.5.0 on February 11, 2025, introducing a multithreaded encoder for parallel processing and decoder support for chained Ogg FLAC files, with additional compatibility adjustments for modern operating systems like Windows 11 and Android 15 via build system updates.[24]Technical Design
File Structure and Metadata
A FLAC file consists of a 4-byte signature "fLaC" that identifies the stream, followed by one or more metadata blocks, and concluding with the encoded audio stream divided into frames.[12] The metadata blocks provide descriptive information about the audio content, with the first block always being the mandatory STREAMINFO block; subsequent blocks are optional and can appear in any order except for this initial requirement.[12] Each metadata block includes a 32-bit header, variable-length data specific to its type, and a 16-bit CRC checksum for error detection.[12] The 32-bit header consists of 1 bit indicating if it is the last metadata block, 7 bits for the block type (0-127), and 24 bits for the length of the data in bytes. The type values 0-126 are for standard metadata blocks, with 127 reserved as invalid.[12] The STREAMINFO block (type 0) contains critical stream parameters in a fixed 34-byte structure: 16-bit minimum and maximum block sizes (in samples, 16–65535), 24-bit minimum and maximum frame sizes (in bytes, 0 if unknown), 20-bit sample rate (1–1048575 Hz), 3-bit channel count (1–8), 5-bit bits-per-sample minus 1 (thus 4–32 bits), 36-bit total inter-channel samples (0 if unknown), and a 16-byte MD5 hash of the raw PCM audio for integrity verification.[12] FLAC supports up to 8 independent audio channels, sample rates from 1 to 1048575 Hz, and bit depths from 4 to 32 bits per sample, enabling compatibility with a wide range of PCM audio sources.[12] Other standard metadata blocks enhance file utility and extensibility. The VORBIS_COMMENT block (type 4) stores key-value tags such as artist, album, and title in a Vorbis-style format, allowing multiple comments with UTF-8 strings.[12] The PICTURE block (type 6) embeds images like album artwork, using a structure with a 32-bit picture type (e.g., 3 for front cover), MIME type length and string, description, image dimensions, color depth, and indexed image data or URL.[12] The SEEKTABLE block (type 3) facilitates random access by listing seek points, each comprising 64-bit sample number and 64-bit stream offset (or placeholder values for the final point).[12] The CUESHEET block (type 5) embeds CD-style track indexing with up to 100 tracks, including lead-in samples, track times, indices, and flags for pregap or isrc codes.[12] Padding blocks (type 1) reserve empty space for future metadata insertions without file rewriting, while application blocks (type 2) allow vendor-specific data with a 32-bit identifier.[12] Following the metadata, the audio stream comprises variable-length frames, each beginning with a 15-bit synchronization code of 0b111111111111100 (0x7FFC) for alignment.[12] The frame header then encodes parameters via compact codes: after the sync code, a 1-bit blocking strategy flag (1 for variable block size) is followed by a 4-bit code for block size (possibly +8/16 bits for uncommon sizes, ranging 16-65536 samples or from STREAMINFO), a 4-bit code for sample rate (possibly +8/16 bits, or from STREAMINFO), 4 bits for channel assignment (supporting 1-8 channels with decorrelation modes like left-right or mid-side), 3 bits for bits-per-sample (referencing predefined values 4-32 or from STREAMINFO), variable-length coding (up to 36 bits) for frame/block number, and an 8-bit CRC-8 checksum over the header.[12] Each frame concludes with a 16-bit CRC-16 checksum over the entire frame for verification.[12]| Block Type | ID | Purpose |
|---|---|---|
| STREAMINFO | 0 | Essential audio stream parameters (required first block). |
| PADDING | 1 | Reserved space for future metadata. |
| APPLICATION | 2 | Vendor-defined data with identifier. |
| SEEKTABLE | 3 | Seek points for navigation. |
| VORBIS_COMMENT | 4 | Text tags (e.g., title, artist). |
| CUESHEET | 5 | Track and index information. |
| PICTURE | 6 | Embedded images (e.g., cover art). |
Encoding and Compression Methods
FLAC employs linear predictive coding (LPC) to decorrelate audio samples within each block, reducing redundancy by predicting each sample based on previous ones. The predictor order ranges from 0 (constant signal, no prediction) to 12, allowing adaptation to varying signal characteristics. LPC coefficients are computed using the autocorrelation method, where the autocorrelation function is calculated for lags to the predictor order, followed by the Levinson-Durbin recursion to solve the Yule-Walker equations efficiently: This process yields the coefficients that minimize the prediction error energy.[25] The prediction residual , representing the difference between the actual sample and the predicted value, is given by where is the predictor order. These residuals, which exhibit a Laplace-like distribution after effective prediction, are then quantized and entropy-coded losslessly. No psychoacoustic modeling is applied, preserving the original audio fidelity.[26] Entropy coding of residuals primarily uses Rice codes, a form of Golomb-Rice coding optimized for non-negative integers with exponentially decaying probabilities. For each partition of the residual signal, a Rice parameter (ranging from 0 to 14 in 4-bit mode) is selected, where the code length for a value is bits. An escape code (all 1s, i.e., 15 in 4-bit or 31 in 5-bit) signals a switch to unencoded raw binary representation, using 4-, 8-, 16-, or 24-bit fixed-length codes per sample to handle outliers efficiently. FLAC supports two Rice coding methods: a single parameter for the entire residual or multiple parameters via partitioning into up to 8 sub-blocks (orders 0-8, yielding partitions), enabling finer adaptation to local signal variance. The Rice parameter is estimated by approximating the residual variance as , often refined by testing nearby values for minimal coded length.[12][25] Audio blocks in FLAC range from a minimum of 16 to a maximum of 65,535 samples per channel, with the encoder selecting fixed or variable sizes to balance compression and latency; optimal sizes for 44.1 kHz audio typically fall between 2,048 and 8,192 samples. Sub-block partitioning within a block allows independent Rice parameters per segment, improving efficiency for non-stationary signals without increasing overhead significantly.[12][25] The reference FLAC encoder offers nine compression levels (0-8), trading encoding speed for better ratios. Level 0 provides fast encoding with no LPC (order 0) and minimal partitioning, suitable for real-time applications. Higher levels progressively increase LPC order (up to 12 at level 5+), enable exhaustive Rice parameter searches (from level 3), and use advanced techniques like mid-side stereo decorrelation and windowed LPC analysis (level 7+), culminating in level 8's slowest mode with full model search for optimal residuals. Decoding speed remains constant across levels. For typical CD-quality (16-bit, 44.1 kHz stereo) audio, FLAC achieves 50-70% of the original uncompressed size on average, depending on content complexity. Starting with version 1.5.0 (released February 2025), the reference encoder supports multithreading for faster encoding on multi-core processors, with the number of threads configurable while preserving identical output across levels.[27][28][29] Modern implementations incorporate SIMD optimizations, such as SSE2 and AVX2 instructions, to accelerate LPC coefficient computation via vectorized autocorrelation and Levinson-Durbin steps, as well as Rice encoding loops, yielding 20-50% faster encoding on supported hardware without altering output. These enhancements, introduced in FLAC 1.3.0 and refined in later releases, leverage parallel processing of multiple samples or coefficients.[7]Decoding and Verification
The decoding process for FLAC files begins with parsing the frame header, which contains essential information such as the block size, sample rate, channel assignment, and frame number.[30] This header parsing is followed by decoding the subframe data, where residuals—differences from predicted values—are decoded using the inverse Rice coding method to efficiently unpack variable-length codes.[30] An inverse linear predictive coding (LPC) filter is then applied to these residuals, reconstructing the original audio samples by adding back the predictions; for fixed prediction modes, a simpler differencing reversal is used instead.[30] Finally, the decoded samples from individual channels are interleaved to form the complete PCM audio stream, ensuring proper multi-channel output.[30] Verification of FLAC streams emphasizes bit-perfect reproduction of the original uncompressed audio. During encoding, an MD5 hash is computed over all interleaved raw PCM samples and stored in the STREAMINFO metadata block at the file's start. Upon decoding, reference implementations recompute this MD5 hash from the reconstructed samples and compare it to the stored value, confirming exact fidelity if they match; this process detects any discrepancies from transmission errors or decoding faults. Additionally, each frame includes a 16-bit CRC checksum over its header and audio data, allowing immediate detection of corruption during playback.[3] Error handling in FLAC decoders prioritizes robustness and continuity. Frame and subframe CRC checks are performed continuously; if a CRC mismatch occurs, indicating data corruption, the decoder reports the error but can skip the affected frame and proceed to the next valid one, enabling graceful degradation where playback continues with minor audio gaps rather than halting entirely.[31] This approach relies on the fixed frame synchronization codes to resynchronize quickly after a skip.[30] Seeking within FLAC files is facilitated by the optional SEEKTABLE metadata block, which stores pairs of sample numbers and corresponding byte offsets to frame starts, allowing direct jumps to approximate positions for efficient access.[30] With evenly spaced seek points—typically every few seconds or 10-100k samples—decoders can achieve O(log N) seeking time by binary searching the table to find the nearest entry, followed by minimal forward decoding to reach the exact sample. In the absence of a SEEKTABLE, decoders fall back to scanning the file for frame sync codes, approximating binary search on file size for practical logarithmic performance on large streams.[30] FLAC decoding is optimized for speed, enabling real-time playback on modest hardware from the early 2000s, such as a Pentium III at 800 MHz achieving speeds exceeding 1x for CD-quality audio. This efficiency stems from asymmetric design, prioritizing low-latency decompression over encoding complexity.[3] Decoder security has evolved through targeted fixes and testing. In 2014, vulnerabilities including a heap buffer overflow (CVE-2014-9028) and stack buffer overflow (CVE-2014-8962) in the stream decoder were identified, potentially allowing arbitrary code execution on malformed inputs; these were addressed in the FLAC 1.3.1 release.[32][24] In the 2020s, integration with OSS-Fuzz has driven ongoing improvements, uncovering and patching edge-case crashes and overflows via continuous automated testing, enhancing overall robustness without altering the core format.[33]Implementations and Support
Reference Software
The reference software for FLAC, maintained by the Xiph.Org Foundation, consists of official command-line tools and libraries designed for encoding, decoding, and managing FLAC audio files. These tools provide the core implementation of the FLAC format, ensuring compatibility and adherence to the specification across various platforms.[1] The primary command-line tool isflac.exe, a versatile encoder and decoder that converts between uncompressed PCM formats (such as WAV) and FLAC streams. It supports eight compression levels from -0 (fastest, least compression) to -8 (--best, slowest, highest compression), allowing users to balance speed and file size. Additionally, metaflac is a companion utility for viewing, editing, and removing metadata tags in FLAC files, including support for Vorbis comments and picture attachments.[34][35]
The foundational library is libFLAC, a C-based API for developers to integrate FLAC encoding and decoding into applications. Key components include the FLAC__StreamEncoder for creating FLAC streams from raw PCM data and the FLAC__StreamDecoder for extracting PCM from FLAC streams, with options for native FLAC or Ogg FLAC encapsulation. The library also includes libFLAC++, a C++ wrapper for object-oriented use. Notable features encompass multithreading for encoding (introduced in version 1.5.0), ReplayGain volume normalization calculation, and input/output handling for WAV and raw PCM formats.[36][37][7]
Licensing distinguishes the components: libFLAC and libFLAC++ are distributed under a BSD-like license, permitting broad reuse in proprietary software, while the command-line tools like flac.exe and metaflac fall under the GNU General Public License (GPL). The project follows a release cycle tied to major versions, with FLAC 1.4.3 released in 2023 focusing on encoder speed improvements and FLAC 1.5.0 in 2025 adding multithreaded encoding enhancements and chained Ogg FLAC decoding support.[10][38][7]
These tools exhibit strong cross-platform compatibility, compiling on Windows, macOS, Linux, and other Unix-like systems via standard build tools like Autotools or CMake. By 2025, WebAssembly ports such as libflac.js enable browser-based FLAC processing without native plugins, facilitating web applications for audio conversion and playback.[34]
Common usage includes batch conversion scripts, such as shell loops invoking flac -8 input.wav to process directories of WAV files into compressed FLAC archives while preserving metadata. Developers integrate libFLAC into build systems (e.g., via pkg-config or CMake) for automated audio workflows in media servers or archival tools.[39]
Third-Party Software and Libraries
Several third-party audio players provide native or integrated support for FLAC files, enabling playback on various platforms. Foobar2000, a highly customizable Windows-based media player, has offered native FLAC decoding since its initial release in 2002, allowing users to handle lossless audio alongside other formats without additional plugins.[40] VLC Media Player, a cross-platform multimedia framework, supports FLAC through its integration with the FFmpeg library, providing seamless playback, streaming, and conversion capabilities across Windows, macOS, Linux, and mobile devices. Audio editing software has incorporated FLAC support to facilitate import, export, and manipulation of lossless files. Audacity, an open-source editor, uses the libFLAC library for direct import and export of FLAC files, preserving audio quality during editing tasks like trimming or effects application without requiring external dependencies on most platforms.[41] Adobe Audition, a professional digital audio workstation, includes native FLAC support in recent versions for importing and exporting, though earlier iterations relied on third-party plugins such as the FLAC File Filter developed for compatibility with Cool Edit Pro and Audition.[42][43] Programming libraries extend FLAC functionality into development environments. FFmpeg, a widely used multimedia framework, added FLAC decoding to its libavcodec component around 2007 and encoding support in version 0.6 released in 2010, enabling developers to process FLAC in video and audio pipelines.[44] Language bindings include pyFLAC, a Python wrapper for libFLAC released by Sonos in 2021, which supports real-time encoding and decoding for applications like audio streaming.[45] JFLAC, a pure Java implementation ported in 2004, provides encoder and decoder classes for integrating FLAC into Java-based projects, such as desktop or Android applications.[46] Tools for audio conversion and archiving often prioritize FLAC for its balance of compression and fidelity. Exact Audio Copy (EAC), a Windows utility for precise CD ripping, supports outputting directly to FLAC format, using AccurateRip verification to ensure bit-perfect extraction from optical media. On mobile platforms, FLAC playback relies on system-level or app-based implementations. Android has supported FLAC decoding via the MediaCodec API since Android 3.1 (API level 12, released in 2011), allowing native apps to process the format efficiently.[47] iOS lacks built-in FLAC support in its Music app but accommodates it through third-party players like FLAC Player+, which handles playback, metadata viewing, and equalizer adjustments for lossless files.[48] Recent developments have expanded FLAC into interactive media. The Godot game engine, starting with version 4.0 in 2023, facilitates FLAC integration via GDExtension modules like godot-flac-extension, enabling developers to load and play compressed audio assets in cross-platform games for optimized storage.[49] By 2025, browser-based applications leverage JavaScript ports such as libflac.js for FLAC decoding within the Web Audio API, supporting web games and streaming without native browser codec reliance.[50]Hardware Integration
FLAC has seen integration into various consumer hardware devices, beginning with portable audio players in the early 2000s. The iRiver H300 series, released in 2003, was among the first portable players to offer native FLAC decoding, allowing users to play lossless audio files on battery-powered devices without quality loss. Similarly, Cowon players, such as the iAudio X5 introduced around 2005, supported FLAC playback, contributing to its early adoption in the digital audio player market. In modern portable players, brands like FiiO and Astell&Kern provide robust FLAC support, with models such as the FiiO M11 and Astell&Kern A&ultima series capable of native decoding up to 24-bit/192 kHz resolution, often paired with high-quality DACs for audiophile-grade performance. Audio-video receivers (AVRs) and home theater systems from major manufacturers began incorporating FLAC support in the late 2000s to meet the growing demand for high-resolution audio. Denon AVRs began incorporating FLAC support via network streaming and USB inputs in models from around 2010, such as the AVR-3310, enhancing compatibility with lossless formats in home entertainment setups. Yamaha receivers followed suit in the late 2000s, with models like the RX-V2065 from 2010 supporting FLAC over DLNA and Ethernet, and later models utilizing HDMI audio return channels to transmit FLAC streams between devices without recompression. Smartphones have increasingly embedded FLAC decoding in their hardware. Android devices gained native FLAC support starting with version 3.0 (Honeycomb) in 2011, allowing direct playback through the operating system's media framework without third-party apps. On iOS, while there is no built-in hardware decoding for FLAC, certain apps can leverage the device's audio processing capabilities for playback, though this remains app-dependent. Many modern smartphones use chipsets like Qualcomm's Snapdragon series, which include hardware acceleration for FLAC decoding, improving efficiency and battery life during playback of high-resolution files. In automotive audio systems, FLAC compatibility is facilitated through integration with smartphone mirroring protocols. Android Auto and Apple CarPlay support FLAC playback when connected to compatible head units, enabling lossless audio from mobile devices to stream via the car's infotainment system without quality degradation. Professional hardware, particularly in broadcasting, utilizes FLAC for reliable audio transmission in some workflows. In the 2020s, FLAC-like lossless audio has expanded to wireless consumer devices. The Sony WF-1000XM5 wireless earbuds support aptX Lossless, a codec developed by Qualcomm that transmits uncompressed audio equivalent to FLAC over Bluetooth, achieving CD-quality lossless playback. Smart home systems have also updated their hardware firmware for better FLAC integration; Sonos speakers added native FLAC support in updates around 2009 and have continued enhancements for high-resolution streaming, while Google Nest devices, through recent firmware, enable FLAC playback via compatible services like Tidal.Comparisons
With Other Lossless Formats
FLAC, as an open-source lossless audio codec, offers compression ratios typically reducing stereo 16-bit WAV files to about 50-60% of their original size, depending on the audio content's complexity.[51][52] This efficiency has been benchmarked on standard test sets, including high-resolution audio corpora, where FLAC maintains bit-perfect reproduction while balancing file size and processing speed.[53] Compared to Apple's ALAC, FLAC achieves similar overall compression levels of 50-60% but often results in 5-10% smaller files for equivalent audio, particularly in benchmarks from the 2020s on modern hardware.[54][53] While ALAC was proprietary until Apple open-sourced it in 2011, FLAC has been freely available without licensing restrictions from its inception, avoiding any patent encumbrances that affected early ALAC implementations (with related claims expiring in the 2020s). FLAC also supports more flexible metadata via Vorbis comments and enables faster seeking through its streamable structure, advantages over ALAC's integration with MP4 containers and iTunes-style tags.[53] In contrast to Monkey's Audio (APE), FLAC prioritizes speed over maximum compression, encoding and decoding 2-5 times faster on average, though APE can produce files 5-20% smaller at its highest settings, such as "Insane" mode.[55] Recent tests on 2020s hardware highlight FLAC's efficiency edge, with lower computational demands making it suitable for real-time applications, while APE remains closed-source and slower overall.[56][57] Relative to WavPack, FLAC and WavPack both support bit-perfect lossless decoding of audio data, though WavPack offers additional features like hybrid compression and may better preserve certain file metadata in roundtrip scenarios to WAV; WavPack generally achieves comparable or slightly better compression (within 1-5% smaller files).[58][59] Both are open-source and patent-free, but FLAC's design emphasizes hardware-friendly decoding and native support for error detection, outperforming WavPack in streaming benchmarks on recent processors.With Lossy Formats
FLAC, as a lossless audio codec, achieves compression ratios of approximately 50-70% of the size of uncompressed WAV files for CD-quality audio (16-bit/44.1 kHz stereo), reducing file sizes from around 1411 kbps to 700-1000 kbps on average without any data loss.[52] In contrast, lossy formats like MP3 and AAC typically compress to 10-20% of WAV size at high bitrates (128-320 kbps), achieving much smaller files—such as 9-12 MB for a 4-minute track versus 36-40 MB for WAV—but at the cost of perceptual audio quality through irreversible data discard.[52][60] This trade-off makes lossy codecs suitable for bandwidth-constrained applications, while FLAC's preservation of the original waveform ensures no generation loss upon repeated decoding. Unlike lossy codecs, which introduce artifacts such as quantization noise and perceptual distortions by discarding inaudible frequencies and quantizing audio samples into coarser levels, FLAC retains every bit of the source material, making it immune to such degradations and ideal for long-term archiving where fidelity must remain intact.[61] For instance, MP3 and AAC at 128 kbps often exhibit noticeable smearing or "pre-echo" artifacts in complex passages, whereas FLAC decoded output matches the input exactly, supporting bit-perfect verification.[62] This lossless integrity positions FLAC as the preferred format for professional audio workflows like editing and mastering, where multiple processing steps could amplify artifacts from lossy intermediates, whereas lossy formats dominate storage-limited streaming due to their efficiency.[63][64] In terms of bitrate equivalents, a CD-quality FLAC stream operates at around 1411 kbps uncompressed equivalent but averages 800-1000 kbps post-compression, compared to MP3 or AAC at 128-320 kbps, where perceptual transparency—indistinguishability from lossless—is generally achieved only above 256 kbps for most listeners and content types.[52] Converting from FLAC to a lossy format like MP3 is irreversible, as the discarded data cannot be recovered, reinforcing FLAC's role as a high-fidelity intermediate for workflows before final distribution in lossy variants.[65] This distinction has influenced streaming services; for example, Spotify's long-delayed HiFi tier, launched in September 2025, utilizes a FLAC backend to deliver up to 24-bit/44.1 kHz lossless audio to Premium subscribers, bridging the gap between archival quality and convenient playback without the compromises of traditional lossy streaming.[66]Adoption and Applications
Commercial and Streaming Use
FLAC has played a prominent role in commercial music distribution since the late 2000s, enabling high-fidelity downloads without quality loss. Platforms like HDtracks pioneered high-resolution audio sales in 2008, offering tracks in FLAC format up to 24-bit/96 kHz and beyond, catering to audiophiles seeking studio-master quality.[67] Similarly, Qobuz launched as a key provider of FLAC downloads in 24-bit Hi-Res quality, emphasizing uncompressed audio for over 100 million tracks and establishing 24/96 as a de facto standard for high-resolution purchases.[68] These services allow consumers to own files outright, supporting metadata preservation and offline playback on compatible devices. In streaming, FLAC underpins several premium tiers designed for lossless and high-resolution delivery. Tidal introduced its Masters program in 2014, initially using MQA-wrapped audio but transitioning to native HiRes FLAC by 2023, supporting resolutions up to 24-bit/192 kHz for superior detail in compatible setups.[69] Amazon Music HD, launched in 2019, streams FLAC files up to 24-bit/192 kHz as part of its Unlimited plan, expanding access to ultra-high-definition content for subscribers.[70] Deezer's HiFi tier also utilizes FLAC for CD-quality lossless streaming at 16-bit/44.1 kHz, with options extending to higher resolutions like 24-bit/96 kHz in select markets.[71] In September 2025, Spotify introduced lossless audio streaming using FLAC up to 24-bit/44.1 kHz for Premium subscribers.[66] Direct-to-consumer sales platforms further integrate FLAC for artist-driven distribution. Bandcamp has offered native FLAC downloads since its early days, recommending artists upload lossless sources like FLAC to ensure high-quality conversions and fan ownership of 16-bit/44.1 kHz files or higher.[72] In contrast, the iTunes Store (now Apple Music downloads) does not support native FLAC, instead providing Apple Lossless (ALAC) files; users often convert FLAC purchases from other sources to ALAC for iTunes compatibility using built-in tools.[73] By 2025, FLAC commands a significant portion of the lossless download and streaming market, driven by post-2020 surges in demand amid 5G rollout and broadband improvements.[74] This growth reflects broader adoption in commercial ecosystems, though challenges persist, particularly for mobile streaming where high-res FLAC demands substantial bandwidth—up to 9.2 Mb/s for 24-bit/192 kHz—potentially straining non-5G connections and leading to adaptive quality downgrades.[75] Integrations like YouTube Music's anticipated lossless tier remain incomplete as of late 2025, highlighting ongoing hurdles in universal high-res rollout.[76]Archival and Preservation
FLAC's lossless compression ensures that audio data remains identical to the original upon decoding, making it ideal for long-term digital preservation where fidelity is paramount. As an open-source format developed by the Xiph.Org Foundation, FLAC avoids proprietary restrictions and is unencumbered by patents, allowing unrestricted use and modification by archives worldwide.[10] Each FLAC file embeds an MD5 checksum in its header for verifying data integrity without recompression, providing a robust mechanism to detect corruption over time.[77] Compared to uncompressed formats like WAV, FLAC reduces file sizes by 30-60% through efficient lossless encoding, facilitating storage of large collections without quality loss.[78] Major institutions have adopted FLAC for archiving audio materials. The Internet Archive prefers FLAC among lossless formats for uploading and deriving public domain recordings, as it balances quality and efficiency in their vast digital library.[79] The Library of Congress provides a technical description of FLAC as a suitable open-source lossless format for linear PCM audio, though it recommends uncompressed WAVE formats for archival master copies.[8] These organizations leverage FLAC's support for embedded metadata, such as timestamps and provenance details, to enhance cataloging in preservation workflows. Bulk conversion pipelines streamline the migration of legacy audio from formats like AIFF or WAV to FLAC, often using tools such as FFmpeg for batch processing and the FLAC command-line utility for verification. For instance, runningflac -t on converted files performs checksum validation to confirm bit-perfect reproduction.[80] This approach aligns with standards like the International Association of Sound and Audiovisual Archives (IASA-TC 04) guidelines, which emphasize lossless PCM-based formats for production and preservation, with FLAC serving as a practical compressed alternative to uncompressed WAV in resource-constrained environments.[81]
FLAC's longevity is bolstered by its patent-free status and ongoing maintenance by the Xiph.Org community, ensuring format stability and backward compatibility for future decoders. In emerging applications, FLAC has appeared in blockchain-based audio archives, such as NFT platforms using it for tokenizing high-fidelity music files stored via decentralized protocols like IPFS, a trend noted in music copyright management systems from 2021 onward.[82] For ultimate durability, FLAC archives are housed in climate-controlled data centers, where stable temperatures (typically 18-27°C) and humidity (40-60% RH) prevent media degradation, supporting indefinite access to preserved audio.[83]