My powervu linux streaming setup II. (TVHeadend)

joeuser

Registered
Messages
199
I have been using TVHeadend (instead of MuMuDVB) for two months now. I had to make some patches to oscam-emu/osemu and to tvheadend to get it to work. But, now no patches are needed since now the functionality is implemented in the latest TVHeadend.

Basic steps to setup:

Install TVHeadend (latest version from nightly builds...)
For Debian:
Code:
echo deb https://dl.bintray.com/tvheadend/ubuntu master main | sudo tee -a /etc/apt/sources.list
apt-get update
apt-get install tvheadend


Create network(s)
Code:
	Configuration -> DVB Inputs -> Networks -> add
	Type: DVB-S network
	Network name: HBO (or whatever appropriate...)
	Network discovery: unchecked
 	Skip initial scan: checked
	Use service IDs as channel numbers: (up to you, can leave default)
	Ignore provider's channel numbers: (up to you, can leave default)
	SAT>IP source number: 0 (leave default)
	Pre-defined muxes: leave default (unset) we will create manually
	Orbital position: 4W : Amos 2/3
	
	Leave other defaults and press "create"

Add network created to adapter
Code:
	Configuration -> DVB Inputs -> TV adapters -> (your adapter) -> Parameters
	(varies depending on your physical setup, ie motor/diseqc swithces. etc...)
	Under Basic Settings add your new network

Define mux for your network
Code:
	Configuration -> DVB Inputs -> Muxes -> add
	Network: HBO (or whatever you entered above)
	Delivery system: DVB-S
	Frequency: 10935000
	Symbol rate: 13750000
	Polarization: H
	Modulation: QPSK
	FEC: 5/6
	
	Leave other defaults and press "create"

Scan new muxes
Code:
	Configuration -> DVB Inputs -> Networks
	Select HBO (or whatever you entered above) and then press "Force Scan"
Hopefully if you go now to Services, you should see the channels from the mux...

Create a PowerVU streaming profile with mpeg-ts pass through and enable PAT and SDT rewrite
Code:
	Configuration -> Stream -> Streaming Profiles -> Add
	Type: MPEG-TS Pass-thru/built-in
	Enabled: (check)
	Profile Name: PowerVU (or any name, but must replaced in further config, scripts, etc...)
	Rewrite PMT: unchecked
	Rewrite PAT: checked
	Rewrite SDT: checked
	Rewrite EIT: unchecked
	
	Leave other defaults and press "create"

Create a pvu user with password pvu with PowerVU as streaming profile (or any name/password, but must replaced in further config, scripts, etc...)
Code:
	Configuration -> Users -> Access Entries -> add
	Enabled: checked
	Username: pvu
	Streaming: checked
	Advanced Streaming: checked
	Streaming profiles: check "PowerVU"
	
	Leave other defaults and press "create"
        
        Configuration -> Users -> Passwords -> add
	Enabled: checked
	Username: pvu
        Password: pvu
        
        Press "create"

Install either oscam-emu or osemu
Build your own, or download latest versions.

Since oscam-emu/osemu ignores the user:password in the url request, you must setup the user:password for TVHeadend in oscam-emu/osemu.
For OSEmu, add "-t <stream source user>:<stream source password>" to the command line:
Code:
./OSEmu -a user:pass -p1234 -s tvheadendhostip -r 9981:17999 -c /path/to/PowerVU_keyfile -b -t pvu:pvu

And for oscam-emu, you have to add the user:password to the oscam.conf file in the streamrelay section:
Code:
[streamrelay]
stream_source_port            = 9981
stream_source_auth_user       = pvu
stream_source_auth_password   = pvu

To use with TVHeadend, you just need to create a URL something like:
Code:
http://pvu:[email protected]:17999/stream/service/5207215882cb76f456a5d65ecfba2124?profile=PowerVU&descramble=0&emm=1:0:0:4

Where the last number is the sid (srvid/service id) of the channel in hex.

Here are some scripts (original base from B C at TVHeadend forum) modified to create vlc playlists and userbouquets for use with enigma2.

VLC playlist:
Code:
#!/bin/bash
# you must have installed jq (apt-get install jq)

############### BEGIN CONFIG ###################
tvh_data_path="/home/hts/.hts"
OSEmu="192.168.1.10:17999"
profile="PowerVU"
userpass="pvu:pvu"
###############  END CONFIG  ###################

echo \#EXTM3U
grep -rnwl $tvh_data_path'/tvheadend/input/dvb/networks' -e '\"caid\": 3584' | while read  -r services
do
    enabled=$(/usr/bin/jq -c  '.enabled'  $services)
    sid_dec=$(/usr/bin/jq -c  '.sid'  $services)
    sid=$(printf '%x' $sid_dec)
    desc=$(/usr/bin/jq -c -r '.networkname' ${services:0:-81}/config)/$(/usr/bin/jq -c -r '.frequency/1000' ${services:0:-42}/config)$(/usr/bin/jq -c -r '.polarisation' ${services:0:-42}/config)/$(/usr/bin/jq -c -r  '.svcname'  $services)
    if [ "$enabled" = "true" ]
    then
        echo \#EXTINF:-1, $desc
        echo http://$userpass@$OSEmu/stream/service/$(basename "$services")\?profile=$profile\&descramble=0\&emm=1:0:0:$sid
    fi
done

Enigma2 userbouquet:
Code:
#!/bin/bash
# you must have installed jq (apt-get install jq)

############### BEGIN CONFIG ###################
tvh_data_path="/home/hts/.hts"
OSEmu="192.168.1.10%3A17999"
profile="PowerVU"
userpass="pvu%3Apvu"
###############  END CONFIG  ###################

echo \#NAME PowerVU Channels
grep -rnwl $tvh_data_path'/tvheadend/input/dvb/networks' -e '\"caid\": 3584' | while read  -r services
do
    enabled=$(/usr/bin/jq -c  '.enabled'  $services)
    sid_dec=$(/usr/bin/jq -c  '.sid'  $services)
    sid=$(printf '%x' $sid_dec)
    desc=$(/usr/bin/jq -c -r '.networkname' ${services:0:-81}/config)/$(/usr/bin/jq -c -r '.frequency/1000' ${services:0:-42}/config)$(/usr/bin/jq -c -r '.polarisation' ${services:0:-42}/config)/$(/usr/bin/jq -c -r  '.svcname'  $services)
    if [ "$enabled" = "true" ]
    then
        echo \#SERVICE 1:0:1:$sid:0:0:0:0:0:0:http%3A//$userpass@$OSEmu/stream/service/$(basename "$services")\?profile=$profile\&descramble=0\&emm=1%3A0%3a0%3A$sid:$desc
        echo \#DESCRIPTION $desc
    fi
done


BTW:
I left the user:password in the URL in the scripts because in the future I would like to change oscam-emu/osemu so it parses the http request and passes on the user:password hash to enigma2/TVHeadend instead of making it an oscam-emu/osemu config option.
 

Purrfect

Registered
Messages
19
Hello again,

Interesting configuration! What are the advantages of tvheadend compared to mumudvb? I'm still running the "old" system and it actually works very well.

Greetings,
Purrfect
 

joeuser

Registered
Messages
199
A few advatntages:
1. Only need to run one instance of oscam.
2. Only need to run one instance of TVHeadend
3. Webif for TVHeadend to see what is going on...
4. Much lower CPU usage when not streaming (and a little lower during streaming...)

Disadvantage is only that it is a little more difficult to do the initial setup.
 

Purrfect

Registered
Messages
19
Good morning!

Only one instance of Oscam? Means stream relay is not needed for this solution for decrypting PVU?

Regards,
Purrfect
 

joeuser

Registered
Messages
199
Stream relay is still used, but TVHeadend can serve streams from multiple cards/sats at the same time. So, in the url is included the channel you want and you send it to oscam stream relay which requests the channel from TVHeadend. TVHeadend knows which sat/card the channel is on and streams it. The reason mulitple oscam instances were needed before is you needed multiple instances of MuMuDVB, each listening on a different port and oscam can only be configured to connect to one stream server.
 

Purrfect

Registered
Messages
19
I see. Maybe this wouldn't work for me as I need to be able to provide multiple channels to different clients at the same time.
 

joeuser

Registered
Messages
199
I see. Maybe this wouldn't work for me as I need to be able to provide multiple channels to different clients at the same time.
But that is exactly what this does. All clients connect to the same oscam which connects to TVHeadend which can server all channels from a tuner at the same time and all tuners on all cards at the same time. Your only limit is the same as before - each tuner can only tune one transponder at a time (but can still stream all channels on each transponder at the same time.) Also you can have multiple clients connected to the same channel at the same time...

Other advantage is that you do not have to do a special patch for oscam anymore, so updating oscam is easier. The only limit you may run into is the number of clients oscam allows by default (8) but that can be easily changed in module-emulator-stream.h (EMU_STREAM_SERVER_MAX_CONNECTIONS=8)
Or you can still run multiple instances of oscam and point them all to the same TVHeadend server. But managing one oscam instance and one TVHeadend instance, each through a webif, makes things much easier.

Another advantage would be that you can stream other FTA or normally encrypted channels directly from TVHeadend - it uses a capmt connection to oscam.
 

Purrfect

Registered
Messages
19
That's amazing. :thum: Did you also try out AU? If this should work I would really give it a try. Presently I receive 2 transponders but maybe I would like to add some more but AU is important as some providers keep on changing keys daily. :)

I still encounter troubles with OSEmu and AU, it's not working for me.
 

joeuser

Registered
Messages
199
No, I did not test AU. I am not sure the results would be any different than with MuMuDVB.
 

joeuser

Registered
Messages
199
So while debugging a bit, I found one problem. While the url generated by the scripts works for decrypting/playing the stream from TVHeadend, it was not sending emm info. Finally I noticed that alhough TVHeadend wasn't complaining (even in debug logs), it did not parse the "emm=1" properly. To get it to work, you need to add another "&" between "emm=1" and the trailing sid info for oscam. (":0:0:4")

So to get the emm pids to be sent, the url needs to be changed to something like:
Code:
http://pvu:[email protected]:17999/stream/service/5207215882cb76f456a5d65ecfba2124?profile=PowerVU&descramble=0&emm=1&:0:0:4

Here are updated scripts to automatically generate the correct urls.

VLC Playlist:
Code:
#!/bin/bash
# you must have installed jq (apt-get install jq)

############### BEGIN CONFIG ###################
tvh_data_path="/home/hts/.hts"
OSEmu="192.168.1.10:17999"
profile="PowerVU"
userpass="pvu:pvu"
###############  END CONFIG  ###################

echo \#EXTM3U
grep -rnwl $tvh_data_path'/tvheadend/input/dvb/networks' -e '\"caid\": 3584' | while read  -r services
do
    enabled=$(/usr/bin/jq -c  '.enabled'  $services)
    sid_dec=$(/usr/bin/jq -c  '.sid'  $services)
    sid=$(printf '%x' $sid_dec)
    desc=$(/usr/bin/jq -c -r '.networkname' ${services:0:-81}/config)/$(/usr/bin/jq -c -r '.frequency/1000' ${services:0:-42}/config)$(/usr/bin/jq -c -r '.polarisation' ${services:0:-42}/config)/$(/usr/bin/jq -c -r  '.svcname'  $services)
    if [ "$enabled" = "true" ]
    then
        echo \#EXTINF:-1, $desc
        echo http://$userpass@$OSEmu/stream/service/$(basename "$services")\?profile=$profile\&descramble=0\&emm=\&1:0:0:$sid
    fi
done

Enigma2 userbouquet:
Code:
#!/bin/bash
# you must have installed jq (apt-get install jq)

############### BEGIN CONFIG ###################
tvh_data_path="/home/hts/.hts"
OSEmu="192.168.1.10%3A17999"
profile="PowerVU"
userpass="pvu%3Apvu"
###############  END CONFIG  ###################

echo \#NAME PowerVU Channels
grep -rnwl $tvh_data_path'/tvheadend/input/dvb/networks' -e '\"caid\": 3584' | while read  -r services
do
    enabled=$(/usr/bin/jq -c  '.enabled'  $services)
    sid_dec=$(/usr/bin/jq -c  '.sid'  $services)
    sid=$(printf '%x' $sid_dec)
    desc=$(/usr/bin/jq -c -r '.networkname' ${services:0:-81}/config)/$(/usr/bin/jq -c -r '.frequency/1000' ${services:0:-42}/config)$(/usr/bin/jq -c -r '.polarisation' ${services:0:-42}/config)/$(/usr/bin/jq -c -r  '.svcname'  $services)
    if [ "$enabled" = "true" ]
    then
        echo \#SERVICE 1:0:1:$sid:0:0:0:0:0:0:http%3A//$userpass@$OSEmu/stream/service/$(basename "$services")\?profile=$profile\&descramble=0\&emm=1\&%3A0%3a0%3A$sid:$desc
        echo \#DESCRIPTION $desc
    fi
done
 

Purrfect

Registered
Messages
19
Did you ever consider to use one (or more) Sat>IP converter(s) instead of DVB cards? As far as I figured out, it should be possible, too. I'm thinking of using a Megasat SAT>IP Server 2 or similar in my garage, so I could move the Linux PC running TVHeadend into my cellar. Just an idea. :)
 

Purrfect

Registered
Messages
19
A 4 tuner in a small box with a Gigabit uplink cost about 150€ depending on the brand. This way the Linux PC used for TVHeadend wouldn't need to provide any PCI slots and could be very small. :)
 
Last edited:

joeuser

Registered
Messages
199
TVHeadend has built in support for SAT>IP servers and I don't see why it wouldn't work. For me it wouldn't be practical to add another box and network cable when I already have a server with storage space for recordings and a couple dvb cards. But I can see where it might be more convenient for some situations. It is certainly easier to run one CAT 6 cable than a bunch of coax cables...
 

biss_whisperer

Registered
Messages
70
@joeuser
Thanks for sharing this configuration.
I have used mumudvb/osemu with your changes for the last few months and it works great. Now I will try with tvheadend.
 

boyet05

Registered
Messages
245
I have tvheadend running on openelec rpi with oscam server. I was able to use sat-ip as tuner for tvheadend. All is working fine streaming channels in the same transponder at the same time. as of now i have 3 enigma2 box as sat-ip running with 36 channels streaming. As of now only 5 client are connected and its doing fine. but i want to lower the resolution of the HD channels so the bandwidth will be just fine.
 

dale_para_bajo

Registered
Messages
646
@joeuser

I need help!!! I see you have not post recently. But lets see if you can read this. I am learning. And apart from having trouble with setting for C-BAND the rest seems to go well. Up to where I a going to make my VLC Playlist:.

http://www.sat-universe.com/showpost.php?p=2036628555&postcount=10

In general my problem is that the files in "tvh_data_path="/home/hts/.hts" are in fact in binary form!!!! This do not go well with the grep instruction

Code:
grep -rnwl $tvh_data_path'/tvheadend/input/dvb/networks' -e '\"caid\": 3584' | while read  -r services
do

So no output is produce as grep can not gather valid information!! Please tel me what I can do? My thheade vesrion is
Code:
HTS Tvheadend 4.1-1555~g414512d~trusty

Maybe the have done something new and files are no in some sort of compress format. As the magic numbers of the files reads

Code:
FF FF 47 5A 49 50 30 30 00 00       ..GZIP..

I will post the same question on other forums you do post. Hope to see you soon.

@ the rest of the crowd.

If anyone of you know how to correct this let me know. I need to create the channel bucket list. Thanks ahead.
 

joeuser

Registered
Messages
199
Thanks for the report. I haven't run the scripts in a few months. Yes, it looks like they are using zlib to compress the files now, but not in a standard way. So I will have to look at tvh source code to see what they are doing. I don't have much free time now, so I probably won't get to it until next week...
 

joeuser

Registered
Messages
199
Sorry, not much free time lately, but I finally got around to adjusting the script...

You can try this for the VLC playlist.
Code:
/#!/bin/bash
# you must have installed jq (apt-get install jq)

############### BEGIN CONFIG ###################
tvh_data_path="/home/hts/.hts"
OSEmu="192.168.1.11:17999"
profile="PowerVU"
userpass="pvu:pvu"
###############  END CONFIG  ###################

wget -O /tmp/services.json http://admin:admin@localhost:9981/api/mpegts/service/grid?limit=100000

echo \#EXTM3U

entries=$(/usr/bin/jq -c  '.total' /tmp/services.json)

for (( service=0; service<= $entries; service++ ))
do
        if [ $(/usr/bin/jq -c '.entries['$service'].caid' /tmp/services.json) = '"0E00:000000"' ]
        then
                enabled=$(/usr/bin/jq -c  '.entries['$service'].enabled'  /tmp/services.json)
                if [ "$enabled" = "true" ]
                then
                        svcname=$(/usr/bin/jq -c -r  '.entries['$service'].svcname'  /tmp/services.json)
                        uuid=$(/usr/bin/jq -c -r  '.entries['$service'].uuid'  /tmp/services.json)
                        network=$(/usr/bin/jq -c -r  '.entries['$service'].network'  /tmp/services.json)
                        multiplex=$(/usr/bin/jq -c -r  '.entries['$service'].multiplex'  /tmp/services.json)
                        sid_dec=$(/usr/bin/jq -c  '.entries['$service'].sid'  /tmp/services.json)
                        sid=$(printf '%x' $sid_dec)
                        desc="$network/$multiplex/$svcname"
                        echo \#EXTINF:-1, $desc
                        echo http://$userpass@$OSEmu/stream/service/$uuid\?profile=$profile\&descramble=0\&emm=1\&:0:0:$sid
                fi
        fi
done

Something similar can be done for creating userbouquets. I can post later when I get some more free time...
 
Top