FLAC (Free Lossless Audio Codec)
An open-source lossless audio compression format that reduces file size by 50-70% while preserving bit-perfect audio fidelity.
You are a file format specialist with deep expertise in the FLAC (Free Lossless Audio Codec) format. You understand the encoding pipeline (linear prediction, Rice coding, interchannel decorrelation), the block-based structure with seek tables and MD5 verification, Vorbis comment metadata, and compression level tradeoffs. You can advise on encoding, decoding, transcoding, tagging, verifying integrity, and optimizing FLAC files for music archival, streaming, and high-resolution audio workflows. ## Key Points 1. Audio is divided into blocks (typically 4096 samples) 2. Interchannel decorrelation is applied (mid-side stereo) 3. Linear prediction models the signal (up to 32nd order) 4. Residuals (prediction errors) are encoded with Rice/Golomb codes 5. MD5 checksum of raw audio is stored for verification - **Desktop**: VLC, foobar2000, MusicBee, Winamp, Clementine, Strawberry - **macOS**: Native support since macOS 11 Big Sur; VLC for older versions - **Mobile**: Most modern music players (Poweramp, AIMP, VLC) - **Streaming**: Tidal (HiFi), Qobuz, Deezer HiFi use FLAC - **flac** (reference encoder): `flac -8 input.wav` (max compression) - **FFmpeg**: `ffmpeg -i input.wav -codec:a flac -compression_level 8 output.flac` - **Audacity**: Export > FLAC ## Quick Example ``` flac --test input.flac ```
skilldb get file-formats-skills/FLAC (Free Lossless Audio Codec)Full skill: 158 linesYou are a file format specialist with deep expertise in the FLAC (Free Lossless Audio Codec) format. You understand the encoding pipeline (linear prediction, Rice coding, interchannel decorrelation), the block-based structure with seek tables and MD5 verification, Vorbis comment metadata, and compression level tradeoffs. You can advise on encoding, decoding, transcoding, tagging, verifying integrity, and optimizing FLAC files for music archival, streaming, and high-resolution audio workflows.
FLAC — Free Lossless Audio Codec
Overview
FLAC (Free Lossless Audio Codec) is an open-source audio codec that compresses audio without any loss of quality. Every bit of the original audio is preserved and perfectly reconstructed on playback, while achieving file sizes typically 50-70% smaller than uncompressed WAV. FLAC has become the de facto standard for lossless music distribution and archival.
Developed by Josh Coalson, FLAC was first released in 2001 and has been maintained by the Xiph.Org Foundation since 2003 (the same organization behind Ogg Vorbis and Opus). The format is fully open-source under BSD and GPL licenses, with no patents or royalties. In 2014, FLAC reference encoder/decoder development was incorporated into the Xiph.Org community.
FLAC works by predicting each audio sample using linear prediction, then efficiently encoding the small residual error using Rice coding. Because the prediction closely matches the actual signal, the residuals are small numbers that compress well.
Core Philosophy
FLAC embodies a clear principle: audio fidelity should never be sacrificed for file size. As a lossless codec, FLAC guarantees bit-perfect reconstruction of the original audio — every sample decoded is identical to the source. This makes FLAC the natural choice whenever audio quality matters more than minimizing bandwidth or storage, from music archival to professional audio workflows.
FLAC's design balances compression efficiency with practical usability. Unlike some lossless codecs that maximize compression at the expense of decode speed, FLAC decodes quickly enough for real-time playback on modest hardware while still achieving 50-60% size reduction compared to uncompressed WAV. The format is also streamable, seekable, and supports rich metadata — qualities that make it suitable for both archival and everyday listening.
The FLAC ecosystem reflects its open-source philosophy. The format is patent-free, royalty-free, and supported by a vast range of hardware and software. When choosing a lossless audio format, FLAC is the default answer unless your workflow specifically requires Apple ecosystem integration (use ALAC) or maximum possible compression ratio (consider Monkey's Audio). For everything else, FLAC's combination of quality, compatibility, and openness is unmatched.
Technical Specifications
| Property | Details |
|---|---|
| File Extension | .flac |
| MIME Type | audio/flac, audio/x-flac |
| Codec | FLAC |
| Compression | Lossless |
| Compression Ratio | Typically 50-70% of original (varies by content) |
| Sample Rates | 1 Hz to 655,350 Hz (common: 44.1, 48, 88.2, 96, 176.4, 192 kHz) |
| Bit Depth | 4 to 32 bits per sample (common: 16, 24) |
| Channels | 1 to 8 |
| Metadata | Vorbis comments (flexible key=value tags), embedded cover art |
| Seekable | Yes, via seek table |
| Streamable | Yes, with Ogg container (Ogg FLAC) |
Compression Levels
FLAC encoders offer compression levels 0-8, affecting encode speed vs. file size (all levels are lossless):
| Level | Speed | Compression | Notes |
|---|---|---|---|
| 0 | Fastest | Least compressed | Good for real-time recording |
| 5 | Default | Good balance | Recommended for most use |
| 8 | Slowest | Most compressed | ~2-3% smaller than level 5 |
How It Works
- Audio is divided into blocks (typically 4096 samples)
- Interchannel decorrelation is applied (mid-side stereo)
- Linear prediction models the signal (up to 32nd order)
- Residuals (prediction errors) are encoded with Rice/Golomb codes
- MD5 checksum of raw audio is stored for verification
How to Work With It
Opening / Playing
- Desktop: VLC, foobar2000, MusicBee, Winamp, Clementine, Strawberry
- macOS: Native support since macOS 11 Big Sur; VLC for older versions
- Mobile: Most modern music players (Poweramp, AIMP, VLC)
- Streaming: Tidal (HiFi), Qobuz, Deezer HiFi use FLAC
Creating / Encoding
- flac (reference encoder):
flac -8 input.wav(max compression) - FFmpeg:
ffmpeg -i input.wav -codec:a flac -compression_level 8 output.flac - Audacity: Export > FLAC
- Any DAW: Most support FLAC export directly or via plugin
Converting
- To WAV:
flac -d input.flacorffmpeg -i input.flac output.wav - To MP3:
ffmpeg -i input.flac -codec:a libmp3lame -V 0 output.mp3 - To ALAC:
ffmpeg -i input.flac -codec:a alac output.m4a
Verifying Integrity
flac --test input.flac
This decodes the file and compares the MD5 checksum against the stored value, confirming bit-perfect integrity.
Common Use Cases
- Lossless music libraries and collections
- Music archival and preservation (ripping CDs to FLAC)
- Source format for transcoding to lossy formats (encode once, transcode to any target)
- High-resolution audio distribution (HDtracks, Bandcamp, Qobuz)
- Professional audio backup and interchange
- Lossless streaming services (Tidal HiFi, Amazon Music HD, Apple Music lossless uses ALAC)
Pros & Cons
Pros
- Completely lossless; bit-perfect reconstruction guaranteed
- 50-70% compression ratio compared to uncompressed PCM
- Open-source, royalty-free, no patents
- Fast decoding (lighter than encoding)
- Built-in MD5 verification for integrity checking
- Rich metadata via Vorbis comments; embedded album art support
- Seekable with seek tables for instant navigation
- Supports high-resolution audio up to 32-bit/655 kHz
- Widely supported by music players and streaming services
Cons
- Files are 2-5x larger than equivalent lossy formats (MP3, AAC)
- Not natively supported on iOS (Apple uses ALAC) prior to iOS 11
- Older car stereos and portable players may lack support
- No native DRM support (a pro for users, con for some distributors)
- Web browser support limited (no Safari support for
<audio>as of 2024) - Compression ratio varies significantly by content (silence compresses well; noise does not)
Compatibility
| Platform | Support |
|---|---|
| Windows | Windows 10+ native; earlier via codecs/players |
| macOS | Native since macOS 11 (Big Sur) |
| Linux | Native (GStreamer, FFmpeg, ALSA) |
| iOS | Native since iOS 11 |
| Android | Native since Android 3.1 |
| Web Browsers | Chrome, Firefox, Edge (no Safari) |
| Streaming | Tidal, Qobuz, Deezer, Amazon Music HD |
| Hardware | Most modern DAPs, receivers, smart speakers |
Related Formats
- ALAC — Apple's lossless codec; similar compression, better Apple ecosystem support
- WAV — Uncompressed source; FLAC compresses this losslessly
- APE — Monkey's Audio; slightly better compression but less compatible
- WavPack — Lossless codec with hybrid lossy+correction mode
- DSD/DSF — 1-bit high-resolution format; different encoding paradigm
- Opus — Lossy but extremely efficient; not comparable use case
Practical Usage
- CD ripping workflow: Use Exact Audio Copy (Windows) or whipper (Linux) to rip CDs to FLAC with AccurateRip verification. Store FLAC as the archival master and transcode to lossy formats as needed -- never transcode from one lossy format to another.
- Metadata tagging: Use
metaflac(CLI) or MusicBrainz Picard (GUI) to add Vorbis comment tags. FLAC supports arbitrary tag names, but stick to standard fields (ARTIST, ALBUM, TITLE, TRACKNUMBER, DATE) for maximum player compatibility. - Integrity verification: Run
flac --test *.flacperiodically on archival collections to verify MD5 checksums. This catches bit rot from storage degradation before it becomes unrecoverable. - Streaming service source files: When uploading to streaming services (Bandcamp, DistroKid), upload FLAC as the source. The service will transcode to various lossy formats -- starting from a lossless source ensures the best possible quality at every bitrate.
- ReplayGain for normalized playback: Apply ReplayGain tags with
metaflac --add-replay-gain *.flacto normalize playback volume across albums without modifying the audio data.
Anti-Patterns
- Using compression level 8 for real-time recording: Level 8 is CPU-intensive and provides only 2-3% smaller files than the default level 5. For live recording or real-time encoding, use level 0 or 1 to avoid dropped samples on slower hardware.
- Transcoding MP3 or AAC to FLAC expecting quality improvement: Converting a lossy file to FLAC preserves the lossy artifacts in a larger file. FLAC only preserves quality that exists in the source. Lossless encoding is only meaningful from a lossless source (CD, studio master, WAV).
- Storing FLAC files without embedded metadata: Relying solely on folder structure and filenames for organization is fragile. Always embed proper Vorbis comment tags so files remain identifiable regardless of where they are stored.
- Ignoring sample rate and bit depth mismatches: Mixing 44.1 kHz and 48 kHz files in a playlist causes some players to resample silently. Group files by sample rate and be aware of implicit conversion during playback.
- Assuming all devices and services support FLAC: While support is broad, Safari's
<audio>element does not support FLAC, and some older car stereos and portable players lack FLAC decoding. Provide fallback formats when targeting these platforms.
Install this skill directly: skilldb add file-formats-skills
Related Skills
3MF 3D Manufacturing Format
The 3MF file format — the modern replacement for STL in 3D printing, supporting colors, materials, multi-object assemblies, and precise manufacturing data in a single package.
7-Zip Compressed Archive
The 7z archive format — open-source high-ratio compression using LZMA2, with strong AES-256 encryption, solid archives, and multi-threading support.
AAC (Advanced Audio Coding)
A lossy audio codec standardized as part of MPEG-2 and MPEG-4, designed to supersede MP3 with better quality at equivalent or lower bitrates.
AC3 (Dolby Digital)
Dolby's surround sound audio codec used in cinema, DVD, Blu-ray, and broadcast television for multichannel 5.1 audio delivery.
AI Adobe Illustrator Format
AI is Adobe Illustrator's native vector graphics file format, used for
AIFF (Audio Interchange File Format)
Apple's uncompressed audio format storing raw PCM data, serving as the Mac equivalent of WAV for professional audio production.