MARCH 30, 2005
Building an Internet radio recorder with VLC Player
Author: DmitriPopov
It's nice to be able to listen to a net radio station directly on your computer. But wouldn't it be great if you could record it on your hard disk?

Better yet, what if you could schedule recordings, so you don't miss your favorite programmes?

VLC Player and a simple batch file you can turn your computer into a radio recorder.

VLC Player is a core application of the VideoLAN project. This versatile software can handle a wealth of video and audio formats and stream content over a local network. Moreover, VLC Player is able to play net streams and record them to the hard disk, which makes it a perfect tool for our project.

Listening to a net radio (or any net stream for that matter) using VLC Player is not that difficult. However, to be able to record it using VLC Player, you have to make sure that you have a direct link to the stream. Normally the links on radio stations' Web sites refer to .plsplaylist files, which contain the stream information. Like any other player,VLC Player can use the playlist files to play the stream, but not to record it.To solve this problem you have to extract a direct link to the stream from the.pls file.

Let's say you want to record the Virgin Radio Classic Rock stream. Point your browser to
the page containing the streaming links.

If you use the Firefox browser, right-click on the desired link (an MP3 modem or broadband is always the safest bet), and select Save Link As to save the playlist file.

Open the saved file in a text editor and locate the line containing the direct link to the stream. In this case it is:


Check that the link works properly, then copy it into the Clipboard. Launch VLC Player and choose File > Open NetworkStream. Select the HTTP/FTP/MMS option, and enter the link into the URL field.To avoid hiccups during playback, you might want to enable caching. To do this,tick the Caching check box and type a value in milliseconds into the Caching field (5,000 works fine in most cases). Finally, click OK. If the link works,VLC Player will play the stream.

The next step is to configure VLC player to record the current stream. Once again, choose File > Open Network Stream, select the HTTP/FTP/MMS option, and enter the link into the URL field. This time, though, tick the Stream output check box, and press the Setting button. This will open the Stream Output dialogue window. If you want to listen to the stream while it's being recorded, tick the Play locally check box.

Use the Browser button next to the File name field to give the recorded stream file a name and choose where it will be stored. For Encapsulation Method, select Raw. In the Transcoding options section, tick the Audio codec check box and select MP3 from the list. Select abitrate from the Bitrate list (128 is a good compromise between audio qualityand file size).

Since you are going to record a stereo stream, select 2 from the Channels list. Finally, press OK to save the settings and close the window.

Press OK to start recording. To make sure that everything works properly, close VLC Player and try to play the recorded file on your favourite MP3 player.

Although VLC Player can now play and record the net stream, there are still a couple of things you can do to improve the way it works. First of all, if you quit VLC Player, you'll lose all your settings. Luckily, you can launch VLC Player using a command with different parameters. This means that you can create a batch file (or a script on Linux) that you can use to launch VLC Player with predefined settings.

Create a new text file and enter the following string, if you're running Windows:

"C:\Program Files\VideoLAN\VLC\vlc.exe"--http-caching 5000{acodec=mp3,ab=128,channels=2}:dup licate{dst=display,dst=std{access=file,mux=raw,url ="C:\VLCOutput.mp3"}}

In this string,
points to the VLC Player's executable. Linux users can replace this part with the appropriate file location.
--http-caching 5000 enables caching and sets it to 5,000 milliseconds. pointsVLC Player to the net stream.
The part of the command that starts with :sout contains recording settings.

Typing this string manually can be somewhat laborious. Luckily, you can simply copy the string from the Destination Target field in the Stream Output dialogue window and paste it in the text file.

Finally, save the file as a shell script, or with the .bat extension on Windows.

The last part of the project is to create a schedule that will execute the batch file at a predefined time. You can use cron on Linux or the Scheduled Tasks tool on Windows to do this.

On Windows, goto Accessories > System Tools > Scheduled Tasks and double-click on Add Scheduled Task. This will launch the Schedule Task wizard that will guide you through the process of creating a task. When the wizard prompts you to choose a program file, press the Browse button and point to the batch file. Configure the rest of the settings, and save the task. That's it! Your radio recorder is ready for use.