How to stream Freeview HD (DVB-T2) over multicast using dvblast, you Idiots
This is a follow-up to my earlier post, How to stream EVERY channel from Freeview onto your network. If you’re new to this, you’ll want to go and read that one first, or a lot of this article won’t make sense.
Almost a year ago now, the first DVB-T2 USB tuner shipped in the form of the pctv 290e nanoStick T2, and work began on getting it working under Linux. Thanks to the sterling efforts of the developer community, working drivers for this tuner (which is based on the Sony chip) are now shipping as standard with Linux distros that use a kernel version of 3.0 or greater. This includes the recently released Ubuntu 11.10, and since this was my distro of choice for my previous DVB streaming project, I upgraded my streaming server and finally went ahead with buying a nanoStick tuner.
At the time of writing, the 290e nanoStick T2 was coming in at just under £80 on Amazon. It comes with a bunch of Windows software I haven’t bothered to look at yet, and few different accessories (including a next to useless sucker-cup portable aerial), but these are the bits from the package you need.
The tuner itself is the size of a fat flash drive, and is about the same weight. That said, you’ll probably still want to use the the included USB flylead to help prevent strain on the USB connector, and you’ll also need the aerial adaptor.
As expected, Ubuntu detected the tuner immediately and I could tune to a standard definition DVB-T signal straight away using VLC. But we’re not interested in that! We want DVB-T2, for some proper HD goodness. So, lets get started.
Are you ready for this?
Before you get ahead of yourself, make sure you have the following in place unless you want to make things stupidly difficult for yourself:
- Make sure you are within range of a transmitter that broadcasts in HD. Honestly, you should probably have checked this before you bought the tuner. In the UK, if your area has been through the digital switchover (i.e. analogue broadcasts have been switched off), then you should be able to get Freeview HD. Some pre-DSO transmitters (such as Crystal Palace in London) also carry HD, but not many of them. Check here if in doubt.
- Make sure your Linux install (I used Ubuntu for this guide) is up to date and running a kernel version of 3.0 or later. For Ubuntu, that means installing version 11.10 or later.
- Make sure your clients have some fizz in them (the machines receiving the stream, not the server). That old Pentium 4 you’ve got lying around will not have enough processing power to decode an MPEG4 HD stream. It will look awful, if it picks it up at all. Do not come crying to me.
- Make sure your network connection can handle it. In my previous guide I recommended you have a 1Gbps connection for the machine doing the streaming, though it wasn’t essential. Well, bad news. If you are already running a bunch of standard definition DVB streams off of the machine, adding 4 HD streams (about 40Mbps extra) will almost certainly push you over 100Mbps, so you really do need a 1Gbps connection now, unless you cut down on the number of channels you want to stream. An alternative would be to add a second 100Mbps network card and split the broadcasting across the two by binding dvblast, but I don’t cover that here because you need to do some damn work yourself, you lazy gits.
Getting the program data
Previously, we used the config files from the dvbapps project to scan for programme data. Unfortunately, due to the digital switchover going on in the UK at the moment, the dvbapps files are not 100% up-to-date for all transmitters. I receive Freeview from the Crystal Palace transmitter, and the details for the HD multiplex are missing.
UPDATE 08/05/13: I’ve recently blogged about using a different scan tool called w_scan that eliminates the need to find out the frequency information in advance, so you can use that method and skip straight to writing the config file if you want a shortcut.
The important bits are circled. The most important bit is the frequency in Hz (not MHz, so multiply by 1,000,000), but also useful is 256QAM (which we reverse into QAM256), the 2/3, and the 32k.
A line for one of the SD multiplexes from the dvb-apps config file for Crystal Palace looks like this:
T 505833000 8MHz 3/4 NONE QAM16 2k 1/32 NONE
Hopefully you can see where the values 554000000, 2/3, QAM256, and 32k can be substituted in here (your values may vary, obviously). The 8MHz stays as 8MHz, so the only value missing is that to replace the 1/32 (which is the guard interval). According to DVB.org, Ofcom specify this as 1/128 for UK DVB-T2. So, we end up with the following, which I saved into a file named uk-CrystalPalaceHD:
T 554000000 8MHz 2/3 NONE QAM256 32k 1/128 NONE
Now run a scan:
scan ~/uk-CrystalPalaceHD -u > channels.txt
The scan command complained about not recognising some of the parameters given in the file, but performed a successful scan anyway (including the SD channels on the same transmitter). The important bits were as follows:
BBC HD:554000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_AUTO:QAM_256:TRANSMISSION_MODE_AUTO:GUARD_INTERVAL_AUTO:HIERARCHY_AUTO:101:102:17472 BBC One HD:554000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_AUTO:QAM_256:TRANSMISSION_MODE_AUTO:GUARD_INTERVAL_AUTO:HIERARCHY_AUTO:6601:6602:17540 ITV1 HD:554000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_AUTO:QAM_256:TRANSMISSION_MODE_AUTO:GUARD_INTERVAL_AUTO:HIERARCHY_AUTO:201:202:17604 Channel 4 HD:554000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_AUTO:QAM_256:TRANSMISSION_MODE_AUTO:GUARD_INTERVAL_AUTO:HIERARCHY_AUTO:301:302:17664
Write your config file
As in the previous guide, this gives us enough information to build a config file for this multiplex to use with dvblast, by taking the SID value from the last column of each row and assigning it to a multicast IP address:
126.96.36.199:5004 1 17472 188.8.131.52:5004 1 17540 184.108.40.206:5004 1 17604 220.127.116.11:5004 1 17664
I saved this file as mpsb3.cfg (as this multiplex is called PSB3 on the Crystal Palace transmitter).
Time to upgrade dvblast
Now, at this point you might be thinking, “hey, all that’s left is to run dvblast”, but unfortunately for you, life is never that simple. As of May 2013, the stable version of dvblast that is available from the standard Ubuntu repositories is version 2.2-1, and that will work fine, but if a version below 2.0 isn’t yet available in your distro repository, you’ll need to compile and install at least version 2.0 from VideoLAN’s git repository. I removed the installed version of dvblast 1.2 first, just to be on the safe side.
(You should issue the following commands from somewhere in your home directory to avoid leaving source code directories in random places on your machine.)
First install git either through subversion or by running apt-get from the command line:
sudo apt-get install git
First we need to fetch and install the bitstream library,which is the only pre-requisite for dvblast:
git clone git://git.videolan.org/bitstream cd bitstream sudo make install
Now issue the following commands to get the latest source for dvblast and compile it:
git clone git://git.videolan.org/dvblast cd dvblast sudo make install
(I didn’t have to tweak the makefile at all during my test on Ubuntu. Your mileage may vary.)
… and we’re finally ready
Right, after all that tedious rubbish, we are ready to actually run dvblast and watch some HD television.
sudo /usr/local/bin/dvblast -f 554000000 -c ~/mpsb3.cfg -m qam_256 -b 8
If you remember the command from my previous guide, you’ll notice I’ve left off the -e directive, which sends the over-the-air EPG data to the network. I’ve left this off because VLC can’t read the data (yet). The EPG in DVB-T2 is compressed in a way that differs from the DVB-T implementation, and the libraries that VLC relies on don’t support it yet, so the EPG data is garbled. This is a known issue, and I expect it will be fixed in a future update in the coming months. UPDATE 22/02/12: VLC 2.0 has now been released, which has partial support for the new EPG. Anything it can’t decode will be omitted, rather than garbled, so you can safely add the -e directive for DVB-T2 streams now.
Tip: To reduce skipping, I’ve found it helps to add the -i 1 parameter to the dvblast command line to set it to realtime priority. This is particularly useful if you already have another 6 tuners on the same system streaming regular DVB, as I do. You shouldn’t need to add it to the commands for your other DVB streams, and it would probably be detrimental to do it for all of them.
Other than that, you should then be able to watch a stream with VLC via rtp://18.104.22.168:5004 and find everything working quite nicely:
The BBC HD channel (even though it may not be around much longer) is good for testing because, unlike the other 3 channels currently on Freeview HD, it always broadcasts shows that were shot in HD. Because the others (BBC1, ITV1, and Channel 4) are simulcasts of the regular Freeview channels, some of their content will be upscaled SD, and won’t look much different from the SD broadcast.
Another reason it’s handy for testing is because in the mornings (during the ‘preview’ period) it runs test screens between some of the previews, such as the audio/video sync check signal and the new HD test card:
(More about these here)
For details on setting up SAP announcements for the streams, and setting everything up to run at boot time without having to start dvblast manually, refer back to my earlier Freeview streaming guide.
As of today, you’ll be shelling out £80 to essentially upgrade 3 (and a bit) of your Freeview channels to HD. This is definitely an optional extra compared to the much better value of getting every Freeview channel available with standard definition tuners, as covered in the earlier guide. It will, however, still be cheaper than buying an Exterity IPTV gateway.
It is worth noting that while BBC channels in particular are available online, you cannot currently get a live stream in HD from iPlayer (and I suspect it will be a year or two at least before that becomes available). If you have HD at home already, you’ll know that for big events (especially sports), HD makes a difference, and if you have some decent projectors in school, it might be well worth spending that little extra.
On a related note, I have learned over the last couple of days that watching cookery shows in HD is a very good way of making yourself hungry.
Was this guide useful? Useless? Do I have a glaring typo or a completely broken script? Feedback in the comments.