Next Previous Contents

10. Encoding from CD-ROM.

Again, check you will have enough drive space on your system.

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, "/mnt/mp3/tmp/cdda.wav");
$track = "$ARGV[1]/track".$count.".mp3";
$benc = system("bladeenc  /tmp/cdda.wav $track -br 256000");
$count++;

}
until $count > $ARGV[0];
exit;
}

else {
print "Usage cdriper [no of tracks] [destination directory]\n\n";
}

The main lines of interest are

$cdcap = system("cdparanoia", $count, "/mnt/mp3/tmp/cdda.wav");

This line calls the CD ripper, cdparanoia. Cdparanoia converts raw CD audio data to WAV format. 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.

Please note: The above script is very basic and has nothing fancy, like error checking. Improve at your leisure :)


Next Previous Contents