
10.1 Command Line encoding
I've written a very simple Perl script that will rip and encode tracks from a CD.
#!/usr/bin/perl
if ($ARGV[0] ne "") {
$count = 1;
do {
$cdcap = system("cdparanoia", $count, "/mp3/cdda.wav");
$track = "$ARGV[1]/track".$count.".mp3";
$enc = system("bladeenc /mp3/cdda.wav $track −br 256000");
$count++;
}
until $count > $ARGV[0];
exit;
}
else {
print "Usage cdriper [no of tracks] [destination directory]\n\n";
}
Please note: The above script is very basic and has nothing fancy, like error checking or CDDB. Improve at
your leisure :)
The main lines of interest are:
$cdcap = system("cdparanoia", $count, "/mp3/cdda.wav");
This line calls the CD ripper, cdparanoia. Cdparanoia converts raw CD audio data to WAV format.
I'm using Cdparanoia, but if you wish to use CDDA2WAV, the command line would be:
$cdcap = system("cdda2wav", $count, "/mp3/cdda.wav");
The salient options are $count, which is the number of tracks to rip, and then the path for the outputted WAV
file. In my example this will go to a tmp directory on my MP3 SCSI drive.
The WAV file is then converted into a MP3 file using Bladeenc.
I've written this Perl script in order to rip a CD without having to rip and encode each track, and without
having to use the batch mode of Cdparanoia. This cuts down on free disk space needed as Cdparanoia's batch
mode will rip the whole disk, and take up anything upto 600 Meg.
The Linux MP3−HOWTO
10.1 Command Line encoding 15