Tag Archives: audio

Audio CD Ripper

A customisable cdripper script.

cdripper

It took me a while to get this functioning how I wanted it.. but it seems to do the job.  The script can be run as any user from any location.  It will create a config file in ~/.cdripper and work in ~/tmp.  I bunged it in /usr/local/bin ($PATH) and made it executable.  The config file will be used  for defaults, but any arguments passed on the command line will over rule it.

There are a couple of functions that require an internet connection ie: cddbdb and sample offset values.  If no net connection is available, then cdtext will be used for id3tag and no sample offset will be used.

Features:
Can use CDTEXT or FreeDB for id3tag info.

Dependencies: (Versions at time of creation.)

cdparanoia III release 10.2
cdda2wav 3.00
LAME version 3.98.4
id3tool version 1.2a
id3v2 0.1.11
Uses id3lib-3.8.3
flac 1.2.1
cd-discid 0.9
cddb-tool version 0.4.7
traceroute (used instead of ping due to some networks blocking ICMP traffic)
libwww-perl (used for the GET binary to grep web pages)
vorbis-tools 1.4.0

TO DO:
Add other formats to encode to ie shn, wv, ogg
Add more arguments or config file.
Do an ebuild :)
Convert from bash to perl (add freedb submission)

Tweaks and Fixes:
13th Nov 2011: Added WAV support
19th Nov 2011: Added OGG support
21st Jan 2012: Added ripping to wav image with cue file
11th Feb 2012: Added rip speed, tidy log file, corrected removal of temp files.

How to use:
Several arguments can be passed at runtime.  Any arguments not used, the defaults will be used.

The current defaults are:
Device: /dev/sr0 (auto detected)
Sample Offset: (grepped from accurip)
Encoder: LAME
Bitrate: 320kbps CBR
Mode: Stereo
Quality: 0
CDDB: FREEDB

OPTIONS:

-d<devicenode>      usually /dev/sr0 
-b<bitrate>         lame bitrate 
-o<quality>         ogg quality 
-t<track #>         all|single|range|image
-e<encoder>         lame|flac|wav|ogg 
-c<cddb>            local|net
-s<rip speed>       cdparanoia rip speed

Jack-3.1.1

Jack (not to be confused with the jackd audio daemon) is a cdripper for Linux written in python.  You can download via your package manager or from the homesite.  I have found on Gentoo and Fedora that jack depends on python-2.4 which is a pain when just about everything else builds against python-2.5 or higher which causes problems.  I was forever getting:

$ jack
Traceback (most recent call last):
 File "/usr/bin/jack", line 42, in <module>
 import jack_argv
 File "/usr/lib/python2.6/site-packages/jack_argv.py", line 22, in <module>
 import jack_utils
 File "/usr/lib/python2.6/site-packages/jack_utils.py", line 26, in <module>
 import jack_functions
 File "/usr/lib/python2.6/site-packages/jack_functions.py", line 222
 def starts_with(str, with):
                         ^
SyntaxError: invalid syntax

I had my fill of fixing this every time I needed to rip a cd, so I fixed it.  All you need to do after it has been installed is run this script jack python-2.6 patch

If you look at the script, you'll see that it just changes any definitions from starts_with to startswith.
Another common problem is a gcc memory leak.  To fix this add MALLOC_CHECK_=1 at the start of your command.  I have added this as an alias in my .bash_profile eg.

alias jackflac='MALLOC_CHECK_=1 jack --device=/dev/sr0 --append-year=yes --dir-template "%a/%l" -C -Q -R --rename-fmt "%n - %a - %l - %t" --workdir /home/cdstealer/Desktop/ -E flac'

alias jackmp3='MALLOC_CHECK_=1 jack --device=/dev/sr0 --append-year=yes --dir-template "%a/%l" -C -Q -R --rename-fmt "%n - %a - %l - %t" --workdir /home/cdstealer/Desktop/ -E lame --vbr=no -b 320 -e 2 --write-id3v2=yes'

Please make sure that jack and its dependencies have been built against python-2.6+.

dev-python/id3-py
dev-python/cddb-py
dev-python/pyogg
media-libs/id3lib
dev-python/pyid3lib
dev-python/pyvorbis
media-sound/jack

I edited the files below to add high quality and forced stereo.  Just add "-q0 -ms" to the end of the 4 line in each file.  eg:

'cmd': "lame --preset cbr %r --strictly-enforce-ISO %i %o -q0 -ms",
'vbr-cmd': "lame -V %q --vbr-new --nohist --strictly-enforce-ISO %i %o -q0 -ms",
'otf-cmd': "lame --preset cbr %r --strictly-enforce-ISO - %o -q0 -ms",
'vbr-otf-cmd': "lame -V %q --vbr-new --nohist --strictly-enforce-ISO - %o -q0 -ms",

/usr/lib/python2.6/site-packages/jack_helpers.py
/usr/lib/python2.6/site-packages/jack_main_loop.py
/usr/lib/python2.6/site-packages/jack_plugin_lame.py