1. Andrew's Corner :

Slackware and "For The God Who Sings"

In this page I have attempted to combine my love of an amazing radio broadcast called "For the God Who Sings" with my passion for Linux. Perhaps an uneasy mix in the eyes of many but humour me, Gentle Reader, and read the entire page and perhaps you will follow me down this same path? Every Sunday night at 10.30 pm Stephen Watkins hosts a 2 hour radio show that presents "music and texts that seek to enlighten the path untravelled, the idea unravelled". Stephen has a beautiful and quietly contemplative voice that complements perfectly the sacred music that he introduces. And yes, the music echoes the title of the radio presentation as it speaks of God in an exultation of song:

Sing aloud, O daughter Zion; shout, O Israel! Rejoice and exult with all your heart, O daughter Jerusalem! The LORD has taken away the judgements against you, he has turned away your enemies. The king of Israel, the LORD, is in your midst; you shall fear disaster no more. On that day it shall be said to Jerusalem: Do not fear O Zion; do not let your hands grow weak. The LORD, your God, is in your midst, a warrior who gives you victory; he will rejoice over you with gladness, he will renew you in his love; he will exult over you with loud singing as on a day of festival.

But can I say for all this it is often way past my bedtime!! So on this page I will demonstrate how with the svn MPlayer and oggenc you can download the live stream of "For the God Who Sings" and then convert it to the free Ogg Vorbis format for offline playback on the music device of your choice. (In my own case this device is an HTC Legend smartphone.) A perhaps precarious mix of religious music and modern technology?

All the steps...

Downloading and converting the live stream for "For The God Who Sings" can be easily done from within most modern Linux distros but I will share a few tips and tricks that will hopefully make the whole process a little easier:

MPlayer & oggenc...

Times have changed a little for Slackware and perhaps you will no longer need to compile the newest version of MPlayer, as I have advocated before, because as of release 13.0 there is now a quite capable version of the svn MPlayer available in the Slackware xap series. Certainly you would be well advised to run the Slackbuild script again and pass USE_PATENTS=YES to the script, if this is legally allowable in your country, and perhaps also add the MPlayer codecs to your system but otherwise the default copy of MPlayer is more than ready to tackle this stream. For Ubuntu users there is always my guide to building the latest MPlayer and I would strongly advise following this route. There should be no problem getting access to oggenc, it is part of a full Slackware install and Debian based distros can find it as part of their 'vorbis-tools' package. Mind you it is well worth your time to modify the standard oggenc with the aoTuV changes, but that is material for another page perhaps.

Finding the stream...

ABC ClassicFM has changed their web site and also their streaming method over the last few months, making life a little more difficult! There are no longer copies of older broadcasts of "For The God Who Sings" for easy download and the main live ABC ClassicFM broadcast is now a 64k aac rtmp stream. The direct url for the stream can be found with WireShark, as I have done, and this can be played back as follows:

rtmpdump -r "rtmp://cp112896.live.edgefcs.net/live/classic_fm@40676" \
         --swfVfy "http://www.abc.net.au/res/players/aacPlayer.swf" \
         --pageUrl "http://www.abc.net.au/classic/player/" \
         --live --verbose --timeout 240 -o - | mplayer -cache 2048 -

But connection with rtmpdump to this stream is more than a little precarious and I would not trust it for downloading a 2 hour stream. The alternative is unfortunately a Windows-specific link which nevertheless runs much more reliably than the rtmp stream:

mplayer -playlist "http://abc.net.au/res/streaming/audio/windows/classic_fm.asx"

There are several other streams to choose from but the ABC people have requested the two streams above be used so I am trying to be a good citizen about the whole thing and thus this is the stream we will use!

Scripting the stream...

The real magic of course lies in actually capturing the stream live as it is broadcast and I have developed a small script to do this for me automatically every Sunday night. I have named the following script ftgws_download.sh and it lives in /home/andrew/bin:

#  A very simple script to capture the live radio broadcast of:
#             'For the God Who Sings'
#  Tested with the svn Mplayer and oggenc 1.4.0

# Most of the variables:

DATE1=$(date +"%d%m%Y")
DATE2=$(date +"%d-%m-%Y")



# Download the stream and convert it to wave format:

mplayer -cache 2048 -playlist $STREAM \
        -vc null -vo null -ao pcm:fast:waveheader:file=ftgws.wav &

sleep $DURATION # Length of the program being recorded as background. 
kill $!         # End the most recently backgrounded job = mplayer

# Convert to ogg format and place the appropriate tags:

oggenc -q 6 ftgws.wav \
         -t "$DATE2" \
         -l "For the God Who Sings" \
         -a "Stephen Watkins" \
         -o ftgws_$DATE1.ogg 

# Clean up:

rm ftgws.wav

The script is run from cron as follows:

# Runs the ftgws_download.sh script every Sunday:                               
25 22 * * sun /home/andrew/bin/ftgws_download.sh

So all that remains is for you to open up your favourite command line player ogg123, MPlayer or whatever you choose, sit back and prepare to be enchanted for 2 beautiful hours as you listen to "For the God Who Sings" with Stephen Watkins.

Trimming a little...

I have allowed a little 'sneeze factor' at the beginning and end of the broadcast to allow for programming glitches at the ABC end so if you are a perfectionist you may like to trim the extra minutes off? I use the following FFmpeg syntax that becomes a little complex because I have found that the metadata does not always come over:

ffmpeg -i input.ogg -ss 00:06:00 -t 02:00:03 -c:a copy \
   -metadata title="$(vorbiscomment --list input.ogg | grep 'title' | cut -d '=' -f 2)" \
   -metadata artist="$(vorbiscomment --list input.ogg | grep 'artist' | cut -d '=' -f 2)" \
   -metadata album="$(vorbiscomment --list input.ogg | grep 'album' | cut -d '=' -f 2)" \

Obviously the names of input and output files need to be altered and the commencement time for the 'seek stream' option also needs to be tailored to suit the exact broadcast. I will work on this one a little, it is untidy at the moment!

And in conclusion ...

I have found immense enjoyment in writing this page and my pleasure will be redoubled if you have profited by any of the material on this page. Send me an email and let me know! Importantly I am still having a great and productive time in the world of Linux and I feel as if I have joined a community and am contributing to it. What about you?