1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to Dump an Audio CD to ISO

Discussion in 'Howtos and FAQs (Moderated)' started by noz, Oct 26, 2010.

  1. noz

    noz New Member

    Messages:
    41
    Thanks Received:
    11
    For working with data CDs, see a great [thread=1195]thread[/thread] by killasmurf86. It also has burning audio CDs and cdda extraction. If you're interested in backing up an audio CD to an image, let's get started.


    Why bother archiving your music by encoding each and every track with a lossless/lossy codec knowing that someday there's going to be something with better compression/quality than those currently available? If you're OCD about it like I am, you'll just end up re-encoding your entire collection. The ideal way to backup a music collection is to just dump the entire disc to an image. There are several benefits to having an image.

    • Easily burned to make a close, if not exact, copy of the original disc.
    • It's mountable. Play tracks as if physical CD was inserted.
    • Never worry about codecs. Rip the disc once and forget about it.
    • No encoding means backing up your music is much faster.
    • The audio will be lossless, obviously.

    There's clearly one disadvantage, however. The dump will represent the CD, meaning it'll be uncompressed and can take up to 650MBs or more of hard drive space. But, really, who cares. Who doesn't have an abundance of hard drive space these days when a terabyte only costs $60?

    Okay, so let's get something cleared up right now. There is no way to dump an audio CD to an ISO image. WHAT!? An ISO image contains a CD's data contents and file system. The problem comes from the fact that audio CDs have no file system. There's a lot of misinformation suggesting that you "just use dd", which doesn't work. But, you said you'd show how to dump an audio CD to ISO! Sorry, I lied. However, I will show you the next best thing: Dumping an audio CD to BIN; an image format much like ISO.



    Tools
    BSD, UNIX, and Linux users should have no problem obtaining these tools. Windows users, on the other hand, may have to use Cygwin or compile these tools on their own if a prepackaged binary doesn't exist. I will not go into how to get these tools running on Windows, nor will I go into detail about how to use these tools beyond what I will explain below, as that's not the purpose of this tutorial.




    Doing it
    To create the BIN:
    cdrdao read-cd --device ID --read-raw --datafile NAME TOC

    • ID should be replaced with your CDROM device ID. You can find out the ID by inserting a disc into your drive and running cdrdao disk-info. It's typically three comma separated integers. My CDROM ID is 0,0,0.
    • NAME is the name you want for the resulting BIN image. e.g. xyz.bin
    • TOC is the name you want for the resulting TOC file. This is just a plain text file describing the disc's layout. e.g. xyz.toc
    • By default, cdrdao runs at full paranoia mode. What's paranoia? Don't worry about it.

    After running the command you should see cdrdao doing its thing on the screen. If all goes well, a message will appear indicating successful reading of toc and track data. You can ignore the message about sub-channels having CRC errors. If you want you can look through the TOC file with a text editor.



    Playing It
    You now have a dump of the audio CD. The BIN can't be mounted for the same reasons an audio CD can't be dumped to ISO. Luckily, mplayer can play the BIN directly, but you'll have to do a conversion first.

    To convert the BIN:
    dd conv=swab if=ORIGINAL_BIN of=BIN

    • ORIGINAL_BIN is the BIN we got from cdrdao. e.g. xyz.bin
    • BIN is the name you want for the converted BIN image. e.g. xyz_swap.bin

    To play the BIN:
    mplayer -demuxer rawaudio BIN

    • BIN is the converted BIN. e.g. xyz_swap.bin

    You can delete the original BIN and rename the converted BIN so it has the same base filename as the TOC. If you want the original BIN back, just convert the converted BIN. The TOC can be deleted as well, but it can be used for useful things. If you delete it you can get it back with cdrdao's read-toc mode. See the man page.

    Note: Playing the BIN without conversion will give you an earful of static.



    Burning It
    Want to make a copy of the audio CD? There’s no need to take the original out of its jewel case.

    To burn the BIN:
    cdrdao write --device ID --swap TOC

    • Again, ID is your CDROM device ID.
    • TOC is the TOC file that was generated when the BIN was created.
    • Burning the converted BIN will require the --swap option.

    If you get an error mentioning CD-TEXT and burning fails to start, convert the TOC to a CUE.

    TOC to CUE:
    toc2cue TOC CUE

    • TOC is the TOC file that was generated when the BIN was created.
    • CUE is the name you want to give to the CUE sheet.

    Cycle the tray (open and close the CDROM drive) and try burning the BIN again using the CUE sheet instead of the TOC. It should be rainbows and unicorns now.

    ProTip: The --simulate option comes in handy.



    Ripping It
    Do you need to convert the individual tracks to a format like mp3?

    To rip the BIN:
    bchunk -v -w BIN CUE BASENAME

    • -v: this gives detailed output.
    • -w: extract tracks to WAV format.
    • BIN is the converted BIN. If you're using the original BIN, you need to include the -s option.
    • CUE is a CUE sheet. bchunk doesn't work with TOC. See above on how to convert TOC to CUE.
    • BASENAME is the name you want for the resulting WAV files. e.g. xyz will result in xyz01.wav, xyz02.wav, etc.

    You now have a directory of all the tracks in WAV format that you can convert to whatever.



    Shortcomings

    Because the BIN has to be played directly, you may or may not have realized by now that there's no easy way to play a single track nor is there an easy way to skip forward or backward trackwise. This is why the second benefit is gray. There's a workaround but it's a bit of a hassle. I guess it's not really a workaround then... I'm sorry.

    mplayer supports two options: -ss and -endpos. They'll let you start and stop anywhere in the BIN. The TOC file contains the start times of every track as well as its duration. The line you want to look for in the TOC is the one that starts with "FILE".

    Example:
    FILE "xyz.bin" 26:54:00 03:20:15

    Here we see the start time is 26 minutes 54 seconds with a duration of 3 minutes 20 seconds. The value after seconds is the frame (0-74), but mplayer uses the hh:mm:ss.ms format. You can convert the frames to milliseconds, but there's really no need to be that accurate. Just use seconds as the lowest common denominator. Also, everything is optional except for the seconds.

    To get mplayer to play this track you'd use this command:
    mplayer -demuxer rawaudio -ss 26:54 -endpos 3:20 xyz.bin

    Don't let the name of the -endpos option fool you. It's poorly named because you're actually specifying the duration not the end position.

    You can seek forward as much as you'd like and you'll stay on this track (if you have mplayer set to loop infinitely), but if you seek backwards you'll seek into previous tracks. It'd be nice if it wrapped around both ways, but ehh.



    Solution (probably!)
    I want to write a program that will implement playing specific tracks as well as seeking forward and backward trackwise. It will very much be like what I think mplayer's cue:// should do. However, I'm already pretty happy with how things are working right now, so don't hold your breath because I might never get to it.



    Decepticons
    There are several ideas that might pop into your mind that you think might work but it really doesn't.

    You might think you don't have to use a converted BIN because mplayer has options like -af and -format that lets you specify endianness. Doesn't work. Why? I have no idea.

    You might think you don't need to do that stuff I described in the workaround section because mplayer supports the cue:// protocol and you can just play tracks easily by converting the TOC to CUE. Doesn't work. What the hell does cue:// do anyway? It clearly parses a CUE sheet but seems to do nothing else. Perhaps it's not fully implemented?

    You might think you can skip the dd step by using the --swap option in cdrdao to get a converted BIN directly. Nope. That option only works in one direction, from BIN to disc, not disc to BIN. (You COULD use cdparanoia but you'd have to use cdrdao at some point anyway, and cdrdao + dd just seems simpler to me than cdrdao + cdparanoia.)

    You might think bchunk can convert your BIN to a mountable ISO because you read the description in the man page. You'd be disappointed. bchunk will only convert a BIN to ISO if the BIN is from a data disc. If the BIN is from an audio CD, the only thing you'll get are raw audio files.

    I think there were a few other deceptive things I came across while figuring all this stuff out, but I can't remember and it's not really important.



    Special Thanks
    Dallas E. Legan II - Never would I have guessed to swap bytes.
     
  2. Carpetsmoker

    Carpetsmoker Member

    Messages:
    959
    Thanks Received:
    144
    Call me a simply guy, but doesn't this work exactly the same?

    Code:
    # cat /dev/acd0 > image.iso
    # mdconfig -at vnode -f image.iso
    


    You can then play it with mplayer or cdcontrol.
     
  3. noz

    noz New Member

    Messages:
    41
    Thanks Received:
    11
    You can't cat or dd an audio CD, and you can't mount or mdconfig->mount an image created from an audio CD.
    Here's the output when I try. You'll get similar output from mount and mdconfig->mount.

    Code:
    $ cat /dev/cd0
    cat: /dev/cd0: Device not configured
    
    # cat /dev/cd0
    cat: /dev/cd0: Device not configured
    
     
  4. expl

    expl New Member

    Messages:
    664
    Thanks Received:
    121
    Carpet > You can't create an ISO file or mount an audio CD since it does not have a file system(ISO 9660/UDF).

    Anyway, I just use dd to dump the ATAPI track devices to raw track files then just tar.bz2 them for backup storing. And to recover(burn) the CD I use 'burncd' that already comes with the base system. No ports are needed for the whole process.