modified recorder with simultaneous encoding and mp3
Posted May 18, 2006 20:57 UTC (Thu) by
nealmcb (subscriber, #20740)
In reply to:
The Grumpy Editor's guide to audio stream grabbers by stevan
Parent article:
The Grumpy Editor's guide to audio stream grabbers
Thanks, Stevan. My version of mplayer doesn't seem to take the
":file" modifier to the "-ao pcm" option, so I used the "-aofile"
option instead.
I also didn't like the idea of filling up my disk with the .wav
data until the recording was done, so I changed it to run the
encoder in the background. I couldn't do that via a pipeline
since mplayer doesn't seem to be able to write to stdout, so I
had to connect them via a named pipe. Here is my modification,
which also produces mp3 rather than ogg since that is what my
nokia tablet knows how to play by default.
----
#!/bin/sh
# record a stream with mplayer, e.g. realaudio, saving it as an ogg vorbis file
# todo: trap terminate signal and kill encoding process, remove named pipe
# consider option for dumping raw format via -dumpstream -dumpfile,
# and later conversion
# based on Stevan's script at http://lwn.net/Articles/182954/
# See also scheck's 'srec' script there
usage="$0 url name"
URL=$1
NAME=`echo $2 | tr " " _`.mp3
FILE=$RANDOM
QUALITY=48
mknod $FILE.wav p
(lame --quiet -V6 --vbr-new --resample 22 -m m $FILE.wav $FILE.mp3) &
# (oggenc --quiet -b $QUALITY $FILE.wav) &
mplayer -cache 32 -nojoystick -nolirc -prefer-ipv4 -playlist $1 -ao pcm -aofile $FILE.wav -vc dummy -vo null
wait # wait for encoding process to finish
mv $FILE.mp3 $NAME
rm $FILE.wav
(
Log in to post comments)