From the beginning when I started ripping CDs into FLAC files, I knew that notionally one could recreate an exact copy of the original CD from the FLAC if one wanted to, modulo hardware limitations, because the audio data is stored as a single untouched rip, and the original TOC is stored in the form of the embedded cuesheet. I never got around to figuring out how to do this, because I didn't have much reason: I have Squeezeboxes everywhere I listen to music, and they play the FLAC file.
Now, however, I have got a new car with a CD changer, plus I wanted to burn a copy of something for Beth. So despite not being able to find much of anything on Google, I found that this is actually dead simple:
#!/bin/sh # # flac2cd.sh - Recreate a CD from FLAC file $1. # Written 4 Apr 2007 by M. Dickerson (too trivial for a license, # don't you think?) set -e ME=`basename $0` AUDIO=`tempfile -p $ME` CUE=`tempfile -p $ME` FLAC=$1 metaflac --export-cuesheet-to=- "$FLAC" | sed s!dummy.wav!$AUDIO! > $CUE flac -f -o $AUDIO -d "$FLAC" cdrecord -dao --cuefile=$CUE rm $CUE $AUDIO
Obviously you need your cdrecord defaults set up right if you're going to use that literally, but that's left as an exercise to the reader.
So, the reason I didn't figure that out three years ago was that it was too easy. I was expecting to have to do all kinds of Godawful cuesheet arithmetic like I did for my assemble-random-tracks-into-CD script. It's kind of like the time when I couldn't figure out for half an hour how the hell you burn a CD on OS X, because it turns out, all you do is put in the blank CD and wait for magical things to happen.
04 Apr 2007 01:37 PT - persistent link - trackback - 2 comments

4171622

