By Kristian Ki▀ling
The Internet has given birth to a new generation of "radio hams" who employ webcasting or streaming to deliver programming to Internet listeners using a variety of protocols. The innumerable radio stations at Shoutcast.com use the MP3 format for webcasting, whereas traditional radio stations tend to use the RTSP or PNM protocol, as spoken by RealPlayer, or the MMS protocol, as spoken by MPlayer. Unfortunately, recording the data from an incoming audio stream involves some extra work.
Radio stations that use the MP3 format are the easiest to record. Streamripper  supports recording of MP3 streams, such as those found at Shoutcast.com or Icecast.org. The Streamtuner  GUI supports simultaneous recording and playing and gives users some convenient management features (Figure 1). Both programs can typically be installed using the package management tools provided by the major distributions. Fedora users may need to install the xmms-mp3 package . Note that both Fedora Core 3 and Suse 9.3 no longer have the MP3 codec on board by default.
After installing Streamtuner, you will normally launch the program via a start menu entry, but you can pop up a terminal window and type streamtuner if you prefer. This opens the graphical interface with various tabs and entries. Selecting the SHOUTcast tab takes you to a list of radio stations. Double clicking on a station launches an MP3 player such as Xmms to play the stream. To record a stream, simply click on the round Record button in the toolbox. This opens a console that logs the process. The tracks will be placed in your home directory by default.
It is slightly more difficult to record RealAudio formats. RealPlayer, which is available for Linux , can replay these formats but not record them. You need Vsound and Sox  for recording RealAudio.
Vsound captures the output stream of an external sound program and calls Sox to store it in .wav format. Besides these two programs, you also need Lame , to convert the wav files to MP3.
Before you rush into the install, check to see if the packages really are missing. Type which sox to find out; if the response does not contain a path such as /usr/bin/sox, launch your package manager to install Sox and Vsound. Then move on to install Lame. You can download RealPlayer as an RPM or bin file from the Internet. RealPlayer assumes you have a functional Java Runtime Environment; check if this is so by typing which java. If not, you will need to install Java. To set up the bin file, become root and then give the following command: sh ./RealPlayer10GOLD.bin.
The recording process comprises three steps. First, find the URL of the station (see the box titled "Finding the Streaming Address"). Second, pop up a terminal window and give the following command:
vsound -d -t -f test.wav realplay rtsp://stream_address
This command launches RealPlayer and starts playing the stream at the address rtsp://stream_address while Vsound records the stream. The -f option redirects the stream to a file called test.wav. The -d option makes sure you can listen while you record. Remember that you need to terminate RealPlayer manually to start converting the temporary au file to wav format. Make sure you have enough space left on your hard disk to store the file. The third step is to convert the wav file to an MP3 file; typing lame test.wav radiostream.mp3 will take care of this.
|Box 1: Finding the Streaming Address|
It is easy to identify the streaming address if the stream is embedded directly in a website. Right click the link that plays the stream, and then (for Mozilla) select Save link target as. You can open the file in a text editor, such as kate, to view the stream address. The procedure for identifying the address is more complicated if the radio station embeds the player in a pop-up window. In that case, you need to inspect the pop-up window source code for the address. You may need to isolate the frame with the play button in the pop-up window. To do so in Mozilla, right click somewhere near the play button and select Show only this frame. You can then search the HTML source code for the frame for things like lsc.redirect, embed src, ra, rm or smil. Then enter wget -O address.txt "http://foundaddress.ra" to parse the address and store it in the file address.txt. Then type cat address.txt to read the address file and discover the address, which will typically start with RTSP:// or MMS://.
The final option is audio streams that use the MMS protocol. MMS stands for Microsoft Media Services. MMS files are tailored for Windows Media Player. MPlayer can read this format, but you may have to install it manually, since many distributions do not include MPlayer. Suse users can go to  to download the required packages: Lame, the Win32 codec, and mplayer. Users with Fedora, Mandrake, or Debian should build the application from the source.
Building MPlayer from source actually takes far less time than attempting to resolve all the dependencies when installing the package. First become root and create a directory, as follows: mkdir /usr/local/lib/codecs. Then set the permissions: chmod 664 /usr/local/lib/codecs. Download the essential codec package from the MPlayer page at  and unpack the package. Copy the contents of the package to the /codecs directory, then type ./configure, make and, again working as root, make install. This step places the MPlayer executable in /usr/local/bin/.
Now for a three-stepper. First, discover the address of the stream, as described in the box titled "Finding the Streaming Address." Second, convert the stream to a wav file called audiodump.wav. The mplayer `mms://YourStation.wma' -ao pcm command passes the audio stream to your PCM audio output device, which then stores the stream as audiodump.wav. Don't expect sound output while recording. Finally, convert the wav file to MP3 using the following command: lame audiodump.wav myradiostream.mp3 (Figure 2.). Finished! And if you prefer to chop the continuous stream into individual tracks, you can always use a tool such as Audacity .
 Streamripper source code download: http://sourceforge.net/project/showfiles.php?group_id=6172
 The Streamtuner page with source code and RPMs: http://www.nongnu.org/streamtuner/
 The MP3 codec for Fedora Core 3: http://dag.wieers.com/packages/xmms/xmms-mp3-1.2.10-11.1.1.fc3.rf.i386.rpm
 RealPlayer for Linux: http://www.real.com/linux/?rppr=rnwk&src=040104freeplayer
 Source files for Vsound and Sox: http://prdownloads.sourceforge.net/sox/sox-12.17.7.tar.gz?download http://www.zorg.org/vsound/vsound-0.6.tar.gz
 Lame source code: http://lame.sourceforge.net/
 MPlayer files for Suse: http://packman.links2linux.org/?action=index
 MPlayer website with sources: http://www.mplayerhq.hu/homepage/design7/dload.html
 Cutmp3 website with RPMs: http://www.puchalla-online.de/cutmp3.html
 Audacity website at Sourceforge: http://audacity.sourceforge.net/