May 20, 2012

Audio mass encode on Synology NAS (FLAC to MP3)

Quick Sunday hack while waiting for the damn rain to stop :-(

 I was looking for an easy solution to mass-convert my music library from FLAC to MP3 (because iP*ds don't play FLAC...). Don't worry, I'm still keeping the FLACs for home playing :)

My library is stored on a Synology NAS and the prospect of transferring all of it back and forth through my LAN didn't sound really attractive, so I figured maybe I could find a way to reencode everything on the NAS itself, using whatever tools are available on a vanilla box (i.e. no additional package).

And voila!

This script is pretty self-explanatory: just ssh to your box and launch the script at the root of the music library. It will go sequentially through every subdirectory and each FLAC file will be encoded to a 320kbit MP3 file, saved in the same directory under $newbasedir. Existing ID3 tags are preserved by ffmpeg.

Of course, this will not only run on Synology, but also on any Unix box with ffmpeg... although in this case, I'm sure there are much better solutions :)

Good to see that I can still write a few lines of script. Hope you like it!