Linux / DVB / Command line: Watching multiple channels with single DVB adapter
Some (or all?) DVB adapters can be set to submit the entire MPEG-TS stream to the host, without filtering specific channels (actually, PIDs). This allows viewing more channel at a time. This is demonstrated below with ffplay, even though ffplay tends to get stuck when it goes to a live stream.
It’s also not possible to view multiple channels with ffplay like this, because the device file can be opened only by a single instance of ffplay (or there’s a device or resource busy error). So in short, this is really just a proof of concept. Tvheadend does this anyhow. But the point there is to do it low-level style.
What I had: A HD-901T2 DVB-T2 stick on a Linux Mint 18.1 running a 4.4.0-53-generic kernel.
First, a scan should be done with dvbv5-scan, which creates a dvb_channel.conf file (shown in this post)
Using the -P flag to disable channel filtering:
$ dvbv5-zap -P -c dvb_channel.conf -r 'Ch 10' using demux '/dev/dvb/adapter0/demux0' reading channels from file 'dvb_channel.conf' service has pid type 06: 2642 2641 2640 tuning to 538000000 Hz pass all PID's to TS dvb_set_pesfilter 8192 (0x00) Lock (0x1f) Lock (0x1f) DVR interface '/dev/dvb/adapter0/dvr0' can now be opened Lock (0x1f) Signal= 92.55% C/N= 33.62dB postBER= 0
Note that the specification of ‘Ch 10′ in the command was merely a lazy way to set the frequency and other technical parameters.
Without stopping dvbv5-zap, go
$ ffplay /dev/dvb/adapter0/dvr0 2>log
and quit as soon as an image window appears. It’s a lot of mumbo-jumbo, but there’s a stream list somewhere in the middle — the example I captured is given at the end of this post.
So, to watch Channel 2:
$ ffplay -vst p:2 /dev/dvb/adapter0/dvr0
The p:2 specifier matches the “Program 2″ in the stream list. ffplay automatically matches the audio channel (even though -ast wasn’t specified).
Note that it’s ffplay that does the demuxing. This works (even better, actually) if the data stream is copied into a file first (with cat, for example) and then the file is played.
It also possible to handpick the streams with the PIDs, as listed in the dvb_channel.conf file (or in the stream list, as hex numbers in the square brackets). For example, watching channel 99:
$ ffplay -vst i:2689 -ast i:2690 /dev/dvb/adapter0/dvr0
or, equivalently
$ ffplay -vst i:0xa81 -ast i:0xa82 /dev/dvb/adapter0/dvr0
ffplay stream list
As captured in Haifa, Israel on March 10th 2017:
Program 1
Metadata:
service_name : ?Ch 1
service_provider: ?Idan +
Stream #0:30[0x401](heb): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Stream #0:12[0xa01]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg), 720x576 [SAR 12:11 DAR 15:11], 25 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0:31[0xa02]: Audio: aac_latm (HE-AACv2) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Program 2
Metadata:
service_name : ?Ch 2
service_provider: ?Idan +
Stream #0:0[0xa21]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg), 720x576 [SAR 12:11 DAR 15:11], 25 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0:1[0xa22]: Audio: aac_latm (HE-AACv2) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Stream #0:2[0xa23]: Audio: aac_latm (HE-AACv2) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Stream #0:3[0xa30](heb): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Stream #0:4[0xa31](rus): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Stream #0:5[0xa32](ara): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Program 3
Metadata:
service_name : ?Ch 10
service_provider: ?Idan +
Stream #0:6[0xa41]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg), 720x576 [SAR 12:11 DAR 15:11], 25 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0:29[0xa42]: Audio: aac_latm (HE-AACv2) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Stream #0:28[0xa43]: Audio: aac_latm (HE-AACv2) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Stream #0:32[0xa50](heb): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Stream #0:33[0xa51](rus): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Stream #0:34[0xa52](ara): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Program 4
Metadata:
service_name : ?Ch 33
service_provider: ?Idan +
Stream #0:22[0xa61]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg), 720x576 [SAR 12:11 DAR 15:11], 25 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0:23[0xa62]: Audio: aac_latm (HE-AACv2) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Program 5
Metadata:
service_name : ?Ch 99
service_provider: ?Idan +
Stream #0:11[0xa81]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg), 720x576 [SAR 12:11 DAR 15:11], 25 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0:26[0xa82]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Stream #0:35[0xa90](heb): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Program 6
Metadata:
service_name : ?Ch 23
service_provider: ?Idan +
Stream #0:8[0xe01]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg), 720x576 [SAR 12:11 DAR 15:11], 25 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0:27[0xe02]: Audio: aac_latm (HE-AACv2) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Program 21
Metadata:
service_name : Aleph
service_provider: Idan +
Stream #0:19[0xb01]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Program 22
Metadata:
service_name : Bet
service_provider: Idan +
Stream #0:18[0xb11]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Program 23
Metadata:
service_name : Gimmel
service_provider: Idan +
Stream #0:7[0xb21]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Program 24
Metadata:
service_name : Dalet
service_provider: Idan +
Stream #0:9[0xb31]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Program 25
Metadata:
service_name : Moreshet
service_provider: Idan +
Stream #0:25[0xb41]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Program 26
Metadata:
service_name : 88FM
service_provider: Idan +
Stream #0:13[0xb51]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Program 27
Metadata:
service_name : Musica
service_provider: Idan +
Stream #0:16[0xb61]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Program 28
Metadata:
service_name : Reka
service_provider: Idan +
Stream #0:20[0xb71]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Program 29
Metadata:
service_name : Galatz
service_provider: Idan +
Stream #0:24[0xb81]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Program 30
Metadata:
service_name : Galgalatz
service_provider: Idan +
Stream #0:14[0xb91]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Program 36
Metadata:
service_name : Radios
service_provider: Idan +
Stream #0:15[0xbf1]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Program 41
Metadata:
service_name : Kol Barama
service_provider: Idan +
Stream #0:21[0xc41]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Program 42
Metadata:
service_name : Lev HaMdina
service_provider: Idan +
Stream #0:17[0xc51]: Audio: aac_latm (HE-AACv2) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Program 45
Metadata:
service_name : CLASSICAL bu
service_provider: Idan +
Stream #0:10[0xc81]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Program 7
Metadata:
service_name : Idan+test_2
service_provider: Idan+
So this list leaves no doubt that all channels were passed on to ffplay.