Test FLACs for corruption
A recent email from a bliss user reminded me of the need to cover a topic I'd long considered: FLAC corruption. I'd previously discussed fixing corrupt MP3s and I'd always had it in mind to cover other file formats, but until now I'd deferred this.
Writing this up makes all the more sense when you consider that my advice is always to rip to lossless and of the lossless formats, FLAC is my preferred default choice (unless you live in/endure iTunes land, in which case it's Apple Lossless).
What could possibly go wrong?
Plenty can go wrong. Unnoticed problems during the encoding process (encoding is the conversion of audio in a source format into, in this case, the FLAC format), problems introduced when tagging files, virii, hard disk failures and more can all affect your files. It's unlucky when it happens, but when it does, unless you have backups, there might be no other way back.
But what's the problem with that? That's a good question; you can often have a music library with a good amount of audio corruption and not notice a thing. However, in some cases, some music players can fail to play back the audio and even crash when the audio is played. It's best to keep on top of this.
The good news is that FLAC makes checking files easier than many other formats. FLAC includes a checksum within the audio stream. A checksum is a small amount of data derived from a larger amount; in this case a checksum is produced of the audio stream and stored in the file. This means that a subsequent checksum can be generated for the audio stream at a later date, and if the stored and new checksums differ then the audio stream must also have differed.
This error checking "built in" to FLAC means that the tools to perform FLAC testing are built into FLAC itself, with an option in the command line encoder. In addition there are plenty of free tools that offer a GUI should you not want to use the command line.
Testing FLACs on Windows
It's possible to use the FLAC command line as described below under Testing FLACs on OS X / Linux. If you really don't want to use the command line, though, there is a free tool called FLAC Frontend which you can use to perform testing.
First, download the Windows installer and install FLAC Frontend to your machine. Then run the app and you'll get:
Add the files you want to test. Click Add files and then use the standard file browser until all the files you want to test are selected (you can also use drag and drop):
Now click Test for errors and the FLAC command line will be executed for you, testing the files you selected:
From there you can work out which, if any, of your FLACs need attention. Re-download, re-rip or restore from backup!
Testing FLACs on OS X / Linux
I'm a fan of using the command line. So, open up Terminal (OS X) or your equivalent terminal app for Linux. Here's the code suggested by my correspondent I mentioned at the top of the post:
find ~/Music -type f -name '*.flac' | while read file; do flac -wst "$file"; done
~/Music" with the location of your music files).
This command finds all FLAC files from a root point in your file system and applies the
flac -t command to each one, to test them. The
-ws options are also added so that only errors are reported (otherwise
flac is silent) and all warnings are reported as errors, to make sure we see all the problems.
Edit (29/6/2016) Changed to a version that allows spaces in filenames!
I hope that helps you find any corrupt FLAC files!
Thanks to marfis75 for the image above.