In my last post I showed how to convert flac to mp3 using the lame encoder. In this post, I’ll show how to convert your flac audio files to ALAC (Apple Lossless Audio Codec). The main reason to convert flac to alac is to preserve lossless audio files in iTunes and even play them on your iPod/iPhone, natively. All that you need is to install ffmpeg, via Homebrew:
$ brew install --use-gcc ffmpeg
This can take a couple minutes as it installs all of its dependencies and compiles. Note that the --use-gcc flag is used because as of this writing ffmpeg does not compile with LLVM, and there are several issues already open about it.
And then to change a directory full of flac files to alac, run this bash one-liner:
$ for file in *.flac; do ffmpeg -i "$file" -acodec alac -vcodec copy "`basename "$file" .flac`.m4a"; done;
This process didn’t take long at all. It appears that there isn’t any transcoding happening, more likely just a repackaging of data.
I found several other solutions of interest like Fluke to play flac files in iTunes but you would still need to convert them inside iTunes to alac, and, as of this writing, Fluke does not work with iTunes on OS X 10.7 (Lion) in 64-bit mode. You can how ever bypass that by running iTunes in 32-bit mode.
Another tool I found was XLD but I did not test this option since the ffmpeg option was so simple and easy.
Last Edited: January 13, 2021
Derek J Bender