Skip to content

Saving Space with FLAC

There is no reason to store music in WAV format, except for compatibility when working in music production or as a DJ. FLAC is a lossless audio codec, meaning the audio data will not change and will sound exactly the same as the source.

The speed of decoding FLAC files does practically not depend on the compression level used when encoding.1 While encoding with higher compression levels does take more time, it is a one time process and worth the additional saved space, especially if you have a lot of audio.

Assuming all lossless audio is already encoded with libFLAC at compression level 8, the following often overlooked procedures can be applied to save some additional space...


The procedures in this guide can be automatically applied using the following Python script:

1. Remove embedded images


  • Will decrease compatibility with some hardware players.

Often images (covers, scans, etc) for an album are identical for all tracks and will be duplicated if stored embedded, therefore taking more space for no content gained.

Removing low quality embedded covers from tracks can free up enough space for a high quality cover.jpg file without the overall size increasing by too much compared to when the covers were embedded.

metaflac --remove --block-type=PICTURE $path

2. Remove excess padding


  • Will increase tagging time when embedding images.


Add a column to Mp3tag with $div(%_tag_size%,1024) KiB as the value to roughly see the padding size in KiB.

Padding is used to make editing metadata faster. It is added to the beginning of the file, after the existing metadata and before the audio data. When metadata changes the padding will be overwritten instead of the file being lengthened and rewritten.2

Some metadata editors replace removed embedded images with padding instead of shortening the file. This can leave megabytes of unused padding, which will likely never be used unless embedding other images later.

The recommended amount of padding is 8KiB, which is enough for editing vorbis comments.3

metaflac --dont-use-padding --remove --block-type=PADDING $path
metaflac --add-padding=8192 $path

3. Reencode hires with FFmpeg


  • Will decrease compatibility with some players.

Reencoding hires audio from libFLAC at compression level 8 to FFmpeg at compression level 12.

The FFmpeg encoder is better optimized for compressing hires audio than the official libFLAC encoder, therefore achieving higher compression rates at faster speeds. Its main feature being that it can compress silence, which is often found in high frequencies of hires audio.


  • Compression level 11 is advised for the best balance of speed and compression ratio.
  • Compression level 12, although much slower, is recommended if you have large amounts of hires audio.
ffmpeg -i $in -compression_level 12 $out

Slower and slightly worse than FFmpeg but better than using plain libFLAC at compression level 8 for this use case.

flac -V -8 -e -f $path

Salty | Created 2021/10/02 | Updated 2021/11/11