DVB-T Signal test on Linux

If you want to know if you are getting a good signal strength through your DVB tuner card, this is how to test it on linux. There is a guide here, but it’s not very descriptive. I have ubuntu, so it might be slightly different for other distributions. First of all you need to install the LinuxTV dvb-apps package if you haven’t got it already. Go here for further information, but on ubuntu install like this:

apt-get install dvb-apps

First of all you need to use dvb scan to create a channel.conf file to use with tzap. Without a channel file, tzap won’t know what to look for. On your linux system you should have a directory full of dvb channel information for your region – mine is under “/usr/share/dvb/dvb-t/”.  You will find the channel information is stored under your country code. Eg. for australia all the available channel files are under au*.

 ls -l /usr/share/dvb/dvb-t/au*
-rw-r--r-- 1 root root  364 Dec 27  2011 /usr/share/dvb/dvb-t/au-Adelaide
-rw-r--r-- 1 root root  371 Dec 27  2011 /usr/share/dvb/dvb-t/au-AdelaideFoothills
-rw-r--r-- 1 root root 1344 Dec 27  2011 /usr/share/dvb/dvb-t/au-Bendigo
-rw-r--r-- 1 root root  380 Dec 27  2011 /usr/share/dvb/dvb-t/au-Brisbane
-rw-r--r-- 1 root root  446 Dec 27  2011 /usr/share/dvb/dvb-t/au-Cairns
-rw-r--r-- 1 root root  360 Dec 27  2011 /usr/share/dvb/dvb-t/au-canberra
-rw-r--r-- 1 root root  363 Dec 27  2011 /usr/share/dvb/dvb-t/au-Canberra-Black-Mt
-rw-r--r-- 1 root root  451 Dec 27  2011 /usr/share/dvb/dvb-t/au-Coonabarabran
-rw-r--r-- 1 root root  324 Dec 27  2011 /usr/share/dvb/dvb-t/au-Darwin
-rw-r--r-- 1 root root  558 Dec 27  2011 /usr/share/dvb/dvb-t/au-Devonport
-rw-r--r-- 1 root root  442 Dec 27  2011 /usr/share/dvb/dvb-t/au-FraserCoast-Bundaberg
-rw-r--r-- 1 root root  777 Dec 27  2011 /usr/share/dvb/dvb-t/au-GoldCoast
-rw-r--r-- 1 root root  649 Dec 27  2011 /usr/share/dvb/dvb-t/au-Goulburn-Rocky_Hill
-rw-r--r-- 1 root root  458 Dec 27  2011 /usr/share/dvb/dvb-t/au-Hervey_Bay-Ghost_Hill
-rw-r--r-- 1 root root  390 Dec 27  2011 /usr/share/dvb/dvb-t/au-Hobart
-rw-r--r-- 1 root root  447 Dec 27  2011 /usr/share/dvb/dvb-t/au-Mackay
-rw-r--r-- 1 root root  382 Dec 27  2011 /usr/share/dvb/dvb-t/au-Melbourne
-rw-r--r-- 1 root root  371 Dec 27  2011 /usr/share/dvb/dvb-t/au-Melbourne-Upwey
-rw-r--r-- 1 root root  732 Dec 27  2011 /usr/share/dvb/dvb-t/au-MidNorthCoast
-rw-r--r-- 1 root root  354 Dec 27  2011 /usr/share/dvb/dvb-t/au-Newcastle
-rw-r--r-- 1 root root  374 Dec 27  2011 /usr/share/dvb/dvb-t/au-Perth
-rw-r--r-- 1 root root  375 Dec 27  2011 /usr/share/dvb/dvb-t/au-Perth_Roleystone
-rw-r--r-- 1 root root  289 Dec 27  2011 /usr/share/dvb/dvb-t/au-SpencerGulf
-rw-r--r-- 1 root root  402 Dec 27  2011 /usr/share/dvb/dvb-t/au-SunshineCoast
-rw-r--r-- 1 root root  633 Dec 27  2011 /usr/share/dvb/dvb-t/au-Sutherland
-rw-r--r-- 1 root root  414 Dec 27  2011 /usr/share/dvb/dvb-t/au-Sydney_Kings_Cross
-rw-r--r-- 1 root root  490 Dec 27  2011 /usr/share/dvb/dvb-t/au-Sydney_North_Shore
-rw-r--r-- 1 root root 1183 Dec 27  2011 /usr/share/dvb/dvb-t/au-Tamworth
-rw-r--r-- 1 root root  380 Dec 27  2011 /usr/share/dvb/dvb-t/au-Townsville
-rw-r--r-- 1 root root  133 Dec 27  2011 /usr/share/dvb/dvb-t/au-unknown
-rw-r--r-- 1 root root  383 Dec 27  2011 /usr/share/dvb/dvb-t/au-WaggaWagga
-rw-r--r-- 1 root root 1309 Dec 27  2011 /usr/share/dvb/dvb-t/au-Wollongong

So if I was in the Wollongong region I would type the following to get my channels.conf file created.

$ scan /usr/share/dvb/dvb-t/au-Wollongong > channels.conf

It should go off and scan your regions channels for you. You should see something like this:


 scanning /usr/share/dvb/dvb-t/au-Wollongong
 using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
 initial transponder 697500000 1 3 9 3 1 1 0
 initial transponder 655500000 1 3 9 3 1 1 0
 initial transponder 613500000 1 3 9 3 1 1 0
 initial transponder 634500000 1 3 9 3 1 1 0
 initial transponder 711625000 1 2 9 3 1 2 0
 initial transponder 690500000 1 3 9 3 1 1 0
 initial transponder 599500000 1 3 9 3 1 1 0
 initial transponder 585500000 1 3 9 3 1 1 0
 initial transponder 592500000 1 3 9 3 1 1 0
 initial transponder 676500000 1 2 9 3 1 2 0
 >>> tune to: 697500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE
 0x0000 0x02a1: pmt_pid 0x0000 ABC -- ABC1 (running)
 0x0000 0x02a2: pmt_pid 0x0000 ABC -- ABC2 / ABC4 (running)
 0x0000 0x02a0: pmt_pid 0x0000 ABC -- ABC News 24 (running)
 0x0000 0x02a3: pmt_pid 0x0000 ABC -- ABC1 (running)
 0x0000 0x02a6: pmt_pid 0x0000 ABC -- ABC Dig Music (running)
 0x0000 0x02a7: pmt_pid 0x0000 ABC -- ABC Jazz (running)
 0x0000 0x02a4: pmt_pid 0x0000 ABC -- ABC3 (running)
 Network Name 'ABC NSW'
 >>> tune to: 655500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE
 WARNING: filter timeout pid 0x0011
 scan /usr/share/dvb/dvb-t/au-Wollongong > channels.confWARNING: filter timeout pid 0x0010
 >>> tune to: 613500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE
 Network Name 'MH Illawarra'
 0x0000 0x0001: pmt_pid 0x0000 WIN Television -- WIN Illawarra (running)
 0x0000 0x000a: pmt_pid 0x0000 WIN Television -- GEM Illawarra (running)
 0x0000 0x000f: pmt_pid 0x0000 WIN Television -- GOLD (running)
 0x0000 0x0002: pmt_pid 0x0000 WIN Television -- GO! Illawarra (running)
 >>> tune to: 634500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE
 0x0000 0x0809: pmt_pid 0x0180 SC Media -- SC10 Wollongong (running)
 0x0000 0x0829: pmt_pid 0x0776 SC Media -- ONE Wollongong (running)
 0x0000 0x0849: pmt_pid 0x0780 SC Media -- ELEVEN (running)
 Network Name 'SCA'
 >>> tune to: 711625000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_2_3:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE
 0x0000 0x0351: pmt_pid 0x0401 SBS -- SBS ONE (running)
 0x0000 0x0355: pmt_pid 0x0400 SBS -- SBS HD (running)
 0x0000 0x0352: pmt_pid 0x0402 SBS -- SBS TWO (running)
 

Etc.. etc…. it might take several minutes to run, but in the end you should have the channels.conf we need to run our signal tests with. If you look inside of channels.conf you should see something like this:


 cat channels.conf
 ABC1:697500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:512:650:673
 ABC2 / ABC4:697500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:513:651:674
 ABC News 24:697500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:516:0:672
 ABC1:697500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:512:650:675
 ABC Dig Music:697500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:0:690:678
 ABC Jazz:697500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:0:700:679
 ABC3:697500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:514:652:676
 [0942]:655500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:2700:2701:2370
 [0960]:655500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:2700:2701:2400
 [0961]:655500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:2700:2701:2401
 [0962]:655500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:4620:4621:2402
 [0963]:655500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:4630:0:2403
 [0964]:655500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:4640:4641:2404
 WIN Illawarra:613500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:503:653:1
 GEM Illawarra:613500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:543:0:10
 GOLD:613500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:599:699:15
 GO! Illawarra:613500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:523:673:2
 SC10 Wollongong:599500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:4620:4621:2402
 7mate Wollongong:599500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:4630:0:2403
 4ME:599500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:4640:4641:2404
 WIN Illawarra:585500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:503:653:1
 GO! Illawarra:585500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:523:673:2
 GEM Illawarra:585500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:543:0:10
 GOLD:585500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:599:699:15

Now all you need to do is use the script available here written by José Oliver Segura. This script is quite good, as it calculates the signal strenght for us and make sense of all those number tzap produces. You can download a copy of the script here also. You may need to modify the $channelsConf variable to point to wherever you have saved your channels.conf file. Run is like this:

$ perl testsignal > results.txt &

It will now go off and test your channel’s and save the results in results.txt. I had quite a few channels, so it took me some considerable time to run this script. If you want to watch the progress, then just tail the results.txt file.

$ tail -f results.txt

You should see something like this:

================================================================================
Tunning channel ABC News 24 (226500000)
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
tuning to 697500000 Hz
video pid 0x0204, audio pid 0x0000
status 01 | signal 8480 | snr 0000 | ber 00000000 | unc 00000c78 |
status 01 | signal 9bf8 | snr 0000 | ber 00000000 | unc 00000c78 |
status 1f | signal 4ac0 | snr acac | ber 00000000 | unc 00000c78 | FE_HAS_LOCK (Ignoring to let tuner/decoder settle.(2)
status 1f | signal 4ac0 | snr acac | ber 00000000 | unc 00000c78 | FE_HAS_LOCK (Ignoring to let tuner/decoder settle.(1)
Signal: 29%     BER 0   UNC 3192
Signal: 29%     BER 0   UNC 3192
Signal: 29%     BER 0   UNC 3192
Signal: 29%     BER 1693        UNC 3192
Signal: 29%     BER 1693        UNC 3192
Signal: 29%     BER 1693        UNC 3192
Signal: 29%     BER 1693        UNC 3192
Signal: 29%     BER 1693        UNC 3192
Signal: 29%     BER 1490        UNC 3192
Signal: 29%     BER 1490        UNC 3192

Joining two (or more) avi files together with mencoder

Have you ever needed to join two avi (or more) files together to create one avi file? Well there is an easy way to merge them together using mencoder. This also assumes that the files are actually the same size, in the same codec etc.

Make sure you are in the same directory as the files you want to join

Use the following command to join the files.
mencoder -forceidx -ovc copy -oac copy -o outputfile.avi firstfile.avi secondfile.avi

Obviously you would replace outputfile.avi, firstfile.avi and secondfile.avi with whatever is appropriate what you are doing.
Mencoder will go off and join the two files. It should do this really quickly as this command is not re-encoding the files, just putting them together. It should look something like this:


$ mencoder -forceidx -ovc copy -oac copy -o new_file.avi 1.avi 2.avi
MEncoder svn r34540 (Ubuntu), built with gcc-4.6 (C) 2000-2012 MPlayer Team
success: format: 0 data: 0x0 - 0x2bcbd408
libavformat version 53.21.0 (external)
Mismatching header version 53.19.0
AVI file format detected.
[aviheader] Video stream found, -vid 0
[aviheader] Audio stream found, -aid 1
Generating Index: 99 %
AVI: Generated index table for 158686 chunks!
VIDEO: [XVID] 624x256 12bpp 23.976 fps 1319.0 kbps (161.0 kbyte/s)
[V] filefmt:3 fourcc:0x44495658 size:624x256 fps:23.976 ftime:=0.0417
videocodec: framecopy (624x256 12bpp fourcc=44495658)
audiocodec: framecopy (format=2000 chans=6 rate=48000 bits=0 B/s=56000 sample-1)
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Pos:3308.5s 79325f (99%) 4307.40fps Trem: 0min 700mb A-V:0.000 [1318:448]
Incomplete stream? Trying resync.
Pos:3309.3s 79345f (100%) 4301.24fps Trem: 0min 697mb A-V:0.000 [1318:447]
success: format: 0 data: 0x0 - 0x2bb43de0
AVI file format detected.
[aviheader] Video stream found, -vid 0
[aviheader] Audio stream found, -aid 1
Generating Index: 99 %
AVI: Generated index table for 150239 chunks!
VIDEO: [XVID] 624x256 12bpp 23.976 fps 1414.9 kbps (172.7 kbyte/s)
[V] filefmt:3 fourcc:0x44495658 size:624x256 fps:23.976 ftime:=0.0417
videocodec: framecopy (624x256 12bpp fourcc=44495658)
audiocodec: framecopy (format=2000 chans=6 rate=48000 bits=0 B/s=56000 sample-1)
Pos:4587.6s 109994f (46%) 3049.37fps Trem: 0min 2201mb A-V:0.071 [1419:448]]]
ODML: Starting new RIFF chunk at 1023MB.
Pos:6442.5s 154466f (100%) 3326.00fps Trem: 0min 1395mb A-V:0.071 [1365:447]
Writing index...
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Video stream: 1365.588 kbit/s (170698 B/s) size: 1099729277 bytes 6442.526 secs 154466 frames
Audio stream: 448.000 kbit/s (55999 B/s) size: 360772608 bytes 6442.368 secs

If you are wondering what the mencoder options are, here is a basic run down.

-forceidx – this forces the regeneration of the index table for the video. Apparently it’s needed.
-ovc copy – this tells mencoder to copy the video codec exactly as per the input file(s). In other words don’t re-encode it.
-oac copy – this tells mencoder to copy the audio codec exactly as per the input file(s). Again, in other words don’t re-encode it.

Oh, and in case you are wondering if you have more than two files you just add more on to the end of the command. Example:

mencoder -forceidx -ovc copy -oac copy -o outputfile.avi firstfile.avi secondfile.avi thirdfile.avi forthfile.avi

Also, if you don’t actually have mencoder, you can install it by running this command:

sudo apt-get install mencoder

References: http://www.mplayerhq.hu/DOCS/HTML/en/index.html