LWN.net Logo

The Grumpy Editor's guide to audio stream grabbers

The Grumpy Editor's guide to audio stream grabbers

Posted May 11, 2006 15:32 UTC (Thu) by stevan (subscriber, #4342)
Parent article: The Grumpy Editor's guide to audio stream grabbers

May I humbly submit a little script that I use for recording BBC output,
especially BBC7 stuff from their "Listen Again" page. BBC output is in
Realaudio format, but I've used the same script for other formats too.

You need the URL of the stream. This can usually be pasted from the
clipboard, but is sometimes hidden when you use the BBC RadioPlayer front
end. However, you can find the URL in your squid logs!

The script accepts the URL and a final file name as arguments. Of course,
the final result is an ogg file. I hope someone will improve it so that
it becomes clickable app under KDE.


Stevan
------



#!/bin/sh

FILE=$RANDOM
QUALITY=48

mplayer -nojoystick -nolirc -prefer-ipv4 -playlist $1 -ao \
pcm:file=~/Desktop/$FILE.wav -vc dummy -vo null

cd ~/Desktop
oggenc -b $QUALITY $FILE.wav
rm $FILE.wav
mv $FILE.ogg `echo $2 | tr " " _`.ogg


(Log in to post comments)

modified recorder with simultaneous encoding and mp3

Posted May 18, 2006 20:57 UTC (Thu) by nealmcb (subscriber, #20740) [Link]

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

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 © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds