Saving Space with FLAC
There is no reason to store music in WAV format, except for compatibility when working in music production or DJ'ing.
FLAC (Free Lossless Audio Codec) is a free, lossless, well documented, well supported and open source audio codec. When using FLAC, 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.
The following often overlooked procedures can be applied to save some additional space...
- Well supported common lossy audio formats (like MP3, AAC, OGG, OPUS, etc) should not be converted to lossless formats to avoid degrading the audio quality.
- Uncommon lossy formats (like proprietary formats from game rips) can be converted to lossless formats to ensure compatibility with players.
The procedures described below can be automatically applied using the following Python script: flaccare.py
Proper precautions should be taken when performing batch operations on a media library:
- Keep a restorable backup copy of the library.
- Run operations on a test copy of the library first.
- Run operations in batches. (e.g. depending on the library structure, per letter or genre folder)
1. Encode with libFLAC
Since version 1.4.0, libFLAC has much improved compression ratio for normal and hires audio.
2. 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.
3. Remove excess padding
Add a column to Mp3tag with
$div(%_tag_size_appended%,1024) KiB as the value to 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
Salty | Created 2021/10/02 | Updated 2022/10/29