Sunday, December 16, 2012

Converting CDs to digital from the command line

One of the easiest to use and well featured command line CD ripping utilities around is called jack.

This is not to be confused with the relatively sophisticated general purpose open source audio software called Jack or the windows software called "Jack the CD ripper".

You should be able to find jack in the repositories of most linux distributions. In Ubuntu it is called, unsurprisingly, jack.

The jack program is written in python and makes use of a number of other software packages to do the heavy work. It performs the following:

  • Scan the CD
  • Download album and song information from the internet into a file alongside the tracks
  • Extract the tracks into a directory named using a specified format (eg. artist/album)
  • Convert the tracks them to the desired format (mp3, ogg, flac, etc)
  • Add the downloaded tag information to the files
  • Rename the files using a specified format (eg. 01 - song title.xyz)

Although most the preferences can be specified from the command line, it is more practical to place them in either the user specific config file ~/.jack3rc or the system wide config file /etc/jackrc. I have defined the following settings in my ~/.jack3rc file:


cd_device:/dev/sr0
base_dir:~/jack
ripper:cdparanoia
encoder:flac
rename_fmt:%n - %t
dir_template:%a/%l
unusable_chars:['/', '"', ':']
replacement_chars:['_', '\'', '-']
query_on_start
cont_failed_query


The man page for jack has explanations for all of these (and more). The ones I considered important to change were:

  1. encoder - my preference is to use flac files as my master digital copy
  2. dir_template + rename_fmt - defines my preferred directory and file names formats
  3. query_on_start - perform lookup of album/song information before ripping tracks
  4. cont_failed_query - continue with ripping if lookup of information failed
  5. unusable_chars + replacement_chars - prevent troublesome characters in file names

The last is important and a common feature in CD ripping utilities, even some of the more sophisticated GUI ones. As I use my digital files on a range of operating systems, it is important that they do not contain certain characters that are allowed in directory or file names on one system but not on another. You may even want to add more characters to these options.

If jack is interrupted or stopped by an error (eg. by the user, a power failure, a disc than needs cleaning, etc), simply run it again and it will pick up from where was up to.

There are quite a number of options jack has that I am not making use of (yet). For example, the ripping can be done without any lookup of information (or even encoding) and then the rest of the job done later.

A couple of areas jack could be improved are:

  • Fetching album cover art along with album and song information
  • Allowing files to be re-tagged and renamed after the downloaded information is edited

To make up for this I simply download my on album cover art found on google images and use the metaflac command line utility to make any necessary changes (usually modifying album titles to be consistent).