Wednesday, February 01, 2006

Downloading and converting Real Audio radio streams

Wednesday, February 01, 2006

One of my favourite radio talk programmes is the Jeremy Vine show, a topical news and popular culture symposium, which airs five days a week, nationally on BBC Radio 2 and world-wide over the web. Ever since I bought my first MP3 player I've been recording Jeremy's shows using a combination of the BBC Radio Player and iRecordMusic, and listening to it a bit at a time, on the move and at my convenience.

iRecordMusic (or Audio Hijack Pro if you prefer) is an excellent tool for capturing non-podcast audio streams as it can discriminately record sound on a per web browser window basis (whereas Audio Hijack Pro is capable of capturing audio from any application). While this enables you to record multiple streams simultaneously, you are limited to recording them in real time. That is, if the show you want to capture is two hours long, it takes iRecordMusic or Audio Hijack Pro two hours to save it to disk. Another snag both applications suffer from is their tendency to capture whatever annoying pauses and stutters the streaming server generates.

Out of curiosity (and my anal proclivity for boosting efficiency) I set about finding a better solution.

Common sense suggests the ideal way to achieve this would be to use a resumable download manager to transfer the Real Audio files, and then convert them to the MP3 format using some kind of audio editing application (very few portable devices are capable of playing back .ra files directly).

This poses two challenges; finding a download manager which can make sense of URLs containing references to streaming protocols, and deciphering the precise locations of the Real Audio files you wish to transfer.

Several download managers which can handle RTSP (Real Time Streaming Protocol) and similar protocols include Flashget, HiDownload, Net Transport and Offline Explorer Pro. Flashget would be my first choice if you want a personal recommendation.

Now we need a means of disentangling the real location of the audio files from the melange of javascript, flash and whatever else they tend to be buried beneath when embedded in web pages. There are a number of ways of going about this:-

1. Make sure you're visiting the audio-embedded web page using Firefox. Right-click and select 'View Page Info'. Click on the 'Media' tab and scroll down the list of objects until you stumble across the address of something resembling an audio file (or at least an audio container).

2. Isolate the .rpm file by delving into the source code of the audio-embedded page using Firefox's (or any other browser's) 'View Page Source' button.

3. For the source-code-allergic among us there's URL Helper or URL Snooper.

Let's take URL revealing method 1 and Jeremy's Monday show as an example. Visit this link and open up the media info pane. Gaze down the 'type' column until you reach the only embedded object; an .rpm file. Copy the location into your clipboard and then append it to the site's root URL in your address bar. This should be the result. You can test that you've grabbed the right URL by pressing enter - all being well, the show should begin playing as it would if you'd launched it from within the BBC Radio Player.

Download the .rpm file using your download manager and open it with Notepad or a similar text editor. You should see a single line of text, much like this "rtsp://rmv8.bbc.net.uk/radio2/r2_vine_mon.ra" - this is the true location of the Real Audio file. Copy this into the clipboard and instruct your download manager to begin transferring the .ra file to your computer. It should download in a fraction of the time it would normally take to stream (obviously depending on the speed of your connection) and the end product will be blip-free.

Mac and Linux users can achieve the same results (albeit in real-time, just for now?) using the command line version of MPlayer in conjunction with the reallibs package (click on 'download' in the 'all clients' column adjacent to the operating system of your choice). Having extracted the contents of the reallibs package to the relevant area of your '/Library/Application Support' folder (within the 'ffmpegX' sub-folder in my case as I'm using the build of MPlayer I placed here for use with this video/audio encoding tool), the procedure is as follows: figure out the true URL of the file you wish to download, open a terminal window and type:-

"mplayer -noframedrop -dumpstream rtsp://rmv8.bbc.net.uk/radio2/r2_vine_mon.ra -dumpfile jv_monday.rm".

For those of you not accustomed to typing UNIX commands, remember that you are required to navigate to the folder where MPlayer resides before typing this string - that is unless you include the full path to begin with i.e. "/Applications/mplayer" or place MPlayer in an executable-from-anywhere folder such as "/usr/local/bin". Also bear in mind that you won't get a progress report of any kind, so don't harangue MPlayer; leave it alone to finish its task. Make a mental note of the time you ran the script and return to your computer when the duration of the show has expired if you like.

The .ra output, when fully transferred, can be converted into a more flexible wave file using MPlayer's 'ao' operator, or better still, why not skip the first stage and convert the .ra file on-the-fly? The command string you'd need to use looks a lot like this:-

"/Applications/mplayer -ao pcm:file=jv_monday.wav rtsp://rmv8.bbc.net.uk/radio2/r2_vine_mon.ra"

Executing this command dumps a humongous, uncompressed audio file into your '/Users/' folder. Last time I tried this, MPlayer managed to massage a two hour 32kbps audio stream into a 1.2gb wave file!

Once you've encoded your wave file, the hard work is done. You can either bung it on your portable audio device as it is (if you have a hard drive based player with ample storage for instance), or use Audacity to export it as a nicely condensed MP3 file. My tests indicate that it's possible to pack two hours of Jeremy into a sub-30mb MP3 file. Forget your faddy diets; now that's what I call weight loss!

Meanwhile back on the Windows ranch, there are plenty of applications you can use to convert Real Audio files to the MP3 format. The trouble is, nearly all of them are shareware, and a great many are of dubious quality. This is why WavePad is such a fantastic gift to radiophiles. It's an audio editor with a similar feature set to Audacity; the crucial difference being that WavePad supports Real Audio conversions, while Audacity momentarily chews .ra files, swishes the taste around its mouth and spits them out again in disgust.

To convert an .ra file to .mp3 with WavePad, open the former within the 'file' menu, wait for it to be decoded and then export it to the latter format using the 'save as' option, again from within the 'file' menu. As the BBC's streams tend to be encoded at a standard 32kbps, it makes sense to follow suit when you transcode them to .mp3; selecting a bitrate any higher than this will not improve the quality of the source audio, and will result in larger file sizes.

Of course none of this faffing about would be necessary in the first place if the Beeb would only AGREE TO PODCAST MORE OF THEIR SHOWS! To be fair to them though, the reason they don't is because they have to answer to the overbearing publishers of the music they play in between the chat. I assume these Luddites have got it into their thick skulls that if their music was included in freely available podcasts, listeners would pick them apart to harvest it rather than paying for CDs or legally downloaded songs (or worse still, distribute their yield for profit).

What they fail to comprehend is that you'd have to be suffering from a severe case of mush-for-brains to go to all the hassle of hacking out individual music tracks from such low quality streams. This line of reasoning is especially incredulous when you consider how facile it is to nab their superior quality counterparts from a million and one more accessible sources, on or offline. Really, how many people are there out there who have even attempted it? Not enough to pose a serious threat to the music industry, that's for sure.

0 comments:

 
◄Design by Pocket, BlogBulk