home :: hacks :: flac :: flac2cd

RSS 0.91 feeds Subscribe and save over 75% off newsstand price!

car - 9
games - 2
hacks - 21
  flac - 4
  photo - 5
  slim - 3
journal - 153
misc - 5
news - 9
pomona - 2
rants - 6

For the biographers:

2005 - 2006 - 2007 - 2008 - 2009

Now playing

Décollage (Cristobal Paz & Leo di Giusto remix)
from Remixed by Bajofondo
at Monday, December 14, 2009 12:51 AM

How this works

Hot Live Webcam

Yes, really.

Recently from Google

How this works

Contact me

mikey@singingtree.com
4171622
mdickers47
mike.dickerson@pomona.edu
pomonamikey
wii number7808 7239 7724 0213
blackberry pin204db8e4

On Notice

  • The sun
  • Librarians
  • Blue
  • Purple
  • David Gray
  • Whirlpool
  • Taco Bell

As seen on The Colbert Report.

This site does not represent my employer.

May look horrible in Internet Explorer.

blosxom logo   Creative Commons License

gotta
knock
a
little
harder

obstrepero.us banner
obstrepero.us mistakes you can learn from

How to turn a crazy FLAC back into a CD

filed under: /hacks/flac

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

Copyright © 2005-06 Michael A. Dickerson