Parallel Transcoding from FLAC on Linux

Using find and xargs can dramatically speed up the transcoding of large collections of FLAC files to formats like Ogg Vorbis or MP3.


Here are the commands I used to convert a shitload of FLAC files to Ogg Vorbis.

find ${HOME} -name '*.flac' -print0 | xargs -0 -n 8 -P 8 oggenc -q 9
find ${HOME} -name '*.flac' -print0 | xargs -0 -n 8 -P 8 rm

For some reason I had gotten it into my head to rip my entire CD collection to FLAC (Free Lossless Audio CODEC) so that I could have maximum fidelity digital music. After all, I had disk space out the wazoo and nothing better to do than swap CDs.

However, it’s occurred to me that being a middle-aged metalhead I’m just wasting disk space. There might be a quantifiable difference between FLAC and Ogg Vorbis encoded at maximum quality, but it’s not one I can hear with a decent set of wired headphones.

There’s no sense in ripping everything again, though. Not when it’s possible to transcode FLAC to Ogg Vorbis. However, I’ve got a lot of files and I don’t want to spend weeks transcoding tracks piecemeal.

Fortunately, as Adam Drake writes: command-line tools can be 235x faster than your Hadoop cluster. Not that I’ve got a Hadoop cluster at home. Probably a good thing, because if I did and Catherine saw the resulting power bill she’d probably have kittens.