Sep 13

Ripping CDs on Ubuntu

Category: Linux,multimedia   — Published by tengo on September 13, 2010 at 7:39 am

Coming from Window, audiophile users probably miss EAC (exact audio copy) as a reliable application to rip CDs as accurate as possible. Others relied on dbpowerAmp and it's network of CD track checksums to verify what has been read from a CD by the disk drive.

On Ubuntu Linux, mostly Rhythmbox or banshee will take over as soon as you insert CD into the drive but as good as they are to do quick copies of your audio, paranoid users might miss the verbose error checking and transparency of the process they know from EAC etc.

Extracting with cdparanoia (on CLI and with ripperx GUI)

After shutting down the nice GUIs and looking around the Linux world of CLI tools, most audio enthusiast will come to cdparanoia, a helpful tool that tries really hard to exactly copy what is on a CD.

A common cdparanoia CLI workflow would be to:
1. Get basic info about where your drive is mounted and what's on the CD in it with: cdparanoia -vsQ
2. Make a target directory for the extracted tracks: mkdir SomeCD && cd SomeCD
3. Extract the whole disk with default parameters: cdparanoia -B

A common workflow to convert the extracted .wav files to flac would be:
1. Convert all the extracted .wav files to .flac and delete the origin files: flac --best --delete-input-file -w *.wav

If you prefer GUI tools that wrap cdparanoia, take a look at this list.
grip (only available via ppa as of 12.04) is one frontend, ripperx another

One workflow utilising ripperX as frontend would be:
1. Make sure ripperX is installed: sudo apt-get install ripperx
2. Fire it up, and do you first config, you probably want to make sure cdparanoia is configured as backend, in General check "Keep WAV files"
3. Adapt file naming to your liking: go to Config > General and Config > Files, one sane string is "%a -  %# - %s" (Artist - TrackNo - Song), all strings here
4. Select "Rip to WAV", click "CDDB" to populate track names
5. By default, ripperX will create a subdir for you
6. Note that applying accents in the track names and cd title doesn't work, utf8 support seems broken
7. Note that ripping to WAV will result in named files but without any ID3 or similar tags
8. Click "GO"

Metadata can then be added by utilizing GUI tools like MusicBrainz's picard or a slew of CLI tools or scripting...

Converting WAVs to MP3s, FLACs to M4A

Best way to do it is via CLI with lame. This page has a good section about quality settings, if you are unsure how vbr vs. fixed rate mp3s compare: hydrogenaudio recommendations.
By default, lame is a per-file tool, so it can't process an entire directory of mp3s. However, with a bit of shell scripting you can do it:

for f in *.wav; do lame -V 2 "$f" "${f%.wav}.mp3"; done

This encodes all WAVs with VBR setting V2 (averaging to 190kbps, roughly) to mp3s.

Or convert the resulting FLAC files to .m4a files (aac in an MPEG-4 container, as bare aac alone has no facility to store metadata tags):

$ for f in *.flac; do avconv -i "$f" -strict -2 "${f%.flac}.m4a"; done

SCSI cdparanoia problems solved

When I tried using cdparanoid, I stumbled over my exotic cdrom drive setup. I've got my drive attached to the box via a IDE to USB adaptor, as the drive resides in an external box. This leads to the drive beaing registered with the system as /dev/sr0.

When cdparanoia does it's extensive drive lookups, it always oversaw this location and told me

No cdrom drives accessible to user found.

Very annoying!
Further, simply mounting the drive in one of cdparanoia's known locations didn't help either as you can't mount a drive with an audio CD  - there is no real filesystem on it - and mount will complain.

The solution is to creat a link to this "non-standard" CDROM/DVDROM drive location with

sudo ln -sf /dev/sr0 /dev/cdrom

After that you can use the above workflow to extract audio.