2 # Script for processing all audio tracks with an ogg or mp3 decoder
3 # based on a news article by Tom Kludy
4 # This variant uses named pipes in order to save space.
5 # usage: cdda2ogg <name prefix for all ogg/mp3 files>
7 # specify the sampling program and its options
8 # do not specify the track option here!
9 CDDA2WAV=${CDDA2WAV:-icedax}
10 CDDA2WAV_OPTS=${CDDA2WAV_OPTS:-'-H -P0 -q'}
12 # for normal use, comment out the next line
15 # the post processor is fed through a pipe to avoid space waste
16 # specify the post processing program and its options
19 # ensure the right suffix for suffixes later
21 missmsg="Encoder not found. Install one first! (eg. vorbis-tools)"
22 MP_CODER=${MP_CODER:-oggenc}
25 *mp3|*MP3|*mpeg3|*MPEG3|*Mp3)
27 missmsg="Encoder not found. Install one first! (eg. lame)"
28 MP_CODER=${MP_CODER:-lame}
32 echo Unknown target file type: $suffix. Valid names for this application are: cdda2mp3, cdda2ogg.
37 MP_OPTIONS=${MP_OPTIONS:-''}
39 MP_CODER=$(which $MP_CODER 2>/dev/null)
40 if [ ! -x "$MP_CODER" ] ; then
45 CDDA_DEVICE=${CDDA_DEVICE:-/dev/cdrw}
48 FILEPREFIX=${1:-audiotrack}
50 if [ -e /etc/default/cdda2$suffix ]; then
51 . /etc/default/cdda2$suffix
54 if [ -z "$LIST" ] ; then
55 echo Looking for available tracks...
56 # could use list_audio_tracks instead but that would need an extra filter as
57 # well, and this way we do not depend on that symlink
58 LIST="$( $CDDA2WAV -J -vtoc -H 2>&1 | sed -e 's/^[^\ ].*//; s/\.([^)]*)/ /g;s/,//g;')"
59 if [ -z "$LIST" ] ; then
60 echo "ERROR: No valid audio tracks detected"
65 echo Fetching `echo $LIST | wc -w` tracks from $CDDA_DEVICE, encoding with $MP_CODER.
66 echo Cancel with Ctrl-C, watch out for error messages.
68 for TRACK in $LIST ; do
69 NAME="`printf "%02d" $TRACK`-$FILEPREFIX.$suffix"
71 echo "############ Starting with Track Nr. $TRACK -> $NAME ############"
72 $CDDA2WAV $CDDA2WAV_OPTS -t$TRACK $DEBUG - | \
73 $MP_CODER $MP_OPTIONS - $outopt "$NAME"
77 if [ $RES != 0 ] ; then
78 echo File $NAME failed \(result $RES\). Aborted. >&2