What you will need:
Ė Some technical knowledge.
You could say this is quite an ambitious project and youíll need to be able to do things like install linux on a dedicated machine, install tuners, get drivers working etc. If all this is new to you, good luck, and I still recommend you give it a go, but I canít promise Iíll be able to help you if you get stuck. Admittedly I got it all working within a couple of hours, and at the time of first setting this up, I was quite a linux novice. Through this project, I have acquired a lot of skills and knowledge of linux, so for me itís been very good.
- Actually a bit of technical [networking] knowledge
Sweet so you have some linux knowledge maybe? Thatís great but this could become quite an intermediate to expert project. It really depends on the network youíre plugging the TV Box into.
I would highly recommend at minimum you use a Gigabit Switch in your network. Thereís quite a lot of ways you could have the traffic flow to clients, and each configuration suits different scenarios. E.G. If you have specific hosts purely for receiving TV, you could simply have a separate VLAN the TV box and clients are connected to. Traffic would then just spam out all connected ports in the VLAN, basically this would be a broadcast network. This probably isnít practical though, and what you would do instead is enable a feature called IGMP Snooping (and possibly filtering). This will probably be satisfactory enough for small networks, but if you are running the multicast over a layer 3 network, you will need to have a look at PIM-DM or PIM-SM.
Iím a network engineer but found this project quite full on getting it working throughout the network itís currently running in (quite a few layer 3 switches using PIM-SM). I put this under intermediate to expert because if youíre running this through a layer 3 network, thatís exactly where itís defined by Cisco. Cisco documentation and configuration is minimal in the Cisco CCNP curriculum, and only the CCIE Routing and Switching book will you find a bit more detail. If your network is small and all you have is a managed layer 2 switch[s] youíre probably fine, as youíll only need to enable IGMP Snooping and possibly filtering on your devices. Donít let above drive fear into you in trying to set this up, but you may just need to do a bit of background reading on multicasting
-At least 1 Terrestrial or Satellite TV tuner.
This really comes down to your budget and how many channels you want to be able to stream. Basically you will need at least 1 tuner per frequency for channels you want to receive. Here in Christchurch NZ, we currently have 16 TV channels and 3 Radio stations transmitted over 3 frequencies. This means I only need 3 tuners to be able to stream all channels at once. Effectively 1 dual TV card and 1 single tuner.
- Dedicated PC
This could just be an old 1GHZ pc with 1gb of ram. Nothing fancy, as weíre simply sending the received digital data and multicasting the traffic on to the network. A 1Gbit Network card would be recommended though. Make sure you have enough free PCI/PCI-E/USB ports for Tuners though.
The box after inserting several NICs and the Tuners

Post OS installation

I wonít go into detail with physical installation, nor installing your choice of linux (I recommend Ubuntu 12.04) but once you do have it installed, probably the first thing Iíd suggest you do is make sure your tuners are coming up correctly and working. Simply open a terminal and enter ďls /dev/dvb/Ē
Depending on how many tuners you have, you should see adapter0 and up for each tuner. If you donít see any tuners, itís probably time to start googling support for your tuner, but you can also find more log info by typing dmesg. Iím simply suggesting all this as the HVR2210 didnít work out of the box for me. If you have this card, I believe my solution was:

 cd /lib/firmware/  sudo wget http://www.steventoth.net/linux/hvr2...010-03-10.1.fw  Reboot the machine

Still with me? Lets get started!
Programs to install:

  • Ubuntu 12.04
  • VLC 2.0.1 Ė Possibly not needed, but very helpful for diagnosis
  • Vino Ė VNC Server that comes with Ubuntu
  • dvb-apps (A package containing various different tools for dvb cards)
  • dvblast (Made by the same people as VLC. This is what multicasts all the channels out)
  • minisapserver (for creating the channel playlist in VLC)
  • udpxy (converts the RTP multicast streams into unicast HTTP streams. Currently useful for viewing the TV streams on wireless devices.)

Open a terminal and enter the following:

 sudo -s  apt-get update  apt-get install dvb-apps minisapserver vlc
You could also simply add dvblast to that list above, but I believe I had issues with SD channels (sound not working) which resulted in me needing the current unstable version. More info is available on the commands below again on another Angry Tech post, but simply copy and paste below in a terminal and it ďshouldĒ install fine. Iíve done this on linux mint and ubuntu with no issues.

sudo apt-get install git  	git clone git://git.videolan.org/bitstream  	cd bitstream  	sudo make install  	git clone git://git.videolan.org/dvblast  	cd dvblast  	sudo make install

DVBlast is now installed so we can now get on to the first step which is scanning your local terrestrial tower. DVB-apps comes with some configs for different terrestrial towers, and you can see if your local one already exists by typing ďls /usr/share/dvb/dvb-t/Ē
In my case, my local tower here in Christchurch New Zealand didnít exist, so I just entered ďsudo geditĒ into a terminal, which opens the gui text editor, and created and saved the following:

 Sugarloaf, Christchurch NZ
 # Channel allocation details for NZ can be found at
 # http://www.rsm.govt.nz/cms/policy-and-planning/current-projects/broadcasting/digital-television-2007-frequency-plan
 # T freq bw fec_hi fec_lo mod transmission-mode guard-interval hierarchy

 # Multiplex DA
 T 562000000 8MHz 3/4 NONE QAM64 8k 1/16 NONE
 # Multiplex DB
 T 578000000 8MHz 3/4 NONE QAM64 8k 1/16 NONE
 # Multiplex DC 
 T 594000000 8MHz 3/4 NONE QAM64 8k 1/16 NONE
I had to find out the frequencies used, which wasnít too hard. Just do a google and find out what your local tower is and what frequencies are used.

Once you have your configuration file sorted, we use a program called ďscanĒ which does just that. It will tell us the all important PIDs (the unique identifiers for each channel) and a lot of other helpful information.

Just run the following command, which will output what it finds into a file called channels.txt

 scan /usr/share/dvb/dvb-t/nz-christchurch -u > channels.txt
If you open channels.txt, you will find something similar to the following:

The only thing weíre really interested in is the Channel, the frequency, and the PID. These are the first and last values, so as an example with the first one, the channel is TV ONE, the frequency is 682MHZ, and the PID= 1200, which I also made bold as you can see.

What you now need to do, is make a config file for each frequency which will then be used for each tuner. So if your local tower has 3 frequencies, you will need 3 config files, and 3 tuners.

Iíd suggest you just make a folder in your home directory called dvb, which you store each config file in.

Below are my 3 config files.


;TV1    1   1200
[ff08::1]:5004@[2001:17:17::1]	    1   1200
;TV2    1   1201
[ff08::2]:5004@[2001:17:17::1]      1	1201
;TVNZU    1   1202
[ff08::6]:5004@[2001:17:17::1]      1   1202
;TVONE+1    1   1205
[ff08::7]:5004@[2001:17:17::1]	    1	1205
Whatís this doing? the semicolon is just specifying a comment purely in this case just to help you identify the channel. Next line in the multicast address chosenort chosen. 1 sets the stream to always be on, followed by the unique channel PID.

If you looked closely you will notice Iím also doing IPv6. IPv6 addresses must be specified in brackets due to using semicolons (which would otherwise be followed by a port). As I mentioned earlier, this machine has several network cards in it. I then have the IPv6 address specified that I want the IPv6 multicast to send out of. Otherwise the stream will default to eth0. This is specific to where this box is used and your set up will probably be quite different.

Note here that you could have used a route in the linux routing table to also specify the out going network card. This is what I had set up before knowing that I could use DVBlast to specify out. The reason I changed it though is because after an unspecified amount of time, routing would stuff up and the IPv6 multicast started sending out with the IPv6 link-local address, not the global-address, which had bad results due to using a layer 3 switched network.

Now that the config files are done, itís time to actually start the streams.

Continuing with my example, put the following 3 commands in separate terminal windows:

For tuner 0 (TVNZ Frequency):
  dvblast -a 0 -c /home/localadmin/dvb/M1.cfg -f 578000000 -m qam_64 -b 8 -e
 For tuner 1 PRIME/KORDIA Frequency): 
  dvblast -a 1 -c /home/localadmin/dvb/M3.cfg -f 594000000 -m qam_64 -b 8 -e
 For tuner 2 (Mediaworks Frequency):
  dvblast -a 2 -c /home/localadmin/dvb/M2.cfg -f 562000000 -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.
 -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. 
 -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.
If you wanted to do them all in 1 terminal, just put ď&Ē on the end of the command, enter, then the next dvblast instance.

Now you should be able to open VLC and type in each multicast address to view each stream (provided you have a route on your host [and the sever] to the multicast range.