Convert & Split FLAC files

I had some .flac files that needed to be converted for iTunes, but I couldn’t find a standalone app for OSX, so using my CLI-fu, I managed to do the job.

For reference, this is how I proceeded (you’ll need Homebrew for this).

Install the following packages:

  • cuetools (to print the breakpoints from a cue or toc file)
  • shntool (to split a single-file album image to a file-per-track album)
  • flac (to read .flac file format)
  • ffmpeg (to do the conversion)
  • id3v2 (to read and write id3 tags)
  • mmv (to change the name of files, see below)

mmv is not really needed, but this tool is invaluable, you should use it.

brew install cuetools shntool flac ffmpeg mmv id3v2

First, split the flac file in tracks:

cuebreakpoints album.cue | shnsplit -o flac album.flac

Add the tags to the tracks album.cue split-track*.flac

Rename the files (why? because!)

mmv 'split-track??.flac' "Track#1#2.flac"

Concert the .flac files to mp3 VBR

(for FILE in Track*.flac ; do ffmpeg -i "$FILE" -codec:a libmp3lame -qscale:a 1 "`basename "$FILE" .flac`.mp3" || break; done)

You can now import the *.mp3 files in iTunes.

I couldn’t find a way to convert the .flac files to .m4e AND keep the metadata so I used mp3. If anyone knows a way, let me know. I also read that the ffmpeg aac converter wasn’t as good as iTunes, so I don’t think it’s really worth it.

Leave a Reply

Your email address will not be published. Required fields are marked *