How to stream EVERY channel from Freeview onto your network
So, you’ve read my guide to streaming Freeview via VLC, and you’re thinking, ‘that was too easy’. What’s next? Well, we’ve streamed one channel, and you could potentially leave that running for your users… but what if someone wants to watch a different channel?
How about streaming ALL the channels?
I’m so glad you asked.
In my last school we had an Exterity IPTV system that I had been quietly jealous of ever since I left it behind. A commenter on my last article had the same system, but was less enamoured of it on account of the fact that his was buggered. Certainly a distressing situation to be in given how expensive Exterity is: buying the full 6-tuner system from RM will set you back over £8,000. They may not be the cheapest supplier, but you get the idea.
The thing is, these systems are a few years old, and the world has moved on. Today, free open-source software exists that will let you and I build something to do roughly the same thing for less than £500.
Yes, £500. You’re welcome.
This is a very technical article, so if you’re only here for me ranting about HP, this isn’t for you.
You will need
Your brain, again. Not only am I still making you think, but this will be a bit harder than my guide to streaming a single channel, and it’s not going to be a step-by-step guide due to the complexity.
A spare computer with at least 3 empty PCI slots (or USB 2.0 ports), and preferably with a gigabit Ethernet adapter if you want to stream a lot of channels. If you aren’t planning a high number, you can get away with a 100Mb card; I stream 32 TV channels and 22 radio stations from my box, and it uses about 80Mb of bandwidth (though it should be noted a few of the TV channels broadcast at mutually exclusive times, such as CBBC and BBC3).
This computer will need to run Linux; you can’t just slap some software on that spare Windows XP machine in the corner. I strongly recommend a dedicated unit. The good news is that it doesn’t have to be anything like high spec. You can almost certainly get away with the minimum specs for the Linux distro you choose. I chose Ubuntu because it’s the one I’m most familiar with and the DVB hardware support is pretty good. The machine I used is a 2005 vintage Acer Veriton and it barely tops 10% CPU usage.
A gigabit ethernet switch is preferable at least on the network segment you plug the streaming machine into, and preferably a gigabit backbone throughout your site. You won’t need gigabit to the desktop, however.
6 DVB-T tuner cards (or 3 dual-tuner cards) that work under Linux. Preferably PCI, but you can get USB ones if you’re stuck for PCI slots. I’ll explain why you need 6 tuners later. I’ve been using Hauppage tuners, specifically the WinTV Nova-T 500, because they work well for me and Ubuntu automatically installs drivers that work.
An aerial splitter with at least as many outputs as you have tuners, since you’ll need to plug the aerial into each card. Most of these come with signal boosters built in, which will probably be handy.
A rough idea of which Freeview transmitter you get the best signal from. In my last guide we had to look up the exact frequency details, but there’s software on Linux that can do this for us. You’ll only need to know which transmitter gives you the best signal, so go here and punch in your address. Note that the one with the best signal is not necessarily the nearest one; if you’re within 50-60 miles of London, for example, you might find you get better reception from Crystal Palace than from a much closer transmitter, on account of Crystal Palace having a 20MW trasmitter, one of the most powerful in the country.
Why you only need 6 tuners for all those channels
DVB systems like Freeview don’t broadcast every TV channel on its own frequency like analogue TV does. It groups channels together onto a single frequency using multiplexing. At present, there are 6 multiplexes for standard definition (DVB-T) in the UK: Multiplexes 1, 2, and A-D. Each multiplex has a single frequency. This is why in my previous guide, tuning into a single frequency left you with a small list of channels to choose from in VLC. It’s also why the channel listings on the UK Free TV site are grouped into 6 blocks.
(In the UK, HD Freeview is broadcast on a separate multiplex, using an upgraded encoding method called DVB-T2, but since at the time of writing there are no DVB-T2 tuners for computers on the market, I’m not covering it here. Some current DVB-T tuners say they are “HD”, but this is just marketing BS.)
When your TV tuner picks up a channel, it’s actually picking up the entire multiplex, and just discarding the data for the channels it doesn’t want. Most consumer DVB software (e.g. WinTV, Windows Media Player), and almost all set-top DVB receivers, will only let you watch or record one channel at a time. This is merely a software limitation. You could potentially be watching BBC1 while recording BBC2 and CBBC at the same time with only one tuner, because they are all on the same frequency. The reason most devices restrict you to one channel at a time is because explaining to dumb end users why they can watch BBC1 and record BBC2, but not watch BBC1 and record ITV1, is very hard. So, they restrict you to one channel to prevent the deluge of calls to their tech support line by people who will never understand what’s going on.
You, however, understand. So you can merrily pick up multiple channels on a single tuner. With 6 tuners, you’ve covered every multiplex in the UK, and thus every channel.
Let’s get started
1. First off, get your tuner cards into the machine and get them working under Linux. If you haven’t already done so, you’ll also want to install the following packages using your package management system:
- vlc (useful for testing for tuner card if things don’t quite go to plan)
If you’ve used DVB under Linux before you’ll already be familiar with dvb-apps. The dvblast package is the secret sauce in this project. Developed by the same awesome team that brought us VLC Media Player, dvblast saw its first public release in May 2009. It is a very lightweight program designed for one singular purpose: tune in to DVB broadcasts, and stream them onto a network. That’s all it does. And it does it very, very well. We’ll come on to minisapserver later.
2. Before we start streaming, we need to get the full TV channel details for your local transmitter. To do this, we’re going to use the scan command that comes with dvb-apps, like so:
scan /usr/share/dvb/dvb-t/uk-CrystalPalace -u > channels.txt
That file in /usr/share/dvb/dvb-t/ tells the scan command which transmitter frequencies to check, and is supplied as part of the dvb-apps package. There’s one for each transmitter in the UK (and other countries too). Substitute with the correct file for your chosen transmitter.
Problems with tuning failed!!! messages? Make sure the aerial is plugged in (duh) and if you still have problems, try installing the w-scan package using apt-get and running w_scan -X -c GB > channels.txt instead, as documented here.
You should end up with a file containing a line for each channel that you can pick up, looking like this:
CBBC Channel:505833330:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_3_4:QAM_16:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:620:621:4671 BBC Red Button:505833330:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_3_4:QAM_16:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:0:0:4479 BBC NEWS:505833330:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_3_4:QAM_16:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:640:641:4415 BBC THREE:505833330:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_3_4:QAM_16:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:0:0:4351 BBC TWO:505833330:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_3_4:QAM_16:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:610:611:4228 BBC ONE:505833330:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_3_4:QAM_16:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:600:601:4164 ITV1:481833330:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:520:521:8261 ITV2:481833330:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:530:531:8325 Channel 4:481833330:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:560:561:8384 E4:481833330:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:570:571:8448 More 4:481833330:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:590:591:8442 Heart:481833330:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:0:631:8772 FIVE:481833330:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:540:541:8500 ITV2 +1:481833330:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:600:601:8361
Yours should be longer; this is just some channels from the first two multiplexes. My top tip is to import this into a spreadsheet (delimited by a colon) to get a better view of the fields. Only a few of them are important for us:
- Column A is the channel name.
- Column B is the frequency (in Hz) of the multiplex this channel broadcasts on. The channels will be grouped together in the file by multiplex, so the frequency won’t change on every line.
- Column D is the bandwidth. In the UK it will almost certainly be 8MHz.
- Column G is the phase modulation type for the channel. I won’t try to explain it (you can delve into Wikipedia for that), suffice to say you’ll need to know it later. This should be the same for each channel that broadcasts on the same multiplex.
- Column M (the last one) is the SID (service identifier) for the channel. This is very important as it is what dvblast uses to identify which channel to broadcast. Note that this is not the same as the EPG channel number, which isn’t shown in the file.
Go through this file and pick out which channels you want to stream. You almost certainly don’t want all of them since some are utter tripe and waste of bandwidth, while others are… not exactly suitable for a school, for example.
3. Once you have this data, you need to start writing the configuration files for dvblast. You’ll need one file per multiplex. I find I work best with an example, so here’s my configuration file for Multiplex 1, which carries most of the BBC channels:
18.104.22.168:5004 1 4415
22.214.171.124:5004 1 4164
;BBC Red Button
126.96.36.199:5004 1 4479
188.8.131.52:5004 1 4351
184.108.40.206:5004 1 4228
220.127.116.11:5004 1 4671
The lines starting with a semicolon are comments, and you can write whatever the hell you want there, but I find the channel name is a good idea. The rest is simply a line with three columns: The IP address (and port) to stream the channel to, the ‘always-on’ flag (which you should almost always set to 1) and, importantly, the SID to identify the channel.
The IP addresses I’ve shown here are multicast addresses. I talked about how to pick the IP address to stream to in my last guide, but since you’ve had a beer since then and forgotten it, I’ll repeat it here.
- If your network switches support multicast, pick a multicast address. There’s a long and detailed document from the IANA about picking one, but unless you are already using multicast on your network then you really just need to pick something in the 239.255.000.000–18.104.22.168 range, which is identified by the IANA as the Site-Local Scope. Anything in this range should work. I used 22.214.171.124 as shown below.
- If your network doesn’t support multicast, or you don’t want to use it for whatever reason, then enter the broadcast address for your local subnet.
My addresses are all in the 239.255.1.x range, with the EPG channel number as the last octet. I could have simply gone for 1, 2, 3… etc. It’s up to you.
Time for another example:
126.96.36.199:5004 1 8384
188.8.131.52:5004 1 8448
184.108.40.206:5004 1 8500
220.127.116.11:5004 1 8772
18.104.22.168:5004 1 8261
22.214.171.124:5004 1 8325
126.96.36.199:5004 1 8442
This is the multiplex that carries the rest of the ‘old’ analog channels: ITV, Channel 4, and Five, along with some others. You’ll also notice a radio station in there. Freeview has radio stations on it as well as TV, and they use exactly the same encoding as the TV channels, so we can stream them too. The observant among you will spot that I switched to the 239.255.2.x range, which I did solely because the EPG numbers for the radio stations start at 700, which doesn’t fit into an IP address octet, so I bump the radio stations up to .2 and then subtract 700 from their number to get my last octet. Again, you don’t have to follow this numbering convention.
4. Now you have these files written out with each channel you want to stream… we’re ready to start streaming them. You’ll need to start a separate instance of dvblast for each multiplex, using commands like so:
dvblast -a 0 -c /root/M1.cfg -f 505833330 -m qam_16 -b 8 -e
dvblast -a 1 -c /root/M2.cfg -f 481833330 -m qam_64 -b 8 -e
Here’s what each parameter does:
- -a n tells dvblast to use tuner number n for this multiplex. Obviously, you can’t use each tuner more than one at any one time. Numbering starts at 0, not 1, you idiots.
- -c nameoffile.cfg tells dvblast to use the config file you just write. It doesn’t matter where you save it.
- -f 000000000 is where you specify the frequency for this multiplex. Remember how you noted that down from the scan listing earlier? You better have done, because next you’ll need…
- -m qam_x the modulation type for this multiplex. And then…
- -b n the bandwidth for this multiplex.
- -e Finally, -e tells dvblast to also stream the EPG data. You’ll see how to use this in VLC later, and it’s very exciting. No, really. Shut up, it’s exciting, damnit.
5. Once you’ve started up dvblast, you should be able to start receiving on another machine! Same drill as last time…
Go to the Media menu, and pick Open Network Stream.
Enter rtp://@ followed by the streaming address of the channel you want, e.g. rtp://@188.8.131.52
Now click Play.
6. Now I’m going to show you the extra-exciting EPG interface.
To get to it, go to the Tools menu once a channel is playing, and select Program Guide.
Ta-daaaa! The guide will only show you a couple of programs at first but within about 10-15 seconds or so it should update with the rest of the day’s programming. It’s not the prettiest interface in the world, but you can scroll through and click on upcoming programs to see a synopsis.
If that all worked, you must now be wetting yourself with excitement, but we’re not done yet. Firstly, do you really expect the end users to know about typing in rtp MRLs with multicast IP addresses? What, are you going to give them a list of IP addresses for each channel?
No, of course not.
7. We’re going to set up the Session Announcement Protocol, which VLC can receive, to allow your users (and you) to simply pick the channels from a nice friendly list of channel names. This is why we installed the minisapserver package earlier. All you have to do is write a config file for it, like so:
# sap.cfg - Configuration file of the mini SAP server # Global miniSAPserver options [global] # Number of seconds between announces. 5 is default. Internet announces better use 30. sap_delay=5 # The network interface on which to stream. #interface=eth0 [program] type=rtp name=Channel 4 user=AngryTechnician machine=dvb.angrytech.internal site=http://intranet.angrytech.internal address=184.108.40.206 port=5004 [program] type=rtp name=E4 user=AngryTechnician machine=dvb.angrytech.internal site=http://intranet.angrytech.internal address=220.127.116.11 port=5004 [program] type=rtp name=Five user=AngryTechnician machine=dvb.angrytech.internal site=http://intranet.angrytech.internal address=18.104.22.168 port=5004 [program] type=rtp name=Heart Radio user=AngryTechnician machine=dvb.angrytech.internal site=http://intranet.angrytech.internal address=22.214.171.124 port=5004 [program] type=rtp name=ITV1 user=AngryTechnician machine=dvb.angrytech.internal site=http://intranet.angrytech.internal address=126.96.36.199 port=5004 [program] type=rtp name=ITV2 user=AngryTechnician machine=dvb.angrytech.internal site=http://intranet.angrytech.internal address=188.8.131.52 port=5004 [program] type=rtp name=More 4 user=AngryTechnician machine=dvb.angrytech.internal site=http://intranet.angrytech.internal address=184.108.40.206 port=5004 [program] type=rtp name=BBC News user=AngryTechnician machine=dvb.angrytech.internal site=http://intranet.angrytech.internal address=220.127.116.11 port=5004 [program] type=rtp name=BBC Red Button user=AngryTechnician machine=dvb.angrytech.internal site=http://intranet.angrytech.internal address=18.104.22.168 port=5004 [program] type=rtp name=BBC One user=AngryTechnician machine=dvb.angrytech.internal site=http://intranet.angrytech.internal address=22.214.171.124 port=5004 [program] type=rtp name=BBC Three user=AngryTechnician machine=dvb.angrytech.internal site=http://intranet.angrytech.internal address=126.96.36.199 port=5004 [program] type=rtp name=BBC Two user=AngryTechnician machine=dvb.angrytech.internal site=http://intranet.angrytech.internal address=188.8.131.52 port=5004 [program] type=rtp name=CBBC Channel user=AngryTechnician machine=dvb.angrytech.internal site=http://intranet.angrytech.internal address=184.108.40.206 port=5004
I’m not sure the user, machine, or site fields are necessary, but they were in the example config file I used, so I filled them in. The order you put the channels in is sort of important, as the SAP daemon will send the announcements for each channel one by one, in that order. However, since the users could open up VLC while the announcements are already halfway through, they won’t necessarily be in that order when the user sees them. My advice is to teach your users how to sort the channel listing in VLC (below).
Gerard Sweeney also points out in the comments that you can group the announcements by adding an extra line to each [program] definition like so:
These do however suffer from the same sorting issues as non-grouped channels.
8. Now start the SAP server like so:
./sapserver -c sap.cfg
9. Receiving the SAP announcements is a doddle in VLC 1.0 and upwards (you can do it in earlier versions, but it was more hassle, so just upgrade already):
Open VLC, go to the View menu, and select Playlist.
Click the arrow next to Local Network to expand it, then click Network Streams (SAP). After a few seconds (longer depending on how many channels you have), the list of channels will appear. You can click the top of the Title column to sort alphabetically. Just double-click one to start playing.
Now everything is nice and convenient for playback, but there’s one last thing to do to make life easier for you as the administrator. Remember how you had to start dvblast 6 times, and then start the SAP daemon? You don’t really want to do that manually, do you? Of course not.
10. Let’s get the machine set up to start dvblast and sapserver at bootup. I started doing this using init, but that turned into a colossal pain in the backside because typically it would start up dvblast before the network interface was ready, which would cause dvblast to immediately terminate. Instead, I’m using upstart, which is starting to replace init in Ubuntu and some other distros. One of the many nice things about upstart is that it can trigger something to happen immediately after the network interface becomes ready (and stop the process when the network goes down).
Upstart is very easy to use once you’ve figured out the config file syntax, and since you haven’t yet done that, I’m just going to save you the trouble by posting examples of the scripts I used. Copy these into individual .conf files in /etc/init
# dvb-m1 # description "DVB streaming, Multiplex 1" start on net-device-up IFACE=eth0 stop on net-device-down IFACE=eth0 exec dvblast -a 0 -c /etc/dvb/M1.cfg -f 505833330 -m qam_16 -b 8 -e
# dvb-m2 # description "DVB streaming, Multiplex 2" start on net-device-up IFACE=eth0 stop on net-device-down IFACE=eth0 exec dvblast -a 1 -c /etc/dvb/M2.cfg -f 481833330 -m qam_64 -b 8 -e
And so on for the other multiplexes, then:
# dvb-sap # description "DVB streaming, SAP listings" start on net-device-up IFACE=eth0 stop on net-device-down IFACE=eth0 exec sapserver -c /etc/dvb/sap.cfg
And you’re done. dvblast and sapserver will start up the moment eth0 becomes ready, and will even shut off if eth0 goes down.
All that for under £500
If this has all worked for you, then you’ve managed to build a live TV streaming system for your network that serves all the Freeview channels you want, 24/7. Earlier I said you could do this for under £500. I bought my three WinTV Nova-T 500 dual tuners for less than £60 each, and even adding in an aerial splitter brought my total to under £200. Since I already had an old spare PC knocking around, that was the entire cost of my project. Compare that with the £8,000 for Exterity and you’re laughing all the way to the Bursary.
If this didn’t work out for you, then you may have to figure some things out on your own. This is what I did, and it worked for me. If you have questions, post a comment and I’ll try to answer.
Was this useful? Useless? Do I have a glaring typo or a completely broken script? Feedback on this guide in the comments.