Download RM and Convert to MP3

Ok, so the first useful thing that I'm adding to my website is how you can download an RM file and then convert to mp3 for use on an mp3 player.  I often find myself doing this with files from the BBC website (they're podcasts are in mp3 format, but many other links are real player only - for example, check out the BBC 7 listen again site).

Downloading the RM file

First off, we need to actually download the rm file.  This may sound easy, but is frequently made more difficult because there's no direct link to a file.  Even a link to an rtsp stream can be tricky to find.  RTSP (real time streaming protocol) is the protocol used to stream real media files on the internet.  What we need to find is a link that starts rtp://.

On the BBC web site, when you click on a program to listen to it opens up a new window (the bbc listen again window).  Search for the 'listen in stand alone player' link - right click this and save the file to disk.  It will give you a *.ram file.

If you open the ram file, you'll see the rtsp link that we need.

Now we have the rtsp link, you can download the file with mplayer:

mplayer -ao pcm:file=output.wav rtsp://...

This command tells mplayer to open the rtsp link and then dump the audio file to output.wav.  Change the filename to something else if you wish.

Note:  You may need to enclose the rtsp:// link within double-quotes to ensure that funny characters are handled properly.

Converting to MP3

This is trivial :-)

lame -q 5 output.wav output.mp3

The lame encoder converts wav files to mp3.  The -q option specifies the quality ( 0-10; lower value being better quality, but slower to encode.  For speech, 5 is more than adequate).  See the lame help files for lots more options, but if you want to specify the bitrate you can use -b, for example:

lame -q 2 -b 128 output.wav output.mp3

This produces a 128 kbps file at reasonably high quality.
 

Notes:

On linux, lame should be installed by default but you may need to install mplayer.  On ubuntu it's readily available through synaptic.  Mplayer is a powerful audio/visual player (and with mencoder also a recorder).  It can play any format you can find with a vast array of options (from changing aspect ratios, to altering the delay between the sound and video streams).  It's not the most accessible to begin with (it downloads without a gui - though you can download third-party guis separately) but with patience and practice it is very useful.

For Windows users, mplayer can be downloaded from their homepage.  Lame is also available for windows, see here.