Capturing streamed audio as .mp3

Why?

This technique lets you make high-quality recordings from streamed internet radio.

Internet radio stations are a rich resource. More and more of them are archiving their audio material. Sometimes this can be simply downloaded, as a Podcast (usually .mp3, sometimes .ogg). More often the audio is ‘streamed’ – i.e. the file plays directly but can’t be saved.

This guide tells you how to capture Real Audio .ra and .rm streams (the most common kind).

Some stations also stream .mp3 and .ogg. There is a separate guide for those, using Stream Tuner and Stream Ripper, here.

You can also record the audio from the sound output using something like Audacity – but the quality is limited by your sound card. With this method you’ll be grabbing the digital audio stream file directly. This process is called ‘Ripping’, as opposed to ‘Recording’

NOTE: In most countries it is legal to capture streamed audio, provided that this is for personal use and not for further duplication or commercial re-use. However - note the comments here. Use at your own risk.

Steps

  1. Install Real Player - this is the easiest way to listen to the audio streams.

  2. Install the other software you’ll need – Vsound and Sox to grab the audio stream. Lame to convert it to a .mp3.

  3. Find an audio stream – it can be slightly tricky to find the URL.

  4. Capture your stream - you'll end up with a large .wav file.

  5. Convert your stream to a .mp3 file - to shrink it down to size and make it work on your portable player.

How to install Real Player

Real Player is a proprietary package. For information on how to install it, read here. You will also need to configure it to play Real Audio formats. Read the Real Player section here.

Install the other software you’ll need

Read here for general instructions on how to install software.

The packages you need are vsound, lame and sox.

  • Vsound grabs audio streams

  • Sox converts them to a very large .wav file

  • Lame is a handy package for converting most audio file types to most others.

You may already have these installed. Otherwise, with Universe and Multiverse repositories enabled, type the following in a terminal window:

sudo apt-get install vsound sox lame

And you’re ready to start looking for audio streams.

Finding your Audio Stream

Vsound needs to know the URL of the audio stream it is grabbing. This may not be obvious at first glance. For example, some sites, like NPR (eg here), nest the URL inside a .smil (Standard Multimedia Integration Language) file. If you click on the links you will be offered the .smil file to either play in Real Player or save to disk. Save it. Then open it with a text editor (right-click). Inside, you will see the URL.

Elsewhere (eg. BBC Radio, here) you will be offered a .ram file (On the BBC site, right click on 'Play in standalone Real Player' buttons). Again, save it locally and peek inside using a text editor.

In either case you’re looking for a URL which ends with a something.ra or something.rm filename.

Select and copy the URL.

Some station URLs are listed on this page: RadioURLs

Capture your Audio Stream

Now let’s get to work.

NOTE: before you start, you are going to be making some massive .wav files – approx 10MB per minute of recording. Make sure you have enough disk space for the time you want to record. You’ll need about (2.1 x 10 x recording length in minutes)MB.

Open up a terminal window:

vsound –-timing –-dspout –-file=myfilename.wav realplay url_of_the_stream_you_want_to_rip

Realplayer will open up and play the stream (the –-dspout parameter means you can listen while ripping). At the same time, it will generate a large Sun ULAW format file containing the stream. When it’s got what you want, close down Real Player. Sox will start up, create a .wav file from the ULAW, then delete the ULAW. This may take some time – but you can monitor it in a file browser.

Converting to .mp3

To convert the massive, unwieldy .wav to a more manageable .mp3 (approx 10% of its size), simply:

lame myfilename.wav myfilename.mp3

A dialogue will open in your terminal showing the process. Again, this may take time, depending on your processor speed and the file size. You can use Audacity to edit the .mp3 further – eg to make breaks between songs.


NOTES

This information was based in part on an article in Linux Magazine: http://www.linux-magazine.com/issue/57/Ripping_Audio_Streams.pdf

There is an alternative method just using mplayer and lame here. This has been made into a script that will create the mp3 file automatically. To run it download the script and in the terminal type

bash RunRadioRip4.sh

or

bash RunRadioRip4.sh "url" "filename"

or

bash RunRadioRip4.sh "url" "filename" "lame options" 

the default lame options, if unspecified, are "-V 3 --vbr-new" but they can be changed (e.g. "--preset voice") instead.

This wiki page is identical to HowToRecordInternetRadio - a more user-friendly re-titling

This page does not explain how to rip RTSP video; for example rtsp://realstreams.omroep.nl/bobo02/1/media/tv/vpro/hollanddoc/HD Onderhandelaar-sb.rm


CategoryAudio

HowToRipRealaudioStreamsToMp3 (last edited 2012-02-10 14:17:20 by rex-the-first)