Converting ALAC Apple Lossless to 128kbps AAC m4a

I’ve got all my music in fancy Apple Lossless files. CD quality, but big; 500 megs a CD? I’m importing to a small hard drive and need to resample to 128kbps m4a. I looked at a lot of options, including shell scripts and ffmpeg. But I decided to just let iTunes to do the work; I trust it to handle metadata and album art better than something I cobble together myself.

I ended up following these instructions more or less. Here’s what I did:

  1. Start with an empty iTunes library
  2. Choose a new directory for my iTunes Media folder location in Advanced Preferences
  3. Make sure “copy files” and “let iTunes manage library” were unchecked in Advanced Preferences
  4. Open all my ALAC files from a read only remote file server, so iTunes now knows where all my music is.
  5. Go to iTunes preferences and change the CD import options to AAC encoder. Despite the horrible UI, that’s the option used when encoding all music, not just CDs.
  6. Select all my music. Right click, choose “Create AAC Version”
  7. Wait patiently for conversion.
  8. Press “delete”; this will remove the selection from my library, which still points to all the ALAC originals and not the AAC copies.
  9. The AAC copies are now in the folder I specified in step 2. I think these are safe, complete versions, although I haven’t verified that metadata (particularly album art) is in those files and not just in iTunes’ database. (Update: the album art does seem to be in the new files.)

The main problem with this process is step 7 needs to work correctly. If it’s interrupted then just resuming what wasn’t finished is a PITA. Not great when it will take many hours. Also step 4, the initial import, takes a very long time. I don’t think iTunes is actually reading the entire file, at least I hope it only reads a metadata header, but I’m not positive.

Update guess what, step 7 didn’t work correctly! The machine went to sleep on me, and between that and the Screen Sharing login I was using I ended up having to reboot. It wasn’t too hard to figure out where to resume encoding; you can quickly tell from the Bit Rate column which songs haven’t been re-encoded (or spot the dupes) and I hadn’t changed the sort order. So now I’m encoding the second half of my library. Step 8 won’t work now, no selection intact, but I think I can either use Bit Rate to find the original ALACs to remove or else unmount the disk and have iTunes remove the missing songs.

Update 2 36 hours of conversion later and it’s close to done, but not complete. I think it’s getting slower as time goes on but I’m not positive. There’s no major memory leak, don’t know what’s up. iTunes is a piece of garbage. One more problem with letting it do the work; iTunes names files its own way, it doesn’t copy the source filename. So there’s no real way to just diff directories to see what’s incomplete. I finally had to abort the import about 3% from complete; I may have to write a custom tool just to find what’s missing :-(

Update 3: I decided to redo the conversion and asked on Stack Exchange how best to do it. Glad I did; someone pointed me to Max and it’s doing the job well. It handles all metadata correctly (including Unicode) and it’s fast thanks to being multithreaded. I’ve got 8 encoding threads running on my iMac and have maxed out the hard drive bandwidth. Still no solution for resuming an incomplete batch job but since the whole thing only takes 3.5 hours now, I can live with it.