Wednesday, July 9, 2008

Converting a CD to FLAC Files (Mac OS X)

I have the following software installed:


The following process would be significantly simpler if one app provided both a decent rip log and metadata lookup.

There is no point being concerned with the quality of the audio unless you know if there were errors introduced in ripping the data off the CD. xAct shines here. Max does not provide enough details, although there is a ticket open with the developer to fix that.

Max does well with metadata. xAct is poor.

The process
$TMP and $GIT_REPO represent file paths, e.g. $TMP=$HOME/tmp
  1. Rip CD using xAct, saving files to $TMP/xAct. [1]

  2. Save xAct output to $TMP/xAct/xAct.rip.log

  3. Check the log for errors. After the first section of the log file, search for each occurence of 'track' to quickly find the right spots to check.

  4. Open Max. It will automatically detect the CD and pop up a window. Check the metadata and fix/enter it if necessary.

  5. Download album art. Press Command-D in Max. It will automatically search. Choose one of the listed images (assuming some are found). [2]

  6. Rip to FLAC using Max (I have set my output directory to $TMP)

  7. $ mkdir $TMP/max-rip
    $ mv $TMP/[Artist]/[Album]/*.flac $TMP/max-rip

  8. Convert $TMP/xAct/*.wav to FLAC using Max.

  9. $ mv $TMP/*.flac [Artist]/[Album]

  10. Ensure that all files in [Artist]/[Album] have the same names as those in max-rip. Assume max-rip as correct - we set the metadata in step 4. The following should identify if there are any differences:

    $ cd $TMP/[Artist]/[Album]
    $ ls -1 ../../max-rip > /tmp/ls.txt; ls -1 | diff /tmp/ls.txt -; rm /tmp/ls.txt

  11. Generate FLAC fingerprints:

    $ metaflac --show-md5sum *.flac > ffp.txt
    $ mv ffp.txt $GIT_REPO/flac fingerprints/[Artist] - [Album].ffp.txt

  12. $ mv $TMP/xAct/xAct.rip.log $GIT_REPO/log/[Artist] - [Album].xAct.rip.log

  13. Transfer tags from the files ripped with Max. I use the following script:
    find . -name "*.flac" | while read FILE
    do
    FIXED=`echo $FILE | sed 's/ /\\ /g'`
    metaflac --export-tags-to=- "../../max-rip/$FIXED" | metaflac --import-tags-from=- "${FILE}"
    done
  14. Transfer album art (if it was found and used in step 5) from the files ripped with Max. I use the following script:
    metaflac --export-picture-to=cover.jpg ../../max-rip/01*
    ls -lh cover.jpg
    echo "Adding album art ..."
    find . -name "*.flac" -exec metaflac --import-picture-from=cover.jpg {} \;
    rm cover.jpg
  15. Move $TMP/[Artist]/[Album] to music library

  16. rm -rf $TMP/xAct $TMP/max-rip

  17. In the root directory of the music library:
    $ md5deep -rl * | sort > $GIT_REPO/md5deep.txt

  18. Check the $GIT_REPO changes and commit


[1] See FLAC Encoding Guide for mac for a details on using xAct.

[2] At this stage I do not know the correct way to handle album art, as the players have a variety of ways of dealing with it. For the moment, I have chosen to store it in the metadata of each file.

No comments: