<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Dan Ruscoe's Blog</title>
	<atom:link href="http://danruscoe.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://danruscoe.com/blog</link>
	<description>Blog of a web developer in Green Bay, WI</description>
	<pubDate>Wed, 11 Jun 2008 01:55:20 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Streaming Radio to mp3</title>
		<link>http://danruscoe.com/blog/streaming-radio-to-mp3/</link>
		<comments>http://danruscoe.com/blog/streaming-radio-to-mp3/#comments</comments>
		<pubDate>Tue, 10 Jun 2008 03:28:48 +0000</pubDate>
		<dc:creator>ruscoe</dc:creator>
		
		<category><![CDATA[Guides]]></category>

		<category><![CDATA[bbc]]></category>

		<category><![CDATA[manchester]]></category>

		<category><![CDATA[mp3]]></category>

		<category><![CDATA[streaming radio]]></category>

		<guid isPermaLink="false">http://danruscoe.com/blog/?p=3</guid>
		<description><![CDATA[How I made mp3s from the BBC's streaming online radio to create a personal podcast of a show I enjoy.]]></description>
			<content:encoded><![CDATA[<p>When I worked in Manchester, I&#8217;d listen to Allan Beswick&#8217;s lunchtime radio show on BBC Radio Manchester (95.1 FM). The BBC streams <a href="http://www.bbc.co.uk/radio/aod/mainframe.shtml?http://www.bbc.co.uk/radio/aod/manchester.shtml" title="BBC Radio Manchester">Beswick&#8217;s show online</a>, so I can still listen here in Wisconsin, but what I really wanted to do was get the show as a podcast so I could listen to it wherever I was.</p>
<p>The BBC provides a lot of good radio shows as podcasts, but not the one I&#8217;m interested in. I did some research and found a way to make my own podcasts from the BBC&#8217;s streaming audio using my PC running Ubuntu Linux.</p>
<p>The media player MPlayer can be given this command to record an audio stream to a file:</p>
<div class="code">
mplayer -playlist http://www.bbc.co.uk/radio/aod/shows/rpms/manchester/allan_beswick_manc.rpm -ao pcm:file=&#8221;/home/dan/allan_beswick/beswick.wav&#8221; -vc dummy -vo null
</div>
<p>The URL used above was retrieved from the BBC iPlayer using Firefox. I accessed the Page Info (right-click menu) of the iPlayer page that played the streaming audio I wanted, selected the Media tab and found the URL as an embed in the list.</p>
<p>To explain the switches used in that command, -playlist is used because the URL retrieved from the BBC iPlayer isn&#8217;t a direct link to the audio stream we want to capture. When I looked into recording streaming audio, I found that streaming audio services like this normally provide audio players with a file containing a playlist of audio streams. In this example, the playlist file is located at the URL shown in the command above.</p>
<p>-ao is used to specify the output file for the stream.</p>
<p>-vc dummy and -vo null prevent MPlayer from attempting to find and play any video content, as there isn&#8217;t any.</p>
<p>Running the command will cause MPlayer to output some information about the steam to the terminal. I&#8217;ve trimmed down the output here to show a few interesting parts.</p>
<div class="code">
Resolving www.bbc.co.uk for AF_INET&#8230;<br />
Connecting to server www.bbc.co.uk[212.58.253.71]: 80&#8230;</p>
<p>Playing rtsp://rmv8.bbc.net.uk/england/radiomanchester/aod/allan_beswick.ra?BBC-UID=84076f367e62512a2b98bcba80b0972372b2525bb0b0b154048f98b17feb5665_n&#038;SSO2-UID=.
</p></div>
<p>This is the audio stream specified in the playlist file at the URL given to MPlayer.</p>
<div class="code">
Resolving rmv8.bbc.net.uk for AF_INET&#8230;<br />
Connecting to server rmv8.bbc.net.uk[212.58.252.5]: 554&#8230;</p>
<p>REAL file format detected.<br />
Stream description: audio/x-pn-multirate-realaudio logical stream<br />
Stream mimetype: audio/x-pn-realaudio<br />
Clip info:<br />
 name: Allan Beswick<br />
 author: BBC Radio Manchester<br />
 copyright: (C) British Broadcasting Corporation 2008
</p></div>
<p>Some information about the audio stream.</p>
<div class="code">
Video: no video<br />
Starting playback&#8230;<br />
A: 112.9 (01:52.9) of 6861.0 ( 1:54:21.0) 90.0% 0%
</div>
<p>A progress indicator. MPlayer is 1 minute and 52 seconds into the stream here.</p>
<p>MPlayer will output a wav file. The following line will use lame to convert the file to an mp3 file.</p>
<div class="code">
lame -h /home/dan/allan_beswick/beswick.wav -o /home/dan/allan_beswick/beswick$(date +%m%d%Y).mp3
</div>
<p>I put those commands into a bash script that runs as a cron once daily between Monday and Friday and I have Allan Beswick&#8217;s radio show ready to load onto my iPhone once a day.</p>
<p>The bash script I use, shown below, adds dates to the mp3 files it produces for organization.</p>
<div class="code">
#!/bin/sh</p>
<p>mplayer -playlist http://www.bbc.co.uk/radio/aod/shows/rpms/manchester/allan_beswick_manc.rpm -ao pcm:file=&#8221;/home/dan/allan_beswick/beswick.wav&#8221; -vc dummy -vo null;<br />
lame -h /home/dan/allan_beswick/beswick.wav -o /home/dan/allan_beswick/beswick$(date +%m%d%Y).mp3;<br />
rm /home/dan/allan_beswick/beswick.wav;
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://danruscoe.com/blog/streaming-radio-to-mp3/feed/</wfw:commentRss>
<enclosure url="http://www.bbc.co.uk/radio/aod/shows/rpms/manchester/allan_beswick_manc.rpm" length="0" type="audio/x-pn-realaudio-plugin" />
		</item>
	</channel>
</rss>
