Scheduling the recording of an Internet radio stream with VLC – a post at Steven Luscher’s blog

Radios are so old timey Photo credit

I played a show on UBC’s CiTR radio yesterday with my band, Lakefield. I was planning to record it with something like Rogue Amoeba’s Radioshift, until my brother asked me for “the magic UNIX incantation that will make VLC record the broadcast.” I didn’t know that you can schedule recordings with VLC!

Opening the door to VLC’s secret telnet interface

Alright, it’s not so secret. For my purposes, though, it was rather poorly documented.

Enabling VLC's Telnet Interface on Mac

Enabling VLC's Telnet Interface on Mac

First thing to do, is to launch VLC, and choose (VLC > Add Interface > Telnet Interface) from the menu bar. For non-Mac users, I believe this option lives under the “Settings” menu.

Don’t quit VLC at this point! You will need to keep it running from now until the end of your scheduled recording. Also, make sure that your computer is not set to sleep after a period of idle time, and that your housemates know not to shut the computer down or put it to sleep.

Connecting to VLC through telnet

VLC opens a telnet interface at port 4212 of your local machine. Mac users can launch the Terminal application (typically found in the “Utilities” subfolder of your “Applications” folder) to make a connection.

Open Terminal and type the following:

$ telnet localhost 4212

The password, by default, is admin.

Trying ::1...
Connected to localhost.
Escape character is '^]'.
Password:
Welcome, Master
>

Once you’re in, you can start issuing commands directly to the VLC client.

Defining a broadcast

The “magic incantation” to define a broadcast, and the file to which you would like it saved, is as follows:

> new {name_of_broadcast} broadcast enabled input {url_of_broadcast} output #std{access=file,mux=raw,dst={path_to_which_to_save_broadcast}}

Phew! In my case, where the broadcast I wanted to save streams from http://live.citr.ca:8000/stream.mp3, and I wanted VLC to save the recording to my Desktop folder, the incantation went as follows:

> new citr_radio broadcast enabled input http://live.citr.ca:8000/stream.mp3 output #std{access=file,mux=raw,dst=/Users/sluscher/Desktop/lakefield_show_stream.mp3}

I called my broadcast citr_radio, but you can call yours whatever you like. Also, make sure that the path to your destination file exists.

Testing, testing – 1-2-3

At this point, the recording is ready for scheduling, but before we do that, let’s make sure that we spoke the magic words correctly. Here, we’ll use the control directive to test out our broadcast recorder. Incant the following:

> control citr_radio play

A file should appear at your destination path, and VLC should be dumping your broadcast into it. Let the tape roll for a few seconds, and then type this to stop it:

> control citr_radio stop

If all went well (and VLC doesn’t report any errors when you bring it to the foreground) then you should be able to open the file that was created with VLC and listen to what you’ve recorded!

Scheduling the recording

Once you’ve demonstrated that you can manually start and stop the recording, it’s time to schedule a recording. The scheduling syntax looks like so:

> new {name_of_schedule} schedule enabled date YYYY/MM/DD-HH:MM:SS append {command_to_run}

The time is in 24 hour clock, based on your system clock, and name_of_schedule can be anything you like. In my case, I wanted to schedule a start and a stop coincident with my band’s performance on the radio:

> new lakefield_show_start schedule enabled date 2009/03/19-21:00:00 append control citr_radio play
> new lakefield_show_end schedule enabled date 2009/03/19-23:00:30 append control citr_radio stop

Once you’ve set the trap, you can conclude your telnet conversation with VLC by typing:

> exit

Feel free to quit Terminal at this point, but leave VLC (and your computer) running until the end of the broadcast.

That’s that!

Here’s the whole magic spell:

$ telnet localhost 4212
Trying ::1...
Connected to localhost.
Escape character is '^]'.
Password: [the password is "admin"]
Welcome, Master
> new citr_radio broadcast enabled input http://live.citr.ca:8000/stream.mp3 output #std{access=file,mux=raw,dst=/Users/sluscher/Desktop/lakefield_show_stream.mp3}
> new lakefield_show_start schedule enabled date 2009/03/19-21:00:00 append control citr_radio play
> new lakefield_show_end schedule enabled date 2009/03/19-23:00:30 append control citr_radio stop
> exit
Connection closed by foreign host.
$

…and for your listening pleasure, here is Lakefield on CiTR’s Thunderbird Radio Hell!

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

Tags: ,

be the fourth person to comment on this post:

Want to include some code? Use Pastie and stick the link into your comment. Linebreaks, block quotes, and preformatted code blocks will be removed.

Please make an attempt to prove that you’re still human before submitting your comment.

If you've written a post of your own in response to this one, feel free to trackback from your own site.

  1. Rodrigo Gomez-Tagle said “GTFO! I had to use audio hijack when I wanted to record something from the interwebs this is a pretty good tip.” Reply to this comment.
  2. Jo said “Thanks, this was helpful! I used this successfully to schedule the recording of an IPTV stream (in .TS format) with subtitles. I had to change some parameters to make it work. Here’s the code that I used: http://pastie.org/private/pn5hgo1zrvqtxg1zauax6g The subtitles require the option “option sout-all”, otherwise you’ll get only audio and video.” Reply to this comment.
  3. Paul said “I had to look at the, “Media Information” window of VLC to get the correct location for the radio broadcast in the “General” tab to use in the Telnet commands.” Reply to this comment.

be the fourth person to comment on this entry.