📜 ⬆️ ⬇️

Reception of satellite TV channels in linux

Good day.
I want to tell you about setting up the reception of satellite unencrypted TV channels in linux and broadcasting them to a local network.
The initial data will be the presence of a satellite dish tuned to a certain degree (for example, at www.lyngsat.com/amos2.html ) and a computer running linux (no matter which distribution, in my case was Slackware). The task is very interesting and relevant in our time.

A bit of theory


To receive a signal, we need the following programs:
scan - for scanning channels on a transponder.
szap - to check the reception of data from the respondent.
vlc - for receiving and broadcasting.

The first two utilities are in the linuxtv-dvb-apps package. To install them, you can use the package manager of your distribution or go to LinuxTV , download the source code and compile.
vlc can also be installed using the package manager, or from the official VLC website

frec - frequency or transponder
sr (symbol rate) - symbol rate
fec - error correction frequency
V, H, L, R - polarization
The signal that can possibly be in the C and Ku ranges, in the linear (v, h) and circular polarization (l, r).
')

Catch signal


First of all, we need to check whether our dvb-card was defined in the system:
It's very easy to find out, just run lspci and find similar lines there:

03:05.0 Multimedia controller: Philips Semiconductors SAA7146 (rev 01)
03:06.0 Network controller: Techsan Electronics Co Ltd B2C2 FlexCopII DVB chip / Technisat SkyStar2 DVB card (rev 02)
03:05.0 Multimedia video controller: Conexant CX23880/1/2/3 PCI Video and Audio Decoder (rev 05)
03:05.2 Multimedia controller: Conexant CX23880/1/2/3 PCI Video and Audio Decoder [MPEG Port] (rev 05)
03:05.4 Multimedia controller: Conexant CX23880/1/2/3 PCI Video and Audio Decoder [IR Port] (rev 05)

1st device - skystar3
2nd device - skystar2
3rd, 4th, 5e devices - twinhan 1027

This is how it looks from me:
root@sat:/# lspci
00:00.0 Host bridge: ATI Technologies Inc Unknown device 7910
00:01.0 PCI bridge: ATI Technologies Inc Unknown device 7912
00:07.0 PCI bridge: ATI Technologies Inc Unknown device 7917
00:12.0 SATA controller: ATI Technologies Inc SB600 Non-Raid-5 SATA
00:13.0 USB Controller: ATI Technologies Inc SB600 USB (OHCI0)
00:13.1 USB Controller: ATI Technologies Inc SB600 USB (OHCI1)
00:13.2 USB Controller: ATI Technologies Inc SB600 USB (OHCI2)
00:13.3 USB Controller: ATI Technologies Inc SB600 USB (OHCI3)
00:13.4 USB Controller: ATI Technologies Inc SB600 USB (OHCI4)
00:13.5 USB Controller: ATI Technologies Inc SB600 USB Controller (EHCI)
00:14.0 SMBus: ATI Technologies Inc SB600 SMBus (rev 14)
00:14.1 IDE interface: ATI Technologies Inc SB600 IDE
00:14.2 Audio device: ATI Technologies Inc SB600 Azalia
00:14.3 ISA bridge: ATI Technologies Inc SB600 PCI to LPC Bridge
00:14.4 PCI bridge: ATI Technologies Inc SB600 PCI to PCI Bridge
00:18.0 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] HyperTransport Technology Configuration
00:18.1 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Address Map
00:18.2 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] DRAM Controller
00:18.3 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Miscellaneous Control
01:05.0 VGA compatible controller: ATI Technologies Inc Radeon X1200 Series
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 01)
03:05.0 Multimedia controller: Philips Semiconductors SAA7146 (rev 01)
03:06.0 Network controller: Techsan Electronics Co Ltd B2C2 FlexCopII DVB chip / Technisat SkyStar2 DVB card (rev 02)


The next step is to launch the kernel modules for these dvb cards.
The required modules depend on the dvb-card chipset, but there are 2 mandatory modules: dvb_core and dvb_pll.
For SkyStar 2: b2c2_flexcop
For SkyStar 3: budjet
For Twinhan 1027: cx88_dvb

In 99 cases out of 100, the required modules were loaded at system startup. So whether or not to check it is very simple lsmod | grep dvb
This is how it looks on the same system:
root@sat:/# lsmod | grep dvb
dvb_pll 15876 2 b2c2_flexcop,lgh06xf
dvb_core 74280 5 b2c2_flexcop,budget,lgdt330x,budget_core,stv0299


If the modules have successfully loaded, then you will see new devices in the / dev / dvb directory:
root@sat:/# ls /dev/dvb/
adapter0/ adapter1/


Great, now we need to catch the signal.
First of all, you will need to scan any of the transponders available to us and find out what channels we can receive.
We come to the aid of the scan utility installed by us.
It scans the transponder and provides information on available channels to the standard output stream.
From the parameters, it needs to pass the path to the configuration file, the dvb-adapter number of which is scanned and, with circular polarization, manually set the frequencies.

The configuration file for scan is easy to write using information from the site lyngsat.com . On it you need to find a satellite to the degree you have tuned and from this satellite choose any transponder.
In our example, www.lyngsat.com/amos2.html , we will select a transponder (freq) 10759, horizontal (H) polarization, a symbolic speed (sr) 30000 and an error correction frequency (fec) 3/4. Our configuration file for scan will look like this:

S 10759000 H 30000000 3/4


Use this:
root@sat:/etc/sat/test# scan -a 0 /path/to/trans.conf
scanning /path/to/trans.conf
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
initial transponder 10759000 H 30000000 3
>>> tune to: 10759:h:0:30000
Network Name 'NET'
0x0000 0x0001: pmt_pid 0x0020 Spacecom -- KIEV STB (running, scrambled)
0x0000 0x0002: pmt_pid 0x0030 Spacecom -- M1 (running, scrambled)
0x0000 0x0003: pmt_pid 0x0040 Spacecom -- TONIS (running, scrambled)
0x0000 0x0005: pmt_pid 0x0060 Spacecom -- ICTV (running, scrambled)
0x0000 0x0006: pmt_pid 0x0070 Spacecom -- M2 (running, scrambled)
0x0000 0x0008: pmt_pid 0x1079 Spacecom -- NEWS 24 (running, scrambled)
0x0000 0x0009: pmt_pid 0x0200 Spacecom -- Radio Antoshka (running, scrambled)
0x0000 0x000a: pmt_pid 0x0100 Spacecom -- MTV UKRAINE (running, scrambled)
0x0000 0x000b: pmt_pid 0x0080 Spacecom -- QTV (running, scrambled)
dumping lists (9 services)
KIEV STB:10759:h:0:30000:33:34:1
M1:10759:h:0:30000:49:50:2
TONIS:10759:h:0:30000:65:66:3
ICTV:10759:h:0:30000:97:98:5
M2:10759:h:0:30000:113:114:6
NEWS 24:10759:h:0:30000:4194:4195:8
Radio Antoshka:10759:h:0:30000:0:513:9
MTV UKRAINE:10759:h:0:30000:257:258:10
QTV:10759:h:0:30000:129:130:11
Done.

In the case of circular polarization, add the -l key with the values ​​10750,10750.0

scan -a 0 /path/to/trans.conf -l 10750,10750,0


Let's try to configure the card to receive data. For this we need a configuration file for szap. It is very easy to get:
root@sat:~# scan -a 0 ~/trans36.conf -l 10750,10750,0 > ~/channels.conf
root@sat:~# cat ./channels.conf
Sport 1:11727:h:0:27500:101:201:1
Sport 2:11727:h:0:27500:102:202:2
First Automotive:11727:h:0:27500:103:203:3
BIZ TV:11727:h:0:27500:104:204:4
Che-Pe_INFO:11727:h:0:27500:105:205:5
TBi:11727:h:0:27500:106:206:6
TV3:11727:h:0:27500:107:207:7
CHANSON:11727:h:0:27500:108:208:8
TOPSHOP TV:11727:h:0:27500:109:209:9
Expert test:11727:h:0:27500:110:210:10
Football test:11727:h:0:27500:111:211:11
Engineer_1:11727:h:0:27500:114:214:14


Now let's drop this configuration file in szap:
root@sat:~# szap -c ./channels.conf -n 1 -x -l 10750,10750,0
reading channels from file './channels.conf'
zapping to 1 'Sport 1':
sat 0, frequency = 11727 MHz H, symbolrate 27500000, vpid = 0x0065, apid = 0x00c9
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
status 00 | signal 6262 | snr fcfc | ber 00000000 | unc 00000000 |
status 1f | signal 4d4d | snr 3535 | ber 00000000 | unc 00000006 | FE_HAS_LOCK

If the inscription "FE_HAS_LOCK" appeared, then everything is OK, you are in the right mood.
Parameters for szap are similar to parameters for scan:
-c /path/to/channels.conf - path to the configuration file with channels.
-n X is the channel number from the channels.conf file, where X is a number starting from 1.
-x - as soon as szap is locked, it ends immediately.
-l 10750,10750.0 - necessary for circularly polarized antennas.

We broadcast to the network


So, we have a list of channels available to us on the transponder.
Now that we know the frequencies, the polarization, and have learned the pid of the desired channels (the last digit in each line, the pid of the channel is m1 = 2), we can proceed to receive the stream directly.
To do this, we use the all-powerful player vlc.

There are quite a few parameters transmitted at the start and it’s pointless to type them each time, I advise you to write the entire vlc launch command into the shell-executable file.
#!/bin/bash
/usr/bin/vlc -vvv --color --ttl 12 --ts-es-id-pid --dvb-adapter=0 --programs=1,2,3,6,8,10,11 dvb:
--dvb-frequency=10759000 --dvb-srate=30000000 --dvb-voltage=18 --dvb-fec=9 -d --sout '#duplicate{
dst="standard{access=http,mux=ts,url=0.0.0.0:8011}",select="program=1"
dst="standard{access=http,mux=ts,url=0.0.0.0:8012}",select="program=2"
dst="standard{access=http,mux=ts,url=0.0.0.0:8013}",select="program=3"
dst="standard{access=http,mux=ts,url=0.0.0.0:8014}",select="program=6"
dst="standard{access=http,mux=ts,url=0.0.0.0:8015}",select="program=8"
dst="standard{access=http,mux=ts,url=0.0.0.0:8016}",select="program=10"
dst="standard{access=http,mux=ts,url=0.0.0.0:8017}",select="program=11"}'


A little bit about the parameters:
-vvv - verbose output, useful for debugging.
--color - paints the display of messages, highlights the critical messages with red, very convenient if -vvv is used.
--dvb-adapter - dvb adapter number from / dev / dvb /, in case you have more than one installed on your computer.
--programs - pid'y channels that need to be taken.
-d - work like a demon.
--dvb-fec - The fec 1/2 9 value is automatically detected.
dst = "standard {access = http, mux = ts, url = 0.0.0.0: 8011}", select = "program = 1"

Each of these lines connects the pid of the channel with the computer port. In this case, the channel with pid 1 will be broadcast on port 8011.

It remains only to check.
We start from the client and see:
mplayer h_t_t_p://10.16.0.12:8012

Source: https://habr.com/ru/post/60444/


All Articles