A lot of people have been talking about Raspberry Pis lately so I decided to do some digging of myself. Radio Enfield used to stream their audio from an old Windows desktop computer which had edcast installed to stream the audio input to our Shoutcast server. It worked perfectly well, but the computer itself was unsightly, used up too much space and it’s fan was a little bit noisy (for a radio environment!).
Andy Whiting, Station Engineer for Radio Enfield, had bought a RPi for Radio Enfield with the idea of using the small, credit card sized, computer to stream the audio instead of the bulky desktop pc. After a while of having to learn basic Linux commands (using google as my reference) to navigate the file structure, and after many error messages appearing we finally got it working. This is how it was achieved…
What we used:
- Raspberry Pi – Model B – Running Raspbian OS.
- USB Audio Input – We used the Behringer UCA202 USB audio interface.
It was great to find a post that someone else had tried to stream audio from a Pi before. By following the step by step instructions on this site http://www.t3node.com/blog/live-streaming-mp3-audio-with-darkice-and-icecast2-on-raspberry-pi/ It allowed us to succesfully install darkice and lame encoders.
From this, we could then configure it to send audio to Shoutcast. This is done in the darkice.cfg file. Our config file, for sending to one of our Shoutcast servers looks like this:
[general] duration = 0 # duration of encoding, in seconds. 0 means forever bufferSecs = 2 # size of internal slip buffer, in seconds reconnect = yes # reconnect to the server(s) if disconnected # this section describes the audio input that will be streamed [input] device = hw:1,0 # this references to the audio hardware input sampleRate = 44100 # sample rate in Hz. try 11025, 22050 or 44100 bitsPerSample = 16 # bits per sample. try 16 channel = 1 # channels. 1 = mono, 2 = stereo # this section describes a streaming connection to a ShoutCast server # there may be up to 8 of these sections, named [shoutcast-0] ... [shoutcast-7] # these can be mixed with [icecast-x] and [icecast2-x] sections [shoutcast-0] bitrateMode = cbr # constant bit rate mode bitrate = 96 # bitrate of the stream quality = 0.5 # encoding quality server = xx.xx.xx.xx # host name of the server port = 8001 # source port of the ShoutCast server, usually 8001 password = xxxxxxxx # source password to the ShoutCast server name = Radio Enfield # name of the stream url = http://www.radioenfield.co.uk # URL related to the stream genre = my own # genre of the stream public = yes # advertise this stream?
We encountered some problems when trying to connect the RPi to the stream, but these were easily rectified. Our first problem was that were were using the wrong port number. We had to make sure we were using our client port number +1, for example if the client port number was 8000 – darkice would need to be pointed to port 8001.
Once this was corrected we could then run darkice with the command:
This should then start streaming whatever is received on the USB audio input. To fully set up the RPi as a robust streaming machine, we used a crontab command to automatically run the darkice program upon reboot.
To do this we opened up the crontab file to edit using:
sudo crontab -e
and added the following line, making sure that no #’s were in front of it.
After this, the RPi can be powered off, and when power was reconnected it will automatically start streaming audio to the Shoutcast server.
[Update Feb 2015] After using the Pi as our streaming tool for nearly a year now, I thought it would be a good idea to provide some feedback as to how it’s going.
Overall using the Pi to stream to a Shoutcast server works well, there’s no doubt that the Pi can be used as a basic streaming device. However, after multiple attempts, we have never been able to stream in stereo, instead the most it can cope with is darkice’s mono function, which isn’t mixed mono, but rather single legged, so when playing songs that have vocals panned L, guitar R, or whatever, we inevitably never hear one of them.
Another issue which we have encountered is that after a while the streams output seems to stutter, we have countered this by adding a cron task to reboot the Pi at 4am daily, as it seems the problem lies with the Pi’s small memory. Maybe the latest Raspberry Pi 2 will be able to cope with this better?
The biggest plus point of streaming using the Pi is the price, and the lack of a fan, meaning the Pi can be in the same room as the presenters without creating a background hum of computer fans spinning.
[Update Aug 2015] After buying a Raspberry Pi 2, with increased memory capacity, this has resolved many issues we used to have. We are now broadcasting in stereo! and to two separate Shoutcast servers with no issues as yet! I have yet to test the stutter issue we has on the old Pi yet, and still do a daily reboot.