Building a DVB streaming server

From MetaWiki

Jump to: navigation, search

Before you start, there are some important network issues to be addressesed. Make sure your site/campus network manager knows what you want to do and ensure the network is setup to handle multicast properly. Blindly pouring multi-megabits of video into an unsuspecting campus network could cause a 'network meltdown'. Your infrastructure needs to be configured for multicast, particularly if your aim is a campus wide video distribution system. If you are doing this at home, go for it. mythtv might be a better option though.

My initial servers were built with various Fedora Core versions as the base system. I've also build one using the Debian based Ubuntu linux distribution and will probably use Ubuntu in the future.

There is no reason that this couldn't be done with Windows or MacOSX as the base - however the dvb drivers work quite differently on those platforms. My only experience is with using Linux as a base.


Contents

Hardware

Any reasonably modern PC will do. I've used an old Dual PIII 933 server and P4 desktop machines.

The machine pictured here is an Optima 2Gz P4 desktop from 2003. These machines only had 256Mb of RAM, I found some RAM lying around and upgraded it to 512Mb.

Image:DVBstreamer-1.jpg Image:DVBstreamer-2.jpg

The cards shown here are Twinan 1022A DVB-S cards. Any DVB card supported by the Video for Linux drivers will do. There are many. (Literally over a 100, something like 80 CX88 based cards are supported and over 100 bt8xx based cards). I've even got a USB tuner running, a Divco Fushion HDTV+. However I don't think trying multiple USB tuners would be very satisfactory - most PC's only have one USB2 controller - throwing more than one transport stream at it probably isn't a good idea.

This machine is happily running with 6 video streams, two off one card (Palapa C2) and 4 of the other (Optus B3).

DVB tools

You need the programs scandvb, tzap and szap to scan transponders and to tune the cards. These are packaged in Fedora as 'dvb-apps' in Fedora Extras and 'dvb-utils' in Ubuntu (and thus probably Debian)

scandvb seems to change name depending on the distribution. In Ubuntu 'edgy' the transport scanner is called simply 'scan'. Since Ubuntu is based on Debian, this packaging may also apply to Debian as well.

Tunning transponders, frequencies, and PIDs

We need to determine the parameters for the stream. For this you need the frequency data for the transmitter and various other parameters.

For Australian Digital TV see http://www.dba.org.au/ , for Satellite see http://www.lyngsat.com/ for information. Satelite is much more complex than DVB-T(errestrial) as there are many more tuning factors that have to be correct.

We use scandvb/scan for finding out the 'PID' (Program IDentifiers) on a particular transponder. Unlike Analogue TV, digital usually multiplexes several TV and/or radio channels onto the one transmission. The PID is what is used to separate out the streams.

The dvb-apps package comes with a pile of 'initial tuning data' files, and this has most of the Australian capital cities covered. For Satellite you will probably have to construct this tuning data file from lyngsat.

VideoLan Client

Obtain VLC. We need the DVB options, and for Fedora at least, the version in the Freshrpm's repository is not compiled with that option, so I had to roll my own. VLC is a little challenging to compile as it requires MANY library files to build. VLC pulls in a lot of stuff. A package manager is your friend here. I kept running configure and then 'yum install *-devel' until configure stopped complaining. Debian people use apt-get to do the same.

http://www.videolan.org/

VLC on Ubuntu is already compiled with DVB support - unfortunately the SAP handler in vlc 0.8.6-cvs as found in Ubuntu Edgy is very broken (SAP playlist will crash vlc, the SAP sender produces broken service URLs that can't be parsed by the client). However installing the 'dapper' version of VLC 0.8.4 produces a working system.


Multicast addressing

You will need to talk to your campus network people about this. AARNet have a multicast addressing plan that should be followed, and in most cases you don't want your transmissions to leave your site. The addresses you use will probably be in the 239.255.x.x region.

Note also, that your network 'switch fabric' has to be multicast aware, or you could cause serious performance issues with your LAN. Multicast video is a constant high bandwidth application that has the potential to kill your network for other applications if the network doesn't handle it properly.

See igmp , igmpsnooping or cgmp

Sout command lines

VLM configuration

VLC has mode they call the VLM manager. This is a way of configuring VLC from text files instead of complex command lines, and also allows the one instance of VLC to read and stream of multiple cards at the same time. The VLM language has 'load' commands, so I've split mine up by satellite/transponder.


This is an example VLM file for streaming several video channels off AsiaSat3. This example has the AsiaSat3 dish connected to the first DVB card in the system.

The 'program' numbers were found with the scan/dvbscan program.

new asiasat3-3760 broadcast enabled

setup asiasat3-3760 input "dvb://"
setup asiasat3-3760 option dvb-adapter=0
setup asiasat3-3760 option dvb-frequency=3760000
setup asiasat3-3760 option dvb-srate=2600000
setup asiasat3-3760 option dvb-lnb-lof1=5150
setup asiasat3-3760 option programs=1,3,4,5,2,9,12,30,11,7
setup asiasat3-3760 option ts-es-id-pid

setup asiasat3-3760 output #duplicate{dst=standard{access=udp,mux=ts,url=239.255.100.99:1234,sap,group="Usyd META",name="Usyd META - Deutche Welle (Germany)"},select="program=30",dst=standard{access=udp,mux=ts,url=239.255.100.107:1234,sap,group="Usyd META",name="Usyd META - TV5Monde (France)"},select="program=12",dst=standard{access=udp,mux=ts,url=239.255.100.129:1234,sap,group="Usyd META",name="Usyd META - Al Jazeera International"},select="program=9",dst=standard{access=udp,mux=ts,url=239.255.100.130:1234,sap,group="Usyd META",name="Usyd META - NOW (Hong Kong)"},select="program=1",dst=standard{access=udp,mux=ts,url=239.255.100.131:1234,sap,group="Usyd META",name="Usyd META - Bloomberg (US)"},select="program=2",dst=standard{access=udp,mux=ts,url=239.255.100.132:1234,sap,group="Usyd META",name="Usyd META - Indus Music (Pakistan)"},select="program=3",dst=standard{access=udp,mux=ts,url=239.255.100.133:1234,sap,group="Usyd META",name="Usyd META - Channel G"},select="program=4",dst=standard{access=udp,mux=ts,url=239.255.100.134:1234,sap,group="Usyd META",name="Usyd META - Indus Vision (Pakistan)"},select="program=5",dst=standard{access=udp,mux=ts,url=239.255.100.135:1234,sap,group="Usyd META",name="Usyd META - Indus Plus News (Pakistan)"},select="program=11",dst=standard{access=udp,mux=ts,url=239.255.100.136:1234,sap,group="Usyd META",name="Usyd META - Muslim TV1 (?)"},select="program=7"}

control asiasat3-3760 play

Working Example

start.sh

There is a bug in the latest vlc (or a problem with my build) where it doesn't set the DVB-S card's tuning parameters properly, hence the szap commands in this script. Strictly they are not needed, here they ensure the cards are left in a state that ensures that vlc can work. Note: szap reads ~/.szap/channels.conf which is populated from the output of of scan ./Palapa -l 5150 and scan -a 1 ./OptusD2 -l 11300

#!/bin/sh
#
cd /root
/usr/bin/szap -l 5150 "MetroTV" -x
/usr/bin/szap -a 1  "TGN" -l 11300 -x

/usr/local/bin/vlc --vlm-conf /root/stream.vlm --ttl 12 -I telnet

stream.vlm

load /root/stream-palapa-c2-4080.vlm
load /root/stream-optusb3.vlm


stream-palapa-c2-4080.vlm

A note here is I left the output of scandvb in this file as comments so I know where I got the PIDs from.

new palapa-4080 broadcast enabled

setup palapa-4080 input "dvb://"
setup palapa-4080 option dvb-adapter=0
setup palapa-4080 option dvb-frequency=40800000
setup palapa-4080 option dvb-srate=2812500
setup palapa-4080 option dvb-lnb-lof1=5150
setup palapa-4080 option programs=1,2
setup palapa-4080 option ts-es-id-pid

#  Scan for PIDs 25/08/2006
#  scandvb ./palapaC2-H -l 5150
#
#GlobalTV:4080:h:0:28125:0:0:1
#MetroTV:4080:h:0:28125:0:0:2
# From here in, I don't get video.

#KTV:4080:h:0:28125:0:0:3
#TVRI:4080:h:0:28125:0:0:4
#Prima Ent:4080:h:0:28125:0:0:5
#MQTV:4080:h:0:28125:0:0:6
#ch7:4080:h:0:28125:0:0:7

setup palapa-4080 output #duplicate{dst=standard{access=udp,mux=ts,url=239.255.100.90:1234,sap,group="Usyd META",name="Usyd META - Global TV (Indonesia)"},select="program=1",dst=standard{access=udp,mux=ts,url=239.255.100.91:1234,sap,group="Usyd META",name="Usyd META - Metro TV (Indonesia)"},select="program=2"

control palapa-4080 play

stream-optusb3.vlm

new   optusb3 broadcast enabled
setup optusb3 input "dvb://"
setup optusb3 option dvb-adapter=1
setup optusb3 option dvb-frequency=12525000
setup optusb3 option dvb-srate=30000000
setup optusb3 option dvb-lnb-lof1=11300
setup optusb3 option programs=14,4,3,12
setup optusb3 option ts-es-id-pid

setup optusb3 output #duplicate{dst=standard{access=udp,mux=ts,url=239.255.100.98:1234,sap,group="Usyd META",name="Usyd MET A - Abu Dhubi"},select="program=14",dst=standard{access=udp,mux=ts,url=239.255.100.106:1234,sap,group="Usyd META",name="Usy d META - Thai Global Network"},select="program=4",dst=standard{access=udp,mux=ts,url=239.255.100.121:1234,sap,group="Usyd M ETA",name="Usyd META - Sultanate of Oman TV"},select="program=12",dst=standard{access=udp,mux=ts,url=239.255.100.122:1234,s ap,group="Usyd META",name="Usyd META - ERT (Greece)"},select="program=3"}

control optusb3 play

References

http://www.videolan.org/

http://ab.id.au/StreamingTV/

http://www.dba.org.au/

http://www.lyngsat.com/

Personal tools