Skip to content

FLAC

currentMigrated from docs/audio/FLAC.mdx at 37c3317fd058; modified for Encode Wiki · CC BY-SA 4.0

FLAC (Free Lossless Audio Codec) compresses PCM audio to roughly half its size and decodes back to identical samples. It is open, fast to decode, plays almost everywhere, has good tagging, and is the default choice for music archives and lossless downloads. Use it unless you are locked into Apple’s ecosystem (ALAC) or need something FLAC lacks, such as WavPack’s float support or hybrid mode.

FLAC holds 4–32-bit integer PCM with 1–8 channels. It cannot store floating-point audio or DSD. Encoding a lossy source (MP3, AAC, Opus) to FLAC only preserves the damage at several times the size, so don’t.

With the reference encoder:

Terminal window
flac -8 -V input.wav -o output.flac

Or with FFmpeg:

Terminal window
ffmpeg -i input.wav output.flac

-V verifies the encode by decoding it as it goes. Use flac -t file.flac any time to test a file; it checks the MD5 of the audio stored in the header.

The levels only trade encoding time against file size. Every level decodes to the same samples, and decoding speed barely changes.

ToolLevelsDefaultNotes
flac-0 … -8-5-8 is --best. Add -e for an exhaustive model search, which is very slow for a tiny gain.
FFmpeg-compression_level 0 … 1250–8 roughly mirror flac’s levels. 11 and 12 allow LPC orders up to 32, which takes the file outside the streamable subset at 48 kHz and below.

The gap between -5 and -8 is typically a percent or two, so the default is fine for most work. FLAC 1.5.0 can use several threads (-j) when encoding.

FLAC stores tags in a Vorbis comment block, cover art in a PICTURE block and seek points in a SEEKTABLE. metaflac edits these without touching the audio:

Terminal window
metaflac --list output.flac
metaflac --set-tag="ARTIST=Name" --import-picture-from=cover.jpg output.flac

Plain .flac is the normal form. FLAC can also live in Ogg (flac --ogg, usually .oga), Matroska/.mka, and MP4. Native FLAC plays in all current browsers and most hardware; Ogg FLAC and FLAC in MP4 are less widely supported.

The format has a “streamable subset” that restricts block sizes, LPC order and sample-rate signalling so hardware decoders can cope. flac stays inside it unless you pass --lax, and FFmpeg does up to -compression_level 10; stay there if the files are headed for hardware players.

Check 5.1 and 7.1 files on the device you care about, since some players ignore the channel layout.

Terminal window
flac -d input.flac -o output.wav
ffmpeg -i input.flac output.wav

To get the original WAV back byte for byte, including non-audio chunks, pass --keep-foreign-metadata to both the encode and the decode.

  • ALAC and WavPack for the other lossless options
  • Opus and AAC for lossy delivery from a FLAC master