User Tools

Site Tools


tutorials:command_line_dvb

This is an old revision of the document!


Command line dvb-t

I have two budget dvb-t pci cards in a linux box that I use for saving dvb TV programs and, since I am a minimalist, sometimes viewing in real time using xine. In this brief tutorial I will explain how to access DVB broadcasts on the command line and introduce a bare bones example script that will tune a channel, encode a broadcast on the fly and save it to disk.

You might wonder why in the age of Myth TV would I bother to which I would answer that I'm happy enough to be able to open up a terminal (locally or remotely), type in a command, respond to a couple prompts, and schedule a show to be saved for later viewing. I don't need much more than that.


If you want to try any of this on your own machine you will need to install dvb-apps. If a package is not available for your distro or if you want the latest version go to http://linuxtv.org/wiki/index.php/LinuxTV_dvb-apps to get the latest tarball and roll your own. It is a trivial compile with no dependencies or config file to. Just run make then make install for instant gratification or build your own package. If you prefer, you can just run the executables strait from the build directory.

Note that some distros package dvb-apps as dvb-utils and that there is another bundle of dvb related utilities named DVBapps. If you have installed or built the correct dvb-apps, in addition to some include files, libraries and frequency listings you should have installed the follwing command line utilities

rick[~]$ ls saves/build/usr/local/bin/
atsc_epg         azap  dib3000-watch  dvbdate  dvbscan     femon  gotox  scan  tzap
av7110_loadkeys  czap  dst_test       dvbnet   dvbtraffic  gnutv  lsdvb  szap  zap

I will only discuss the use of scan and tzap in this tutorial.

In order to tune a channel with tzap or indeed other applications including mplayer and xine you will first need a channels.conf file. This is created using the scan, and a file containing initial tuning data for at least one transponder/channel for your area. Dvb-apps provides this data for the TV transponders in my area (on Mt. Dandenong) in the file /usr/local/share/dvb/dvb-t/au-Melbourne.

rick[~]$ cat /usr/local/share/dvb/dvb-t/au-Melbourne
# Australia / Melbourne (Mt Dandenong transmitters)
# T freq bw fec_hi fec_lo mod transmission-mode guard-interval hierarchy
# ABC
T 226500000 7MHz 3/4 NONE QAM64 8k 1/16 NONE
# Seven
T 177500000 7MHz 3/4 NONE QAM64 8k 1/16 NONE
# Nine
T 191625000 7MHz 3/4 NONE QAM64 8k 1/16 NONE
# Ten
T 219500000 7MHz 3/4 NONE QAM64 8k 1/16 NONE
# SBS
T 536625000 7MHz 2/3 NONE QAM64 8k 1/8 NONE

To create my channels.conf I run scan with the path to au-Melbourne and redirect stdout to a file.

rick[~]$ scan /usr/local/share/dvb/dvb-t/au-Melbourne > channels.conf

The complete channels.config looks like this:

ABC News 24:226500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:2314:0:560
ABC1:226500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:512:650:561
ABC2 / ABC4:226500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:2307:2308:562
ABC1:226500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:512:650:563
ABC3:226500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:2311:2312:564
ABC Dig Music:226500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:0:2317:566
ABC Jazz:226500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:0:2318:567
7 Digital:177500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_3_4:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:769:770:1328
7 Digital 1:177500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_3_4:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:769:770:1329
7TWO:177500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_3_4:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:801:802:1330
7mate:177500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_3_4:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:817:0:1331
7 Digital:177500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_3_4:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:769:770:1332
TV4ME:177500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_3_4:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:881:882:1335
Nine Digital:191625000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_3_4:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:519:720:1072
GEM:191625000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_3_4:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:512:0:1073
GO!:191625000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_3_4:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:517:700:1074
ONE:219500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:514:0:1585
TEN Digital:219500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:512:650:1589
ONE:219500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:514:0:1591
ELEVEN:219500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:516:681:1592
SBS ONE:536625000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:161:81:785
SBS TWO:536625000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:162:83:786
SBS 3:536625000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:161:81:787
SBS 4:536625000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:161:81:788
SBS HD:536625000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:102:103:789
SBS Radio 1:536625000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:0:201:798
SBS Radio 2:536625000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_2_3:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:0:202:799

Once the channels.conf file has been created you can put it in ~/.mplayer or ~/.xine if you want to use either of those programs to watch digital TV. I also save a copy as /etc/channels.confto be accessed by the script I use for saving shows to disk.

Note that I have also successfully used this channels.conf on a budget WinFast dvb-s (satelite) card connected to an antenna pointed at Mt. Dandenong, however, I can not say if this would work with all dvb-s cards.

I can now use tzap to tune any channel listed in my channels.conf.

Tzap needs to know what dvb card (adapter) to use. I have two cards installed.

rick[~]$ ls /dev/dvb
adapter0  adapter1

Tzap also needs to know which frontend and which demux to use. My two budget cards can only tune one channel at a time so they only have one frontend and one demux each.

rick[~]$ ls /dev/dvb/adapter0
demux0  dvr0  frontend0  net0

Tzap uses adapter0, demux0 and frontend0 by default, so I will only have to specify which adapter to use when tuning a channel. I will also need to also tell tzap where the channel.conf is and what channel to tune. If I want to set upthe device dvr0 for recording an mpeg-ts (transport stream) I should also use the flag -r. The device net0 is used when feeding packets into the network protocol stack, i.e. streaming a program.

rick[~]$ tzap -a 0 -c /etc/channels.conf -r "ABC1" 
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
reading channels from file '/etc/channels.conf'
tuning to 226500000 Hz
video pid 0x0200, audio pid 0x028a
status 01 | signal 2a2a | snr 8000 | ber 00003fff | unc 00000000 | 
status 1f | signal 2b2b | snr ffff | ber 00000000 | unc 00000000 | FE_HAS_LOCK
status 1f | signal 2b2b | snr ffff | ber 00000000 | unc 00000000 | FE_HAS_LOCK
status 1f | signal 2b2b | snr ffff | ber 00000000 | unc 00000000 | FE_HAS_LOCK
<snipped>

Once tzap has tuned the channel it will remain tuned until the process is terminated. The whatever is being broadcast on that tuned channel is available via dvr0 although you need to do something with it.

rick[~]$ cat /dev/dvb/adapter0/dvr0
���,j����{
          ���V12��W1���J��&���G�\���F���k�JjP�)6�)[]]lc�Q���L▒��Ǡ[DE�q�#
V+nx�:�Z�q��nzV��63k�m���[Wdf��Y,�a�m������                             ���F�mi"3a[W��j:�=�J�+
                                           n?>Ѵ�F���g���<E���gޒ�7�2*m�2F�=����]�0-��:eȱK▒�d����͒����G▒-�X�#5�▒����G��0�cW�b�0��Hгڳ
V&0¶s
     V�Ȕ{!��,F▒���+K��Ŕ��a��[V��1Xd��0���Z�sŌ0ٱ��D?�x @-��
                                                          )�@?��?��,[=&hE!2p\�C`@��e▒�KS��B=k1�`���A�2pmn<:6��G�8�@���(�;{��k����lʏ▒���{?sz��e���U��Ã
         V��$Z�i��ݬ,�)3h�-�h[L��6���w��G����P�9��Oe�M�t.l=�L���6���l|�D�Tؾ�ݖK�:���w���צ���O��j&B[0���▒ɘ��6����&+L�TFVG▒6�Q��˘�@����z�G0�V�hbcc-�s��b���X^[[?1;2c^[[?1;2cX�F��Z)��O�X�
٤��)▒ O�"0�#  �0��f@Ɔ2����
�ˌ#
<snipped>

Using cat to stdout is pretty useless but dvr0 can be redirected and saved as a transport stream (.ts) on disk or accessed by an application and viewed in real time by opening up another terminal and running a second command.

rick[~]$ cat /dev/dvb/adapter0/dvr0 > video_name.ts

This will redirect stdout from dvr0 to a file that can be either viewed or encoded.

rick[~]$ xine stdin://mpeg2 < /dev/dvb/adapter0/dvr0
This is xine (X11 gui) - a free video player v0.99.5.
(c) 2000-2007 The xine Team.
tutorials/command_line_dvb.1330762080.txt.gz · Last modified: 2017/10/12 21:58 (external edit)