The howto is aimed at Debian users of any level who like to use the terminal, appreciate automation and like to hear the music the way it was on the original CD. I'm assuming you've used various CD rippers and know why you don't like them and are at least vaguely familiar with CDDB/freedb and audio tagging.
Objectives
1: Rip an audio CD, without loss of audio quality, to individual tracks.
2: Losslessly compress the ripped audio and number, name and tag the files.
3: Be able to use those files to burn an audio CD that sounds identical to the original and plays in any CD player.
4: Be able to do this on any GNU/Linux distribution and regardless of Desktop Environment/Window Manager etc.
5: Get it set up so you don't have to remember stuff!
The aim is to extract the digital audio, to store it using lossless compression to save disk space and to be able to burn a CD which sounds identical. The copy must have no audio defect. It must have the same gaps between tracks as the original if there are gaps on the original. If the original was gapless the copy must also play back identically on a regular home/car/personal CD player.
The aim of this howto is not to make a bit for bit identical copy of the physical CD. It is only concerned with the audio.
If you need to back up non-audio content or you worry about hearing the difference between 0.25 and 0.3 seconds of silence at the end or at the beginning of your audio CDs then this howto is not for you. You may be happier using cdrdao to make bin+toc and forgoing the space saving of lossless compression.
Advantages & Disadvantages of this Method
Disadvantages:
It doesn't deal with mixed-mode CDs (though it probably could be adapted to do so), or with anything other than the audio. If you want that Sony XCP copy protection and win32 rootkit preserved, or if you like to play your heavy metal CD backwards to hear messages from the devil in hidden sectors then this method won't work.
When you're ready to burn a CD from your archive you need to convert the flacs to wav. Luckily this is very fast and a no brainer, flac -d *.flac, but it might be considered an extra step.
One package needs to be compiled from source because the version in the Debian repos has a serious bug[edit: FIXED in Squeeze & Sid]. Fortunately it's a 100% straightforward install which I'll outline for those who are not used to installing from source. The bug has been reported in Debian's bug tracker, is already fixed upstream, and at some point the fixed version should arrive in Debian.
Advantages:
Instead of a toc+bin (cdrdao) cue+flac (K3B and others) or flac with embedded cue (abcde) this method gives you a set of individual flac files, numbered, named and tagged as you like, which are usable in your favourite audio player software, in your home audio flac player, and possibly even in your portable audio player. They can be used on any general purpose OS, such as Windows 98/ XP/Vista or Mac OS 9/OS X, without restriction or difficulty or compatibility issues.
You can even use this method to simultaneously produce mp3/ogg/aac files as well as the flacs relevant to this howto.
Lossless compression: You could use cdrdao to make a toc+bin and compress the bin with gzip or bzip2. But regular compression tools will only get you a file something like 90% the size of wavs or a cdrdao bin. Flac will easily compress wavs to about 55% of their original size (typically).
Normal burning methods introduce an ugly and unwanted gap between audio tracks. Yuk! Because this method uses a toc file and the CD is burned in dao/sao mode the resulting CD sounds just like the original. For CDs composed of individual tracks this doesn't really matter but many albums have the music flow from one track to the next with no audible break.
Everything is done using free(dom) software and there is no need for wine or win32/proprietary binaries. The tools are hosted in Debian main.
A powerful computer is not required. It doesn't matter if you run Gnome, KDE, Xfce, Ratpoison, Fluxbox or work from a serial terminal. This is all done in the terminal and is quite suitable for modest machines and machines which don't run X. But if you do have a multi-core beast the encoding can take advantage of multiple cores/threads, the number being set by the user.
Once set up, the user only has to remember a one word command 'ripit' to rip the CD. The process of producing an audio CD will be almost as simple.
The Tools
We're going to use Ripit for extracting the CD audio (ripping), Flac for losslessly compressing the audio and cdrdao for burning audio CDs.
As well as ripping the CD, Ripit also handles creating the directories for the resulting files, encoding the audio to flac, naming and tagging the files and producing a toc file. A toc is a Table Of Contents. It's the toc which allows cdrdao to write to a blank CD and have the tracks laid out exactly as they were on the original.
Install cdrdao and flac
Code: Select all
# apt-get install cdrdao flac
**edit July 2009 ** the ripit version in Squeeze is now fine as it is, no need to build it.
Ripit exists in Debian main as version 3.6.0-1 but it has a bug with CDDB lookups. This is fixed in the upstream version which can be obtained from http://www.suwald.com/ripit/news.php I use ripit-3.7.0-beta20090308 and recommend you do the same until a fixed version appears in Debian repos.
Install Ripit's dependencies:
Code: Select all
# apt-get build-dep ripit
Code: Select all
# make install
edit: a better method now that the new version is in Squeeze would be to download the source from Debian Squeeze repos using 'apt-get source' and then build a proper Debian package. I didn't check if all the depends can be met from Lenny, suck it and see.
Configure Ripit
Ripit works best when used with a config file ~/.ripit/config
With a config file in place you don't have to remember anything except the command 'ripit'
Code: Select all
$ mkdir ~/.ripit
Code: Select all
$ cp /etc/ripit/config ~/.ripit/
You might also prefer to set a different directory/naming scheme,
I very strongly advise you to look through and amend and use the original config file. It is extremely well commented and will show you what a versatile tool Ripit is. You can encode simultaneously to multiple formats, have the encoded files output to different locations according to their format, you can have remote machines do the encoding and many other options . But that's all outside the scope of this howto.
It's essential for the purpose of this howto that the following options are as seen in the following example:
cdtoc=1
ripper=1
paranoia=1
encode=1
coder=2
normalize=0
Don't worry about the unset options. The script expects to see them and their presence simply avoids seeing error messages.
This config is ideal for batches of CDs. 'eject=1' means the CD will be ejected as soon as the audio is extracted and 'loop=1' means ripit will just keep on going as long as you feed it another CD when you see the tray eject. You can change either of these options by changing the 1 to 0.
If you're happy to use the names and tags the CDDB lookup produces then you can also set 'interaction=0' and even 'verbose=0' and have the whole process run entirely silently and with no action needed except putting another CD in the tray and pushing it shut.
Code: Select all
cddevice=/dev/cdrom
output=
dpermission=0755
fpermission=
ripper=1
ripopt=
paranoia=1
ghost=0
prepend=2
extend=2
encode=1
coder=2
qualame=
lameopt=
vbrmode=
bitrate=128
maxrate=0
preset=
qualoggenc=3
oggencopt=
quaflac=5
flacopt=
quafaac=100
faacopt=
dirtemplate="$artist - $album"
tracktemplate="$tracknum - $trackname"
infolog=
lowercase=0
underscore=0
chars=
playlist=2
year=
comment=
utftag=1
CDDBHOST=freedb.org
mirror=freedb
transfer=cddb
proto=6
proxy=
mailad=
archive=0
submission=1
interaction=1
lcd=0
lcdhost=localhost
lcdport=13666
sshlist=
scp=0
local=1
verbose=3
eject=1
ejectcmd=eject
ejectopt={cddev}
loop=1
halt=0
nice=0
nicerip=0
threads=1
md5sum=0
wav=0
normalize=0
normopt=-b
cdtoc=1
So now you have ripit installed and configured it's time to rip a CD. I'm using The Beatles Abbey Road because it has many tracks which run seamlessly together with no gap. This makes it a good test because many software audio players, personal mp3/ogg players and CD burning applications will still fail to handle this well, even 25+ years after the audio CD and 20 years after the CD-R.
Code: Select all
$ ripit
You will be prompted to confirm the CDDB lookup looks good and be asked if you would like to change anything. Ripit will then produce a directory containing numbered, named, tagged flac files along with an .m3u playlist and a file named cd.toc
Keep the flac file names intact. You can edit the tags but if you change the actual filename you'll need to change the corresponding name in the cd.toc
Burn It!
The cd.toc is the key to a successful burn. You can see that it describes the filenames of the ripped tracks and contains some CD-Text information. The most important thing is that the files it describes are .wav files not .flac files, so before burning an audio CD those flacs will need to be decompressed back to .wav.
You can also see that there is some helpful info included:
Quite helpful! You don't even need to remember which application to use or how to use it, the reminder is there for every CD you rip.Use command >cdrdao scanbus< to detect device.
Assume the device found is: ATA:1,0,0, then, use e. g. command
>cdrdao write --device ATA:1,0,0 --speed 4 cd.toc< to burn the CD.
If you only have one optical drive then don't worry about the --device parameter, it should be automatically detected. The --speed 4 option reduces the write speed to a max of 4x. This is far less important than it used to be but is a safe default. On a modern burner with high quality media burning at maximum speed is no problem, in fact will produce fewer write errors than if the speed is very low. Your mileage may vary, if in any doubt stick to 4x.
If you have several devices then as root:
Code: Select all
# cdrdao scanbus
The great thing about cdrdao is that it writes the Disk At Once (dao, also known as sao - session at once), instead of writing it track by track. It will not introduce any artifical gaps between tracks. It's used by many CD writing applications such as K3B in KDE and EAC in Windows. It can be installed and used on more types of computer than you've likely ever heard of. It's ideal!
Assuming we're in the folder containing the flacs and the cd.toc we just need to decompress the flacs to wav:
Code: Select all
$ flac -d *.flac
Code: Select all
$ cdrdao write --device <your_device_here> --speed 4 cd.toc
Code: Select all
##### decode & burn flacs+cd.toc to CD ######
alias burnit='flac -d *.flac && cdrdao write cd.toc && rm *.wav'
Code: Select all
source ~/.bashrc
So now I can just run
Code: Select all
burnit
Moment of Truth
I play the CD in my old Sony CD portable. Track 9 "You Never Give Me Your Money" has a fairly quiet last 10 seconds with some ambient sounds and on the original CD merges seamlessly into track 10 "Sun King". If the ripping and burning process has introduced any artificial gap or pop or click it will be horribly obvious here......Success! It's perfect I also checked the CD in my Sony CDP-XE570 (a "proper" hi-fi CD separate).
Note about gapless playback of audio CDs on computers
Check your burned CD on a CD player not a computer!
Unfortunately playing a gapless audio CD gaplessly on a computer isn't so simple. Almost every CD capable media player/audio player can play back mp3 gaplessly (some still can't) but not audio CDs. Many (most!) portable mp3 players fail even at this. I booted into Windows to see how simple this is in Vista. I used a retail CD, not a burned copy. I was convinced Winamp would play it perfectly. No it couldn't! There was a small but distinct gap between tracks which should have flowed one into the next. Windows Media Player handled it perfectly, an ability it has had since WMP9 (comparatively recent) and foobar2000 was fine as well. How about in GNU/Linux? It's even worse. I didn't find a single player which can play a CD exactly as a CD player plays it. Rhythmbox can't, Kaffeine can't, VLC can't, Totem apparently can no longer play CDs at all with gstreamer or xine , Xine can't. It's claimed that Aqualung can do this but on my system it crashes as soon as it starts up When you see claims that a player is capable of gapless playback look again because it usually doesn't include CDs. I've even read bug reports where the user files a bug because his/her audio CD is not played back gaplessly and the developers/maintainers close the bug because they support gapless mp3 and refuse to acknowledge that gapless CD playback matters or is a different issue. VLC devs simply say it isn't an aim. Anyway at least we can rip and burn them without error
CD-Text
The combination of ripit and cdrdao will produce an audio with CD-Text if the CD is burned with a CD-Text capable drive. cdrdao should automatically use the best driver for your device. If you know that your burner is CD-Text capable but it's producing CDs with no CD-Text then please have a look at CD-TEXT Burning on Linux which may be useful. It solved the problem for me.
Summary
This rather long howto results in the following process for ripping, backing up and burning your precious collection of audio CDs:
Code: Select all
$ ripit
Code: Select all
$ burnit
edit: link to ripit updated