Dugan Chen's Homepage

Various Things

Burning gapless audio CDs in Linux

Burning gapless audio CDs from the Linux command-line is easy.

Let’s say you have a directory full of .FLAC files. Then all you’ll need to do is:

  1. convert the files to CD audio format
  2. create a description file
  3. burn the CD
  4. test it

The following paste-worthy lines are all you need.

find *.flac -exec sox {} `basename {} .flac`.cdda \;
for file in *.cdda; do echo "TRACK AUDIO" >> toc; echo "FILE \"$file\" 0" >> toc; done
cdrdao write toc
mplayer cdda://1

You’ll have to change “.flac” to “.mp3” if you’re burning a directory of MP3s. You might also have to pass the –device option to cdrdao. The rest should not need to be changed.

UPDATE: A reader has written in to say that the FLAC->CDDA conversion can be speeded up like this:

find . -type f -name *.flac | parallel sox {} {.}.cdda