Converting audio on your Mac/*xnix machine #OSX #flac #ffmpeg #linux
Most of the computer geekdom of my generation has trolled usenet at some point. Many of you still do. One of the many things you an easily find on usenet are lossless albums of your favorite music. I guess you could always rip the CD you already own
in your favorite music management software and call it a day. But perhaps you don’t have access to your CD, and want a really high quality version of your music; since you already own the cd (*snicker*), you probably won’t feel too guilty to download the pre-ripped music from the internet
Anyway, the most likely lossless format you will find on usenet is flac. Now if you use iTunes like me, you know that iTunes doesn’t support flac, rather Apple has their own lossless format, ALAC. So the question then becomes how do you get your recently downloaded copy of Metallica’s Re-Load album in flac format in iTunes – presumably in ALAC? You need to transcode your flac files into ALAC. To do this, there are some utilities out there that will do it for you. Two GUI apps are Max, and XLD. There’s also the old school way of doing it, using FFMPEG. FFMPEG is not pretty, as it’s command line, but it will pretty much convert and transcode anything, and with some simple, or even clever bash scripting, you can get it to do what you need done. I complied ffmpeg from source on my Macbook (you need the developer tools installed), and you’ll need to compile YASM as well, but this is pretty easy and straightforward. Then finally compile ffmpeg, and install it. Then you can use a really simple one-liner bash script to convert all the flac files in a directory to ALAC encoded .m4a files. A version of the script could look like this:
#bash script to convert flac to apple lossless (alac) in the current directory
for i in *.flac; do ffmpeg -i “$i” -acodec alac “`basename “$i” .flac`.m4a”; done;
I wrapped this in a file called flac2alac, and put it in /usr/bin. Just remember to chmod a+rx your “wrapper” before trying to execute, otherwise you’ll have to type in some kind of longer, annoying string
Now you should be able to just drag and drop your .m4a files from the directory where your flac files reside into iTunes. The conversion goes super fast, and you’ll see some output information during the conversion.
Enjoy!