BSD DevCenter

oreilly.comSafari Books Online.Conferences.

We've expanded our LAMP news coverage and improved our search! Search for all things LAMP across O'Reilly!

Search
Search Tips

advertisement

Listen Print Subscribe to BSD Subscribe to Newsletters
Big Scary Daemons

Ripping MP3s

09/13/2001

I never got into the MP3 thing. The wholesale swapping of music online just makes fair use look bad. Plus, my home computer is comfortably situated in the nexus of several speakers attached to a high-quality home stereo. Why would I trade several hundred CDs and high-fidelity recordings for tinny computer speakers? However, as my work schedule shifted, I found myself having a greater need for lugging CDs to and from work. This seemed to be a decent application for MP3s.

Ripping CDs to MP3 is a fairly straightforward process that is ripe for automation. You need the artist, title, and song list from each CD. This information is freely available online through a number of online music databases. CDDB is the best-known example. Armed with this information, you copy the audio track to your hard drive using a "ripper." FreeBSD includes several different rippers, and the core OS actually has the ability to rip audio tracks. You then "encode" the ripped file to MP3. Finally, you label the MP3. There are several other trivial functions that can be added to this process to make life later a little simpler, such as writing .m3u index files, but these are the basics.

My goals were simple: to drop a disc into the laptop's CD tray, type a command, and walk away until the rip finished. It can't be that hard; people barely capable of booting their computers can do it. It certainly wouldn't be worth a column.

Thus began a week-long saga of trying to rip CDs on FreeBSD. My eventual success shows some of the pitfalls of free software, and how to avoid or solve them.

A quick search of the FreeBSD ports tree led me to /usr/ports/audio/ripit, which is a basic Perl script that automates the ripping, conversion, and labeling process. "This looks perfect," I thought, and installed the port. It installed a few dependency ports, and I was ready to go.

# ripit.pl
Getting CDDB info...
Fatal: Cannot open configuration file "/usr/X11R6/lib/X11/xmcd/config/cdrom".

Fatal: Cannot open configuration file "/usr/X11R6/lib/X11/xmcd/config/cdrom".
TOC ERROR: No Artist Found at /usr/local/bin/ripit.pl line 297.
#

Well, this looks simple enough. One of the programs that ripit requires, xmcd, isn't working. I tried running that program at the command line and sure enough, it didn't work. Browsing the xmcd directory listed above, I found quite a few configuration files and a shell script, config.sh. The top of the script said that it configured xmcd, so I ran it. It asked me for my CD-ROM device name (/dev/acd0c) and a few other basic bits of information, then wrote out some configuration files.

The xmcd program now ran, and pulled up the contents of any album I put in. So, I tried to rip again.

# ripit.pl 
Getting CDDB info...

And it hangs. And hangs. Why? Well, let's check the documentation.

# man ripit
No manual entry for ripit
#

Fine, be difficult. See if I care. At least ripit is in Perl. Almost any Unix admin can read Perl. I open the file in emacs and browse through it until I find the "Getting CDDB info..." message. Whatever's broken is beyond that.

sub get_cddb {

  print "Getting CDDB info...\n";

  system("rm $tocfile >/dev/null 2>&1");

  system("cda -dev $cddev on >/dev/null 2>&1") ;
  system("cda -dev $cddev toc >$tocfile") ;
  system("cda -dev $cddev off >/dev/null 2>&1") ;

  if ( ! -r $tocfile ) { die "$tocfile is missing"; }
}

Perl is running the program cda. The arguments include whatever is in $cddev. Looking at the top of ripit.pl, I see that we can set all sorts of useful variables. The script expects to have the CD-ROM be available as /dev/cdrom. That's a useful, common convention, so I create it. I also loosen the permissions on /dev/acd0c, so a regular user can read from the CD-ROM drive. I'd rather not have to rip as root, after all!

# ln /dev/cdrom /dev/acd0c
# chmod +r /dev/cdrom
#

I also set the directory where I'd like the final MP3s to be entered. Now, let's test those commands.

Pages: 1, 2

Next Pagearrow




Sponsored Resources

  • Inside Lightroom
Advertisement

Sponsored by:

O'Reilly Media

©2009, O'Reilly Media, Inc.
(707) 827-7000 / (800) 998-9938
All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.
About O'Reilly
Academic Solutions
Authors
Contacts
Customer Service
Jobs
Newsletters
O'Reilly Labs
Press Room
Privacy Policy
RSS Feeds
Terms of Service
User Groups
Writing for O'Reilly
Content Archive
Business Technology
Computer Technology
Google
Microsoft
Mobile
Network
Operating System
Digital Photography
Programming
Software
Web
Web Design
More O'Reilly Sites
O'Reilly Radar
Ignite
Tools of Change for Publishing
Digital Media
Inside iPhone
O'Reilly FYI
makezine.com
craftzine.com
hackszine.com
perl.com
xml.com

Partner Sites
InsideRIA
java.net
O'Reilly Insights on Forbes.com