Using a Linux box as a PAR (Personal Audio Recorder – think PVR only Audio instead of Video)

I was interviewed by a friend who was doing a seasonal special for a local Internet Radio station. The timing for the playback of the program was not conducive to listening for it “live”. So I looked online for some advice on how to set up a recording of an internet radio program given a time and date and using a URL for the radio stream.

My preference was that the whole process would work from the Linux command line. That would allow me to use the very handy “at” command. More complicated circumstances would also allow a command line to be invoked as a “cron” job. I settled on the “at” command in this particular case. It simply meant that I needed to make sure that the computer was up and running at the appropriate time of day.

An internet search gave me a possible command line solution using VLC. See below for the useful links:

https://www.sourcefabric.org/blog/schedule-stream-recordings-from-the-command-line-part-1-yd2znuky
https://www.sourcefabric.org/blog/schedule-stream-recordings-from-the-command-line-part-2-vvm0irq2

Given that these blog posts were almost five years old, I wanted to make sure that the advice was still valid. Some tests with the software revealed that the instructions were pretty much still sufficiently correct to be useful.

Now that I knew that VLC could do the job of saving an audio file, and that the “at” command could be used to do the scheduling, all that was left was to find the URL for the radio stream. This proved to be a little bit of an exercise in reverse engineering. The radio station advertises a “Listen Live” link. As might be expected, that works fine for listening live, but the URL is not suitable for the VLC command line. Fortunately, the radio station also advertises a “live link”. The “live link” points to a “foo.pls” file. Looking into the “foo.pls” file with a text editor reveals that it is a text file, and in that text file there is a URL that turns into the one that can be used with VLC.

So to sum up the whole process:

Use the “at” command to schedule the recording of the stream:

at 06:00

(The “at” command is very flexible in terms of how the date and time are specified. This is one of the simplest forms. i.e. At 6:00 am do the following. )

This will start an interactive exchange consisting of the command to run at the specified time. More than one command can be provided. After the last command type Ctrl-D.

In this case, the command is:

cvlc “http://stream_url” –sout file/mp3:/home/peter/Audio/foo$(date ‘+%F_%H_%M_%S’).mp3 –run-time 30 –stop-time 30 vlc://quit

This will record the stream as an MP3 in the specified file with the date and time as part of the file name.

See the two blog links above for an explanation of the –run-time and –stop-time options for VLC