[mythtv-users] Tuning QAM for Charter Cable with HD3000

Dylan R. Semler dsemler at macalester.edu
Sun Mar 12 18:11:46 UTC 2006


jborn at charter.net wrote:

>I would love the script. I have about 100 different entries to test across three files.
>
>I've updated the channels.conf files to read test1: and now trying to run
>azap -r test1 in one window and in another running mplayer /dev/dvb/adapter0/dvr0.  So far mplayer does not even seem to start.  Is this normal when the channels is encrypted?
>  
>
Yup, that is the typical behavior for encrypted channels

>Thanks,
>
>jb
>  
>
Here is the script, make sure you make the correct changes to the 
variables at the beginning.  This script will take a long time so make 
sure you run it when you don't need to be using your computer.  It also 
scans and generates a channels.conf automatically.  This can take a 
while, so you might want to comment it out (line 38).  If you decide to 
use yours, just change those entries that I told you to replace with 
test1 and test2 back to something of the format [####] and make sure it 
is located in ~/.azap/channels.conf. i.e. change

test1:609000000:QAM_256:0:2049:1
test2:609000000:QAM_256:0:2113:3
[0002]:609000000:QAM_256:0:2177:2


back to

[0001]:609000000:QAM_256:0:2049:1
[0003]:609000000:QAM_256:0:2113:3
[0002]:609000000:QAM_256:0:2177:2


Also, many people have been having trouble with the way this detects 
encryption (using the time program to time how long mplayer takes to 
play the file--an encrypted file should exit immediately).  This is 
apparently due to different behaviors of the time program on different 
systems.  If it doesn't work for you we can perhaps trouble shoot to try 
to get it to work with time or use a different method to detect mplayer 
exiting without playing anything.

Paste the following into a file (perhaps named scanscript.sh).  Don't 
forget to chmod +x scanscript.sh.  Good luck.

#/bin/bash

#
# Very very simple way of creating a channels.conf file that contains only
# non-encrypted channels coming in over cable.  The first lines of this 
file
# (lines 23, 26, 29, and 32) need to be adjusted to run on each 
computer.  You
# will also need a ~/.azap folder.  This script must be run directly 
from the
# computer that contains the tuner.  If you ssh into the computer and 
try to
# run this script, the mplayer timings will be off and it will probably not
# function correctly.  This script takes a while to run and should be run
# while the computer is not being used.  This script will probably not 
function
# if it finds more that 999 total channels (encrypted and non-encrypted) or
# more than 99 non-encrypted channels.  These limitations can be easily
# fixed by someone who knows what they are doing.  The end of the script
# contains a section to automatically update the mysql database.  What's
# written seems to work for me however I don't know if it will work 
elsewhere
# so uncomment at your own risk.
#
# Script by Dylan R. Semler
#

#Path to the dvb-apps scan subdirectory
pathtoscan=/usr/local/dvb-apps/util/scan

#Path to the dvb-apps azap subdirectory
pathtoazap=/usr/local/dvb-apps/util/szap

#Path to store temp files
tempdir=/video

#Path to DVB device:
dvbdevice=/dev/dvb/adapter0/dvr0

#Backup current channels.conf file
cp ~/.azap/channels.conf ~/.azap/channels.conf.back >& /dev/null

#run atscscan to generate channels.conf file in ~/.azap/
$pathtoscan/atscscan 
$pathtoscan/atsc/us-Cable-Standard-center-frequencies-QAM256 > 
~/.azap/channels.conf

#Replace the ugly-looking first entries of channels.conf with try###
for (( i = 999 ; i >= 1 ; i-- )); do
  sed -i "$[i]s/^.*\]/try$i/" ~/.azap/channels.conf
done

#Get number of lines in channels.conf
total=`cat -n ~/.azap/channels.conf | awk '{ print $1 }' | tail -1`

channum=0

#Test channels for video footage:
for (( i = 1 ; i <= $total ; i++ )); do

    #Try to tune channel
    $pathtoazap/azap -r try$i >& /dev/null &
    azapid=$!
    sleep 2

    #Create 5 second long test video
    cat $dvbdevice > $tempdir/test.mpg &
    catid=$!
    sleep 5
    kill $catid >& /dev/null
    kill $azapid >& /dev/null

    #Time how long it takes mplayer to play the video.  If it is less than
    #2.5 seconds, then the channel is assumed to be encrypted or a music
    #channel
    echo | time -o $tempdir/time.dat mplayer $tempdir/test.mpg >& /dev/null
    length=`sed -e 's/^.*system 0:0//' -e 's/elapsed.*$//' -e /outputs/d 
-e s/\\\.// $tempdir/time.dat`

    #Adjust channels.conf if no video was played
    if [ $[10#$length] -lt 250 ]; then
    sed -i /try$i:/d ~/.azap/channels.conf
    length=
    else
    channum=$((channum+1))
    fi

done
if [ $channum = 1 ]; then
    echo "found $channum channel"
else
    echo "found $channum channels"
fi

#Re-number channels.conf file in order
for (( i = 999 ; i >= 1 ; i-- )); do
    sed -i "$[i]s/try[0-9]\{1,3\}/try$i/" ~/.azap/channels.conf
done

#Remove temp files
rm $tempdir/test.mpg
rm $tempdir/time.dat


# Auto update mythtv's mysql database--not complete, but seems to work 
for me.

#rm channelinput.sql

#for (( i = $channum ; i >= 1 ; i-- )); do
#    echo $i
#    serviceid=`sed -n $[i]s/^.*://p ~/.azap/channels.conf`
#    frequency=`sed -n $[i]s/try[0-9]*\://p ~/.azap/channels.conf| sed 
s/\:QAM.*//`
#    mplexid=`grep $frequency mplexid.dat | awk '{ print $1 }'`
#    if [ $i -lt 10 ]; then
#    j=0$i
#    else
#    j=$i
#    fi
#    echo "INSERT INTO channel VALUES 
('31$j','1$j','NULL','3','try$i','try$i','none','NULL','','','0','32768','32768','32768','32768','Default','0','1','','1','$mplexid','$serviceid','1');" 
 >> channelinput.sql
#done

#echo flush privileges\; >> channelinput.sql

#mysql -u root -p mythconverg < channelinput.sql


More information about the mythtv-users mailing list