Technical documentation

Technical documentation

Server hardware

The server consists of a Raspberry Pi 3 computer with a 16GB micro SD card, a 3-way antenna splitter and three Media-Tech MT4171 DVB-T tuners. A TV splitter splits the signal from a TV antenna and passes it to individual TV tuners. The n-way splitter can split the signal to n tuners, and each of them can be tuned to one multiplex/frequency. Each multiplex contains several TV channels. Then a stream from TV tuner is passed to a Raspberry Pi computer with Tvheadend TV server software installed. Finally Raspberry Pi streams TV to users connected by a computer network.

The server is available in two versions that differ only in the enclosure:

TV splitters

The larger enclosure is big enough to accommodate a 4-way splitter. Unfortunately, we did not find any RoHS compliant 4-way splitter, so we used a 3-way splitter. There are also thicker versions of Gainta G715 case (G716 and G717) which can accommodate 6 and 8-way splitters. Using a 3-way splitter means that 3 people can watch TV at the same time by selecting any channels from all multiplexes. Each subsequent person must select a channel from the multiplexes already selected by the first 3 people, since each tuner is already tuned to a certain frequency of a multiplex.

TV tuners

We used Media-tech MT4171 tuners suitable for all types of DVB-T streams. If terrestrial television is broadcast in a different standard, i.e. DVB-T2, ATSC or ISDB-T, then other tuners should be used.
Because DVB-T H.264 HD stream has 6-7 Mb/s bandwidth, the server cannot stream more than about 16 DVB-T H.264 HD transmissions due to 100 Mb/s Ethernet port used in Raspberry Pi 3. Likewise, we can calculate limits for H.262, H.265 compressions and DVB-T2, ATSC, ISDB-T standards.

Raspberry Pi 3

It is important to use Raspberry Pi 3 rather than Raspberry Pi 1. Raspberry Pi 1 can hardly stream HD TV to 2-3 users simultaneously. On the other hand, several months of tests have shown that Raspberry Pi 3 is able to stream HD TV channels seamlessly to at least 4 users. It seems that Raspberry Pi 3 can send HD TV streams simultaneously to 15 users, although this test was done only for one hour.

Enclosures

We like the fact that all components are enclosed in one case. We think both enclosures are suitable for other Raspberry Pi projects. Their advantage over existing Raspberry Pi enclosures is that they can accommodate both Raspberry Pi and additional devices connected to the Raspberry Pi via USB.

Server software

Installation and configuration steps made during manufacturing of the server are shown below.

Write image of Raspbian Jessie with PIXEL desktop to micro SD card (www.raspberrypi.org/downloads/raspbian/, tested for ver. 2016-11-25)

Start Raspberry Pi and execute the below commands/steps. Set initial passwords. 

Installation
------------
#total time of installation: about 20 minutes; measured for: RPi 3, class 10 SD card, 20Mb/s Internet download speed
#time of downloading and installing updates may vary

#Change the default password for security reasons!
passwd

#Tuners firmware (download from the Internet and save to /lib/firmware/ directory)
sudo curl -o /lib/firmware/dvb-usb-it9135-01.fw 'https://github.com/OpenELEC/dvb-firmware/raw/master/firmware/dvb-usb-it9135-01.fw' -L
sudo curl -o /lib/firmware/dvb-usb-it9135-02.fw 'https://github.com/OpenELEC/dvb-firmware/raw/master/firmware/dvb-usb-it9135-02.fw' -L

#Additional packages repositories and OS update (~11 minutes)
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61
echo 'deb http://dl.bintray.com/tvheadend/deb jessie release' | sudo tee -a /etc/apt/sources.list #Tvheadend 4.0.8, Jessie is Debian current version
                                                                                                  #todo: update the name when changed
sudo apt-get update && sudo apt-get -y -q upgrade         #-q otherwise displays some information and asks to press Q(uit) key; we do not use
                                                          #PiBakery since it would hang after asking which '/etc/lightdm/lightdm.conf' file
                                                          #to use - the one from the system or the updated one
#Packages installation and preconfiguration (~ 8 minutes)
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install tvheadend  #(~ 6 minutes) will not ask about admin name and password during installation
sudo apt-get -y install tightvncserver xrdp               #(~ 2 minutes) Microsoft Remote Desktop (RDP)
                                                          #tightvncserver package is required for uninstalling RealVNC since Raspberry Pi 3
sudo apt-get -y install mc htop                           #Midnight Commander file manager and htop system monitor (set Hide userland threads: on)
sudo apt-get -y install unattended-upgrades               #(~ 15 seconds)
sudo apt-get -y install expect                            #(fast) used to change Tvheadend admin password in command line in automated configuration

in /etc/apt/apt.conf.d/20auto-upgrades file set: APT::Periodic::Update-Package-Lists  "1";
                                                 APT::Periodic::Unattended-Upgrade    "1"; 
in /etc/apt/apt.conf.d/50unattended-upgrades file uncomment and set: Unattended-Upgrade::Origins-Pattern       { ... "o=Raspbian,a=stable"; ... }
                                                                     Unattended-Upgrade::Automatic-Reboot      "true"
                                                                     Unattended-Upgrade::Automatic-Reboot-Time "03:30";
                                                                     Acquire::http::Dl-Limit                   "2048";
in /etc/default/rcS file uncomment and set: FSCKFIX=yes  #try to automatically repair problems with file system consistency
                                                         #(otherwise Raspberry Pi will stop during boot and wait for human intervention)

#Restart Raspberry Pi (to activate the firmware and to be sure that all changes are saved to SD card)
sudo reboot

Initial Tvheadend configuration (without setting multiplexes)
-------------------------------------------------------------
sudo dpkg-reconfigure tvheadend           #set/change Tvheadend admin name (to "tvadmin") & password
configure Tvheadend on raspberrypi:9981
 - Access control                         #add "tvuser1-.."
     Enabled:            yes
     Username:           tvuser<1-..>
     Password:           <password>
     Network prefix:     0.0.0.0/0,::/0   #for computer with any IP address (default value)
                         192.168.1.1/24   #ex. for all computers in local network with 192.168.1.* IP addresses
                         a.b.c.d/32       #ex. for one computer with a.b.c.d IP address, where a-d are numbers between 0 and 255
     HTSP Streaming:     yes              #TV can be watched in Kodi
     Limit Connections:  4                #how many streams can user watch at the same time, default is 4
 - DVB Inputs:
   - Networks:                            #define a "TV network"
     Type:               DVB-T
     Network name:       MyNet
     Network Discovery:  no               #doesn't search for new multiplexes automatically
   - TV Adapters:                         #for each TV adapter set:
     Enabled:            yes
     Name:               any unique name
     Networks:           name of the previously added TV network
     Power Save:         yes              #unused TV adapters will save power
     Priority:           <number>         #set it optionally to control in which order TV adapters are used
     Force old status:   yes              #otherwise sometimes TV signal strength and quality are shown incorrectly (tvheadend.org/issues/2759 bug)

(for testing and configuration purposes:
  - configure multiplexes, services and channels for testing location, they should be removed after tests
  - enable SSH, it will be disabled after changing passwords)

Creative Commons License This work is licensed under a Creative Commons Attribution 4.0 International License.