In this post I'll be talking about how to set another computer to act as a server between Beaglebone Black and Internet. Initially I was planning to use ffmpeg and ffserver but after a week of banging my head against the wall, I couldn't make it work. It would've been nice as I was planning to pipe the stream coming from netcat to ffmpeg so that lets say if I have two Beaglebone Blacks with their own RTL dongles with different ports, I could've streamed both radio stations from the same streaming server. Then I started thinking and decided to use a patch cable to connect my sound card's audio out to its line in and use ffmpeg to capture from line in. This also didn't work. While I was looking around for a solution, I found a blog post about streaming with icecast and darkice.

 

System Setup

I'm using an Ubuntu Desktop 12.04 as my streaming server. aplay comes default but for an Ubuntu Server system, you have to install that too. Now install icecast and darkice with

sudo apt-get install icecast2 darkice




During installation, it will ask you if you want to configure icecast. I chose not to and decided to use the default port and password but if you're going for development, it would be wise to change at least the default passwords. After installation, you also have to edit /etc/default/icecast2 to change line with ENABLE=false to ENABLE=true. After this, I created a configuration file darkice.cfg in my home directory with the following content:

[general]
duration = 0
bufferSecs = 1
reconnect = yes
[input]
device = default
sampleRate = 44100
bitsPerSample = 16
channel = 2
[icecast2-0]
bitrateMode = vbr
quality = 1.0
format = mp3
bitrate = 256
server = localhost
port = 8000
password = hackme
mountPoint = radio.mp3
name = radio




 

You can now either reboot your system or start icecast with:

sudo /etc/init.d/icecast2 start



 

Streaming

Now I ssh into Beaglebone Black and tune into NHK Radio (82.5 MHz) with:

root@beaglebone:~# while true; do rtl_fm -f 82.5M -s 44.1k - | netcat -l -p 8080; done



 

You may decide to put this as a script to be run at boot time or use screen, run it and detach. On the streaming server, I also use screen as I need multiple consoles and again, I need the commands to run even if I cut my ssh connection. I open up two consoles, in one start darkice with:

sudo darkice -c darkice.cfg



 

In the other, I start playing the received audio with aplay:

netcat 192.168.1.5 8080 | aplay -r 44.1k -t raw -c 1 -f S16_LE



 

As I have an audio patch cable connected, I don't have to use jack or set up a pulse monitor. So here is the network diagram explaining this system.

 

rtl_sdr.png

 

And also here is a video with the usage. The first thing I do is go to the stream page and let my browser play the stream. Then I go to icecast status page and click the playlist link and it opens Media Player by default.