From LinuxTVWiki
Revision as of 05:46, 27 March 2007 by CityK (Talk | contribs)

Jump to: navigation, search

The process of tuning a television channel is sometimes referred to by the term "zapping" (apparently in reference to the use of early Set Top Boxes " which could let you zap through a channel list but not much more" [The Linux DVB API]).

Within the LinuxTV dvb-apps package are four similar command line utility programs (azap, czap, szap and tzap) that respectively allow the user to tune a [digital television channel] from a ATSC, DVB-C, DVB-S or DVB-T transmission.

In order to use a zap utility, the user must first create a channel configuration file with the [dvb]scan utility, also found in the dvb-apps package -- see the scan documentation for details. The following sections show typical usage of a zap utility on the command line, and assume that the user has already created/setup a valid channels.conf file.

For purposes of illustration, the tzap utility is used, however, the information should largely be applicable for usage with the other _zap programs as well.


Currently, tzap does not have any documentation. About the only thing that you can do is to run it without any parameters. tzap then displays usage information that is almost enough for experts:

      tzap [options] <channel_name>
        zap to channel channel_name (case insensitive)
    -a number : use given adapter (default 0)
    -f number : use given frontend (default 0)
    -d number : use given demux (default 0)
    -c file   : read channels list from 'file'
    -x        : exit after tuning
    -r        : set up /dev/dvb/adapterX/dvr0 for TS recording
    -s        : only print summary
    -S        : run silently (no output)
    -F        : set up frontend only, don't touch demux
    -t number : timeout (seconds)
    -o file   : output filename (use -o - for stdout)
    -h -?     : display this help and exit

Note that tzap does not take file system device names; instead, it cobbles them together from the adaptor, front end and demux numbers. If you only have one tuner, you don't need to worry about this detail.

Tuning a channel

If you examine your ~/.tzap/channels.conf file, you will discover that its contents are formated something like this:

NINE Digital: ...
NINE HD: ...
TEN Digital: ...

What we're interested in here is the channel name contained in the first field of each line. (If you are interested in what the omitted fields mean, see the scan documentation for more details).

We use the specific name of a channel to tune with tzap. For example, to tune the channel named 'NINE HD',you would enter the following in the command console:

$ tzap -r 'nine hd'

which should produce output similar to the following:

using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
reading channels from file '/root/.tzap/channels.conf'
tuning to 191625000 Hz
video pid 0x0201, audio pid 0x028b
status 00 | signal 933f | snr 0000 | ber 00000000 | unc 00000000 | 
status 1f | signal a70f | snr d0d0 | ber 00000000 | unc 00000000 | FE_HAS_LOCK
status 1f | signal aadf | snr cccc | ber 00000000 | unc 00000000 | FE_HAS_LOCK

Note: You need to put the channel name in single or double quotes if it contains spaces; on the other hand, you don't have to match case.

The first four lines of the above example output show what tzap is doing; they should reflect the corresponding fields in the channels.conf file. The next item of interest is the fifth line, "status 00". This shows that the tuner card has been initialized, but no signal has been decoded. The next line shows correct tuning. It repeats with up-to-date information every second.

The information on this line is:

  • status: Current status, should be 1f (document me better!)
  • signal: Signal strength. The values shown here can vary from card to card, so if yours appears abnormally high or low, it probably means you're using a different card. In general, though, higher values mean better signal.
  • snr: The signal to noise ratio. This is more important than the signal strength. Many cards really only supply 8 bits of data (2 digits); the other two may be 00 or repeat the first two, as in this example.
  • ber: The bit error rate. This should be as low as possible, preferably 0.
  • unc: Uncorrected block errors. This should be 0 for a good signal; if it isn't, you'll have defects in the output stream.
  • FE_HAS_LOCK: This indicates that the tuner has tuned ("locked") into the stream.

Recording a program

There are two ways to record a program. tzap can copy the data directly to a file:

tzap -o foo 'SBS digital 1'

This variant tunes to SBS digital 1 and then copies the stream to the file foo. It continues until you stop the tzap process.

Or, to record a channel for a specified period of time (this could be run from at to record at a specific time):

tzap -t 3600 -o foo.ts "BBC ONE"

(This records from the channel BBC ONE for 1 hour (3600 seconds)).

Alternatively, you can make the MPEG stream available via one of the DVB adaptor devices, typically /dev/dvb/adaptor0/dvr0. For this, you need to specify at least the -r option. If you have more than one tuner and want a different device, for example /dev/dvb/adaptor3/dvr0, use the option '-a 3' as well. You will also probably want to use the -S option to stop the status output every second.

tzap -r -a 3 -S 'SBS digital 1'

You can then copy the stream to a file or view it with mplayer, for example:

cp /dev/dvb/adapter0/dvr0 foo


mplayer /dev/dvb/adapter0/dvr0

Exiting after tuning

The -x option tells tzap to exit once it has tuned the tuner. This is only of interest if you don't want to do anything more; when tzap exits, the connection to the tuner also goes away.


For tuning dvb-s channels szap currently does not have an lnb type defined that will work with standard Ku LO: 10750 lnbs such as are commonly used in North America. Download the source for dvb-apps and in util/lib/lnb.c edit the standard_desc from 10000 to 10750. There are two spots to edit. One at about line 20 and again at about line 38. You'll probably want to do the same for util/scan/lnb.c. Run make and the newly compiled versions will now tune channels using your 10750 Ku lnb or lnbf.