| 1 |
#! /bin/sh
|
| 2 |
# Demo script for processing all audio tracks with a mp3 decoder
|
| 3 |
# based on a news article by Tom Kludy
|
| 4 |
# This variant uses named pipes in order to save space.
|
| 5 |
# There is another variant of this script, which uses temporary
|
| 6 |
# wav files (see cdda2mp3.new).
|
| 7 |
#
|
| 8 |
# usage: cdda2mp3 <name prefix for all mp3 files>
|
| 9 |
#
|
| 10 |
# list_audio_tracks is a (symbolic) link to cdda2wav
|
| 11 |
# and used to generate a list of audio track numbers and start
|
| 12 |
# sectors, which in turn are used in a loop to spawn cdda2wav
|
| 13 |
# and the post processor on a track by track basis.
|
| 14 |
|
| 15 |
# specify the sampling program and its options
|
| 16 |
# do not specify the track option here!
|
| 17 |
CDDA2WAV=${CDDA2WAV:-cdda2wav}
|
| 18 |
CDDA2WAV_OPTS=${CDDA2WAV_OPTS:-'-H -P0 -q'}
|
| 19 |
|
| 20 |
# for normal use, comment out the next line
|
| 21 |
#DEBUG='-d1'
|
| 22 |
|
| 23 |
# the post processor is fed through a pipe to avoid space waste
|
| 24 |
# specify the post processing program and its options
|
| 25 |
MP_CODER=${MP_CODER:-lame}
|
| 26 |
MP_OPTIONS=${MP_OPTIONS:-''}
|
| 27 |
|
| 28 |
export MP_CODER
|
| 29 |
MP_CODER=$(which $MP_CODER 2>/dev/null)
|
| 30 |
if [ ! -x "$MP_CODER" ] ; then
|
| 31 |
echo "Encoder not found. Install one first!"
|
| 32 |
exit 1
|
| 33 |
fi
|
| 34 |
|
| 35 |
if [ -z "$CDDA_DEVICE" ]
|
| 36 |
then
|
| 37 |
CDDA_DEVICE=/dev/cdrw
|
| 38 |
fi
|
| 39 |
export CDDA_DEVICE
|
| 40 |
|
| 41 |
FILEPREFIX=${1:-audiotrack}
|
| 42 |
|
| 43 |
if [ -e /etc/default/cdda2mp3 ]; then
|
| 44 |
. /etc/default/cdda2mp3
|
| 45 |
fi
|
| 46 |
|
| 47 |
TRACK=1
|
| 48 |
while :
|
| 49 |
do
|
| 50 |
$CDDA2WAV $CDDA2WAV_OPTS -D$CDDA_DEVICE -t$TRACK $DEBUG - | \
|
| 51 |
# echo n | $MP_CODER $NPIPE $FILEPREFIX$TRACK.mp3 $MP_OPTIONS
|
| 52 |
$MP_CODER $MP_OPTIONS - $FILEPREFIX$TRACK.mp3
|
| 53 |
|
| 54 |
# check result code
|
| 55 |
RES=$?
|
| 56 |
if [ $RES = 0 ] ; then
|
| 57 |
echo File $FILEPREFIX$TRACK.mp3 finished successfully.
|
| 58 |
else
|
| 59 |
echo File $FILEPREFIX$TRACK.mp3 failed \(result $RES\). Aborted. >&2
|
| 60 |
break
|
| 61 |
fi
|
| 62 |
TRACK=`echo $(($TRACK+1))`
|
| 63 |
done
|
| 64 |
|