LWN.net Logo

modified recorder with simultaneous encoding and mp3

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)

modified recorder with simultaneous encoding and mp3

Posted Mar 7, 2007 20:22 UTC (Wed) by devasura (guest, #43937) [Link]

some mplayer options seem to be decprecated, use:
mplayer -cache 32 -nojoystick -nolirc -prefer-ipv4 -playlist $1 -ao pcm:file= $FILE.wav -vc null -vo null

modified recorder with simultaneous encoding and mp3

Posted Mar 7, 2007 20:28 UTC (Wed) by devasura (guest, #43937) [Link]

ignore the above comment, didnt read the full article
sorry

modified recorder with simultaneous encoding and mp3

Posted Mar 8, 2007 17:27 UTC (Thu) by devasura (guest, #43937) [Link]

i replaced oggenc line by:
(cat $FILE.wav | oggenc --quiet -b $QUALITY - | tee $FILE.ogg | mplayer -cache 32 - > /dev/null) &
to enable playing while the stream is being recorded

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds