FLAC
   HOME

TheInfoList



OR:

FLAC (; Free Lossless Audio Codec) is an audio coding format for lossless compression of
digital audio Digital audio is a representation of sound recorded in, or converted into, digital signal (signal processing), digital form. In digital audio, the sound wave of the audio signal is typically encoded as numerical sampling (signal processing), ...
, developed by the Xiph.Org Foundation, and is also the name of the
free software Free software, libre software, libreware sometimes known as freedom-respecting software is computer software distributed open-source license, under terms that allow users to run the software for any purpose as well as to study, change, distribut ...
project producing the FLAC tools, the reference software package that includes a
codec A codec is a computer hardware or software component that encodes or decodes a data stream or signal. ''Codec'' is a portmanteau of coder/decoder. In electronic communications, an endec is a device that acts as both an encoder and a decoder o ...
implementation. Digital audio compressed by FLAC's
algorithm In mathematics and computer science, an algorithm () is a finite sequence of Rigour#Mathematics, mathematically rigorous instructions, typically used to solve a class of specific Computational problem, problems or to perform a computation. Algo ...
can typically be reduced to between 50 and 70 percent of its original size and decompresses to an identical copy of the original audio data. FLAC is an
open format An open file format is a file format for storing digital data, defined by an openly published specification usually maintained by a standards organization, and which can be used and implemented by anyone. An open file format is licensed with a ...
with royalty-free licensing and a
reference implementation In the software development process, a reference implementation (or, less frequently, sample implementation or model implementation) is a program that implements all requirements from a corresponding specification. The reference implementation ...
which is
free software Free software, libre software, libreware sometimes known as freedom-respecting software is computer software distributed open-source license, under terms that allow users to run the software for any purpose as well as to study, change, distribut ...
. FLAC supports
metadata Metadata (or metainformation) is "data that provides information about other data", but not the content of the data itself, such as the text of a message or the image itself. There are many distinct types of metadata, including: * Descriptive ...
tagging,
album cover An album cover (also referred to as album art) is the front packaging art of a commercially released album, studio album or other audio recordings. The term can refer to: * the printed paperboard covers typically used to package: ** sets of a ...
art, and fast seeking.


History

Development was started in 2000 by Josh Coalson. The
bitstream A bitstream (or bit stream), also known as binary sequence, is a sequence of bits. A bytestream is a sequence of bytes. Typically, each byte is an 8-bit quantity, and so the term octet stream is sometimes used interchangeably. An octet may ...
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. 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 Theora is a free lossy video compression format. It was developed by the Xiph.Org Foundation and distributed without licensing fees alongside their other free and open media projects, including the Vorbis audio format and the Ogg contai ...
, Speex and Opus. Version 1.3.0 was released on 26 May 2013, at which point development was moved to the Xiph.org git repository. In 2019, FLAC was proposed as an IETF standard. In December 2024, FLAC was formally specified in and published as .


Design

FLAC is a lossless encoding of linear pulse-code modulation data.


File structure

A FLAC file consists of the magic number fLaC,
metadata Metadata (or metainformation) is "data that provides information about other data", but not the content of the data itself, such as the text of a message or the image itself. There are many distinct types of metadata, including: * Descriptive ...
, and encoded audio. 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 In signal processing, sampling is the reduction of a continuous-time signal to a discrete-time signal. A common example is the conversion of a sound wave to a sequence of "samples". A sample is a value of the signal at a point in time and/or ...
and bit depth. The data block contains the audio information. Metadata in FLAC precedes the audio. Properties like the
sample rate In signal processing, sampling is the reduction of a continuous-time signal to a discrete-time signal. A common example is the conversion of a sound wave to a sequence of "samples". A sample is a value of the signal at a point in time and/or ...
and the number of channels are always contained in the metadata. It may also contain other information, the
album cover An album cover (also referred to as album art) is the front packaging art of a commercially released album, studio album or other audio recordings. The term can refer to: * the printed paperboard covers typically used to package: ** sets of a ...
for example. FLAC uses Vorbis comments for textual metadata like track title and artist name.


Encoding and decoding

The 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 In mathematics, a polynomial is a Expression (mathematics), mathematical expression consisting of indeterminate (variable), indeterminates (also called variable (mathematics), variables) and coefficients, that involves only the operations of addit ...
, 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 Pulse-code modulation (PCM) is a method used to digitally represent analog signals. It is the standard form of digital audio in computers, compact discs, digital telephony and other digital audio applications. In a PCM stream, the amplitud ...
. The decoding process is the reverse of encoding. The compressed residual is first decoded. 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. 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. Even though the reference encoder uses a single block size for the whole stream, FLAC allows the block size in samples to vary per block.


Compression

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. 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.


Implementation

Alongside the format, the FLAC project also contains a
free and open-source Free and open-source software (FOSS) is software available under a Software license, license that grants users the right to use, modify, and distribute the software modified or not to everyone free of charge. FOSS is an inclusive umbrella term ...
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 A patent is a type of intellectual property that gives its owner the legal right to exclude others from making, using, or selling an invention for a limited period of time in exchange for publishing an sufficiency of disclosure, enabling discl ...
, and anyone is free to write their own implementations of FLAC.


Comparison to other formats

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 gzip is a file format and a software application used for file compression and decompression. The program was created by Jean-loup Gailly and Mark Adler as a free software replacement for the compress program used in early Unix systems, and ...
. 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. The technical strengths of FLAC compared to other lossless formats lie in its ability to be streamed and decoded quickly, independent of compression level. 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. 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


Reference implementation

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 A codec is a computer hardware or software component that encodes or decodes a data stream or signal. ''Codec'' is a portmanteau of coder/decoder. In electronic communications, an endec is a device that acts as both an encoder and a decoder o ...
API is also available in C++ as libFLAC++. The reference implementation of FLAC compiles on many platforms, including most
Unix Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
(such as Solaris,
BSD The Berkeley Software Distribution (BSD), also known as Berkeley Unix or BSD Unix, is a discontinued Unix operating system developed and distributed by the Computer Systems Research Group (CSRG) at the University of California, Berkeley, beginni ...
) and
Unix-like A Unix-like (sometimes referred to as UN*X, *nix or *NIX) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Uni ...
(including
Linux Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
),
Windows Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
, BeOS, and
OS/2 OS/2 is a Proprietary software, proprietary computer operating system for x86 and PowerPC based personal computers. It was created and initially developed jointly by IBM and Microsoft, under the leadership of IBM software designer Ed Iacobucci, ...
operating systems. There are build-systems for autoconf/ automake,
MSVC Microsoft Visual C++ (MSVC) is a compiler for the C, C++, C++/CLI and C++/CX programming languages by Microsoft. MSVC is proprietary software; it was originally a standalone product but later became a part of Visual Studio and made available ...
, Watcom C, and
Xcode Xcode is a suite of developer tools for building apps on Apple devices. It includes an integrated development environment (IDE) of the same name for macOS, used to develop software for macOS, iOS, iPadOS, watchOS, tvOS, and visionOS. It w ...
. 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

FLAC playback support in portable audio devices and dedicated audio systems is limited compared to formats such as MP3 or uncompressed PCM. FLAC support is included by default in
Windows 10 Windows 10 is a major release of Microsoft's Windows NT operating system. The successor to Windows 8.1, it was Software release cycle#Release to manufacturing (RTM), released to manufacturing on July 15, 2015, and later to retail on July 2 ...
, Android,
macOS macOS, previously OS X and originally Mac OS X, is a Unix, Unix-based operating system developed and marketed by Apple Inc., Apple since 2001. It is the current operating system for Apple's Mac (computer), Mac computers. With ...
and iOS. Various other containers are supported, independently from used operating system, depending on used playback software.


Use in archives

The standardization process of the FLAC format into was driven by the specific use case of archival and preservation in mind. The
National Archives and Records Administration The National Archives and Records Administration (NARA) is an independent agency of the United States government within the executive branch, charged with the preservation and documentation of government and historical records. It is also task ...
has FLAC listed as a preferred format for digital audio.


See also

* Comparison of audio coding formats * List of audio player software that supports FLAC


References


External links

*
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 {{Xiph.org 2001 software Cross-platform software Free audio codecs Lossless audio codecs Xiph.Org projects Open formats