Convert ALAC to aac 128k with all metadata intact

I have about 300 gigs of ALAC files (m4a container) with well groomed metadata, album art, etc. (Original source: CD rips with dbPowerAmp). I want to convert my music library to 128kbps AAC (still m4a) to save on hard drive space on a small server.

The solution I'm hoping for is a command line based option using ffmpeg or the like. There's nothing Mac-specific about doing it that way but given it's all Apple codecs and I'm doing the conversion on a Mountain Lion box I thought I'd ask here. I can manage most of the shell scripting myself but I don't know ffmpeg well enough to be sure that it retains metadata and album art.

I've done a conversion in the past with iTunes 10; there's a trick where you manipulate "Convert higher bit rate songs to 128 kbps AAC". But the conversion quality is not sufficient. iTunes rewrites filenames in various circumstances, particularly when any non-ASCII is involved. Also it takes more than 20 hours to do the conversion and there's no clean way in iTunes to keep track of what's converted if the batch is interrupted.


I realise this is not a command line solution, but I use Max to convert FLAC and ALAC to AAC and MP3 files, and it keeps the metadata intact.

http://sbooth.org/Max/

Its a very lightweight app.

There are also download links and instructions on the site for how to build the app from the source, so maybe the moving parts of the ALAC-to-AAC with metadata conversion could be discerned from there.

Also, before compressing lossless rips to save space, maybe give TuneSpan a try, and put your lossless audio on external storage?

http://tunespan.com/#show_demo


This seems to preserve most common tags but not cover art (edited to add -vn):

ffmpeg -i alac.m4a -vn -acodec libfaac -aq 110 aac.m4a

-aq 110 is about 130 kb/s for normal music files. -aq 400 would be about 270 kb/s.

If you have 4 cores, this runs up to 4 parallel processes:

find . -name \*.m4a | parallel ffmpeg -i {} -vn -acodec libfaac -aq 110 {.}-aac.m4a