streaming multiple DAB channels from an RPi

There are any number of ways to listen to BBC radio over the web.  You can use iPlayer for live and catchup, or you can stream to a client using one of the many published urls.

But to save my bandwidth I decided to stream the BBC’s DAB over my local network using a spare DVB-T USB stick.  Although I used a Raspberry Pi for the guide, it would work equally well with any modern Linux distro.

Throughout this guide my RPi has a hostname of ‘raspberry’: replace this with your own hostname or ip address as appropriate.

Configure the receiver

This really couldn’t be easier with a modern distro like raspian.  Plug in the USB stick (I used a KWorld USB DVB-T TV Stick II (VS-DVB-T 395U)) and find out the usb vendor and device ID.

pi@raspberry ~ $ lsusb
 Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
 Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
 Bus 001 Device 004: ID 1b80:e39b Afatech DVB-T395U [af9015]

You can see the chip on the DVB-T stick has been identified as an Afatech with a vendor id of 1b80 and a device ID of e39b.  Look up the support status of your stick at linuxtv, and follow the link to find the extracted firmware for your device.  Download the firmware to the /lib/firmware directory.

cd /lib/firmware
sudo wget firmware_url_from_linuxtv

You will need to unplug and replug the USB (or reboot if you wish) for the firmware to be loaded.  Finally, we need to install some dvb tools, and scan for the DAB channels.

sudo apt-get install dvd-apps

will install a number of tools, but we shall only need ‘scan’.  You also need to know which transmitter serves your area (I’m on Winter Hill) which you can find out here.  Run the following command, replacing Winter Hill with your own transmitter, which creates a file of the channels which your DVB-T is actually receiving.

scan -x 0 /usr/share/dvb/dvb-t/uk-WinterHill > channels.conf

And have a look at the contents

BBC Radio 1:801833000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:0:1002:6720
BBC Radio 2:801833000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:0:1102:6784
BBC Radio 3:801833000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:0:1202:6848
BBC Radio 4:801833000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:0:1302:6912

You can see here that all the BBC radio stations are on the same multiplex, with a frequency of 801833000 Hz, and Radio 4 has a sid of 6912.  There are a number of ways of streaming multiple channels from the same multiplex which we will now explore.

 Streaming with VLC

VLC is the Swiss Army Knife of media players, and also streams media in any number of formats.  First off, install vlc (I’m installing the cli only, hence the ‘No X’).

sudo apt-get install vlc-nox

As a simple test, run the following command on the RPi and it will stream BBC Radio 4 from you DVB-T stick.  Remember to replace frequency and program with your own values from above.

vlc dvb:// --dvb-frequency=801833000 --dvb-bandwidth=8 --dvb-transmission=8 --program=6912 --sout '#std{access=http,mux=ts,dst=raspberry:8004,name="BBC Radio 4"}'

and on the client

vlc http://raspberry:8004

and enjoy!  There is a fairly easy way to stream two or more stations but it doesn’t seem to work on the current build.  Additionally, initial playback seems very jerky while vlc reads the EPG.

Streaming with MuMuDVB

MuMuDVB  is an easier way to stream multiple channels, and will actually multicast a whole multiplex onto the local network.  Firstly, install the software, and add the server user to the ‘video’ group so it has appropriate permissions for the DVB card.

sudo apt-get install mumudvb

sudo adduser _mumudvb video

And create a config file (I’m using /etc/mumudvb/bbc.conf) with the following contents.

freq=801833

multicast_ipv4=0
multicast_ipv6=0
unicast=1

autoconfiguration=2
autoconf_radios=1
autoconf_sid_list=6720 5888 6784 6848 6912 5824 5632 5696 5760

Some of these options need a little explanation.  Multicast kills my local network due to my crappy consumer grade ADSL router, so you can see the switches to turn that off and turn unicast on instead.  The freq is the frequency of the multiplex we want in MHz, not the Hz that we identified earlier..  Finally, we want full autoconfiguration, including radios, but only to stream the listed channels (The sids of all the radio channel – Radio 4 is 6912 as before) as the RPi struggles to stream all the TV channels and I don’t need them.

Change the setting in the /etc/default/mumudvb as follows (there are other options but the don’t need changing)

DONTSTARTMUMU=false
MUMUDVB_CONF_0="/etc/mumudvb/bbc.conf"

and start the service

sudo service mumudvb start

Then all you need to do is play your chosen channel.  Visiting http://raspberry:4242/channels_list.html with your browser will show you the streaming channels and their links, but the general format is http://raspberry:4242/bysid/6912 (where 6912 is the channel sid, BBC Radio 4 in this case).  So try

vlc http://raspberry:4242/bysid/6912

and you should be listening to Radio 4 DAB, streamed over your LAN by a Raspberry Pi.