Capturing an rstp, mms or ogg audio stream and coverting to MP3

Eric Dunbar eric.dunbar at
Sun May 1 15:44:22 UTC 2005

[Note: this was part of an earlier thread... I'm going to experiment
with Chris Kastorff's suggetions re: kill next]

Goal: I wanted to capture radio shows from CBC radio 1*, encode them
to MP3 and then listen to them at my leisure on my iPod Shuffle.

*Canadian Broadcasting Corporation, the Canadian BBC or NPR .

Since I've gotten this thing working I've been able to listen to a LOT
more programs that I want to listen to WHEN I want to listen to them
than I used to....

the good ones (IMNSHO) are on at times when I don't really listen to
radio, e.g. Ideas 21-22 EST (-05:00 EST) <>
which is a one hour program on a specific topic from anything on
science-politics-religion-philosophy-children's lit-the kitchen
sink-art-etc (they had a show on Hans Christian Anderson and on the
monarch butterfly (very good episode IMO) for e.g.)

Synopsis of problem: I wanted to pipe an .ogg stream from a wget
download to an .ogg to .wav decoder to a .wav to .mp3 encoder

(FYI ogg is similar to the mp3 file format (compressed) and .wav is
uncompressed audio)

Solution: even simpler than I thought (will work on Linux and under OS X):

ogg123 -d wav -f -|lame
- outfile.mp3

This line uses ogg123 to connect to CBC's server, download their live
ogg stream and then pipe it to lame (an mp3 encoder/decoder) to encode
to MP3. Lame and ogg123 play together very nicely. When lame's stdin
input is empty it waits for something to come in and continues
encoding :) :) :-)

This is a LOT cleaner than what I was doing up to today (using various
scripts and cron jobs):
1. download stream to .ogg file using wget (2nd cron job killall wget
at a certain time)
2. convert all .ogg to .wav in one dir using oggdec (quite fast) and
rm -f all the ogg
3. convert all .wav to .mp3 using lame and rm -f all the wav

I tried piping wget to oggdec to lame but couldn't get past oggdec...
rather than pipe to lame oggdec would write to the file -.wav (which
was a pain to delete from the command line... I ended up using
nautilus or OS X Finder (logged in via SMB))

This is what I tried (unsuccessfully):
wget -O -|oggdec -|lame
- outfile.mp3

(FYI I tried oggdec -, oggdec - -, oggdec, all to no avail)

PS I can't get lame to do the ogg-to-mp3 conversion directly (I
compiled from source with the --with-vorbis flag enabled but couldn't
figure out how to get ogg->mp3... doesn't matter b/c ogg123->lame
works beautifully).

PS this post'll appear twice in response to two message threads I started!

PSS This is what my script looks like (so far it seems to be working
with cron... I set it to start on the top and bottom of the hour from
2100 to 2200 weekdays and 1000 to 1200 on Sundays):

killall ogg123

Date=$(date +%Y%m%d.%H%M)

/usr/bin/ogg123 -d wav -f - $URL|/usr/local/bin/lame - ${LPath}CBC-${Date}.mp3

(1) I had to specify the path for lame b/c the cron tab entry didn't
run properly without. ogg123 would run but then the error message in
mail reported that lame couldn't be found.
(2) for newbies... you have to "chmod +x yourscriptname" to make your
script executable (you can run it manually from the command line by
typing ./yourscriptname after chmodding it).
(3) if you're interested in finding out what the flags mean, run man
ogg123 or man lame.
(4) I also run a cron tab "killall ogg123" to stop the final instance
of this script... I like 30 minute segments for listening purposes

Now... my next task is to get this machine to auto-update its time
(YellowDogLinux) b/c every week or so it slips by a minute or so.

cc:YDL General, Ubuntu-users, MUGLO

On 4/27/05, Cian Duffy <myob87 at> wrote:
> Short answer: Yes, just use a pipe (|) to do it
> Long answer: Don't bother, just recompile LAME with Ogg input support
> - its either an official compile option or theres a patch for it.
> oggdec is slow (not that LAME doing it will be majorly), and there is
> a possibility of pipe-starvation, where LAME could be running faster
> than oggdec, and there wouldn't be any file to encode from...
> Cian
> On 27/04/05, Eric Dunbar <eric.dunbar at> wrote:
> > Hi all,
> >
> > I'm trying to use oggdec and lame to convert from .ogg to .mp3.
> >
> > First I decode with oggdec to a .wav file and then from .wav to .mp3 using lame.
> >
> > What I was wondering is if it'd be possible to direct the .wav output
> > from oggdec *directly* to lame, skipping the intermediate file
> > creation process?

On 4/10/05, Chris Kastorff <jckastorff at> wrote:
> You'll need curl (or wget), lame, the vorbis-tools (oggdec, oggenc,
> ogg123, etc), and a decent userspace (including awk, sed, ps, etc) for
> this to work:
> Automagically creating an mp3 straight from the ogg stream:
> (you can replace "curl" with "wget -o -" if you want to)
>      shell$ curl http://mystream/ilike/radio.ogg | oggdec -o - - | lame
> -q 2 --abr BITRATE - /path/to/stream/output.mp3
> If this returns static, then try adding "-e 1" or "-e 0" between
> "oggdec" and "-o".
> And to kill it:
>      shell$ ps axc | grep curl | grep -v grep | awk '{ print $1 }' |
> xargs -n 1 kill
> Or if you're on Linux and it's a seperate file/script, as in #!/bin/sh
> blahblahblah,
>      shell$ ps axc | grep namofmyscript | awk '{ print $1 }' | xargs -n
> 1 kill
> (The above will not work on Mach/OSX, for reasons better not explained
> if you value your sanity.)
> It's all just guesswork, because for some reason I can't load the
> vorbis-tools nor can I load lame.
> And by the way, I've tried numerous times to "copy" an r(s)tp/mms
> stream and have had no luck at all with it.
>         -Chris Kastorff, aka `encryptio`
> On Apr 2, 2005, at 7:45 PM, Eric Dunbar wrote:
> > Hello all: I have a challenge for you.
> >
> > I'd like to download streams of OGG and RealPlayer from a radio
> > station, convert them to MP3 or AAC (if I get an iPod shuffle), and
> > play them back on an MP3 player at my leisure.
> >
> > So, in a nut-shell, I have two major options to get audio from the
> > web: streamed OGG for live broadcasts and streamed RTSP (RealPlayer)
> > for audio-archives.
> >
> > I'd like to capture the bit-stream for both formats (OGG and RTSP) and
> > convert them to MP3 or AAC for playback on an MP3 player (which I have
> > yet to get... chances are it'll be an iPod shuffle 512 MB, but if
> > there any *good* ones out there that support OGG I might consider them
> > instead).
> >
> > (1) OGG
> >
> > I have a hunch that it'll be possible to do it for OGG format since I
> > can actually DOWNLOAD the file using wget and any web browser (e.g.
> > <> as referenced in
> > <>) directly to disk.
> >
> > I suspect that I could create a cron entry (anacron would be pointless
> > for *live* content ;-) that did:
> > wget
> > at a certain time (e.g. 21:05), and, then at the end of the program
> > (21:59) would run another cron along the lines of:
> > killall wget
> >
> > I also suspect there are some apps out there that can be coaxed into
> > automagically converting OGG into MP3 or AAC format (if I can find any
> > OGG plug-ins for iTunes I could use the magic of Unix under OS X.
> >
> > Any thoughts? Anyone else have any success doing something similar?
> >
> > Thanks, Eric.
> > _______________________________________________
> > yellowdog-general mailing list
> > yellowdog-general at
> >
> > HINT: to Google archives, try  '<keywords>'
> >
> _______________________________________________
> yellowdog-general mailing list
> yellowdog-general at
> HINT: to Google archives, try  '<keywords>'

More information about the ubuntu-users mailing list