Ivtv Channel changer
From MythTV Official Wiki
Note: The correct title of this article is ivtv Channel changer. It appears incorrectly here due to technical restrictions.
| Author | Nick Fox |
| Description | Channel-change script using ivtv-utils tools to perform channel changing. |
| Supports |
This is a script to use the ivtv-utils tools to perform channel changing.
This script is designed to work around an issue in ivtv drivers that results in audio-quality problems ("tinny audio"), as mentioned on the ivtv wiki.
#!/usr/bin/env python
#
# myth-chan
# A wrapper for MythTV external channel changers
# This is setup to remedy a known audio instability with certian
# TV Capture devices.
#
# Copyright 2009 Nick Fox ( nfox a foxmediasystems d com )
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
# Get python defaults
import os
import sys
from optparse import OptionParser
import subprocess
def main(self):
# Go Baby GO!
# Setup the options
parser = OptionParser()
parser.add_option("-c", "--dct-channel", nargs=3, help="Use DCT Channel Binary to change channels.\
usage: myth-chan <-c | --dct-channel> <port> <video_source> <channel>", dest="dct")
parser.add_option("-d", "--direct-tv", nargs=4, help="Use the DirectTV external channel changer.\
usage: myth-chan <-d | --direct-tv> <set-top-box-type> <port> <video_source> <channel>", dest="dtv")
(options, args) = parser.parse_args()
if options.dct:
dct_channel(options.dct[0],options.dct[1],options.dct[2])
if options.dtv:
dtv_channel(options.dtv[0],options.dtv[1],options.dtv[2],options.dtv[3])
def dct_channel(port, vidsrc, chan):
# Wrapper up and Use the channel binary
try:
if os.path.exists("/usr/local/bin/channel"):
cmd = "/usr/local/bin/channel -p " + port + " " + chan
subprocess.Popen4(["v4l2-ctl -d " + vidsrc + " --set-audio-input=2"])
subprocess.Popen4([cmd])
subprocess.Popen4(["v4l2-ctl -d " + vidsrc + " --set-audio-input=1"])
else:
print "/usr/local/bin/channel not found!"
except:
print "Channel Binary failed to change channels."
def dtv_channel(stb_type, port, vidsrc, chan):
# directtv.pl wrapper
try:
if os.path.exists("/usr/local/bin/directv.pl"):
cmd = "/usr/local/bin/directtv.pl port " + port + " box_type " + stb_type + " setup_channel " + chan
subprocess.Popen4(["v4l2-ctl -d " + vidsrc + " --set-audio-input=2"])
subprocess.Popen4([cmd])
subprocess.Popen4(["v4l2-ctl -d " + vidsrc + " --set-audio-input=1"])
else:
print "/usr/local/bin/directv.pl not found!"
except:
print "directv.pl failed to change channels."
if __name__ == "__main__":
main(sys.argv[1:])