View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 27 posts ] 
Go to page Previous  1, 2

Print view Previous topic   Next topic  
Author Message
Search for:
 Post subject:
PostPosted: Tue Jun 13, 2006 9:54 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
My first attempt at this used a backgrounded function and didn't work. The channel change didn't complete until all the spawned processes had exited. This rocked me back on my heels because I've used backgrounded functions before to monitor the parent process and do cleanup. Now I can't claim that the parent waiting for all the childern wasn't an artifact of the way I was testing, but I did test it and it didn't work.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 13, 2006 11:16 pm 
Offline
Joined: Mon Sep 27, 2004 1:26 pm
Posts: 16
I know for sure that the channel change script I posted "works", meaning that the channel changes, and the values are set, and the channel change takes way less than 10 seconds.

As for the handling other options and/or tuners, it didn't seem to me to be much more duplication to replicate my script than the change_tuner0/1 scripts, but that's just my opinion. I.e., it would have been acceptable to me to have my script be the equivalent of change_tunerN

Personally, I would have preferred the script to accept things like:

-d dev brightness=nn contrast=mm etc.

Basically handle any ivtvctl param, and then repeat with all params (other than the -y options) for each -y or --set-ctrl, since (sadly) ivtvctl doesn't permit more than one ctl to be specified via -y like it does for most other params. The last argument will always be the channel/freq. It just seemed like more work than necessary. So, I think what Mr. Frost suggested is probably a pretty good compromise. Here is my take of the suggested implementation (other than disowning, which I left in for no particular reason):

Code:
#!/bin/bash

# channel_change.sh [devicenum] frequency

# if devicenum is specified, it should be the N in /dev/videoN.  It
# defaults to zero.

# Uncomment this for debugging
#set -vx

DEVICE=0     # Which /dev/videoN to use.
if [ $# -gt 1 ]; then
  DEVICE=$1
  shift;
fi

FREQ_TBL="us-cable-irc" # Possibly "us-cable", "us-cable-hrc", ...
BRIGHTNESS=127 # Picture brightness, actually the black level. [0 - 255]
CONTRAST=63    # Picture contrast or luma gain. [0 - 127]
SATURATION=63  # Picture color saturation or chroma gain. [0 - 127]
HUE=0          # Hue or color balance. [-128 - 127]
VOLUME=60000   # Overall audio volume. [0 - 65535]

case $DEVICE in
  (0) # Device specific settings for /dev/video0
      #SATURATION=66
      ;;
  (1) # Device specific settings for /dev/video1
      #HUE=3
      ;;
esac

exec >>/tmp/changer$DEVICE.log 2>&1
CTL_OPTS="-d /dev/video$DEVICE"

function delayed_tune()
{
  echo ; echo Settings before:
  /usr/local/bin/ivtvctl $CTL_OPTS -Y
  for i in 0 2 4 6 8 10 ; do
      /usr/local/bin/ivtvctl $CTL_OPTS -y brightness=$BRIGHTNESS >/dev/null
      /usr/local/bin/ivtvctl $CTL_OPTS -y contrast=$CONTRAST     >/dev/null
      /usr/local/bin/ivtvctl $CTL_OPTS -y saturation=$SATURATION >/dev/null
      /usr/local/bin/ivtvctl $CTL_OPTS -y hue=$HUE               >/dev/null
      /usr/local/bin/ivtvctl $CTL_OPTS -y volume=$VOLUME         >/dev/null
      sleep 2
  done
  echo ; echo Settings after:
  /usr/local/bin/ivtvctl $CTL_OPTS -Y
}

export HOME=/home/mythtv
echo "Setting channel to $1"
#env
/usr/local/bin/ivtv-tune $CTL_OPTS -t $FREQ_TBL -c $1
delayed_tune args&
disown -h %1


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 14, 2006 12:35 am 
Offline
Joined: Mon May 10, 2004 8:08 pm
Posts: 1891
Location: Adelaide, Australia
Nice job. What I like about doing it that way is there is a single location that you need to look to see what the differences in parameters required for the cards are.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 25, 2006 5:04 pm 
Offline
Joined: Thu Feb 02, 2006 3:57 am
Posts: 31
I'm having some trouble getting these scripts to work. I have a PVR-350 (/dev/video0) and a PVR-150 (/dev/video1) in R5C7 (IVTV 0.4.4). I copied the scripts from tjc's first post. The only change I made was to set FREQ_TBL to "us-cable".

When I change the channel from the command line with the script
Code:
/usr/local/bin/change_tuner0.sh 60

the picture looks good for a moment and then gets very dark.

From /tmp/changer0.log, I can see that the brightness is getting set to zero but the script is supposed to set it at 127. And the audio level only goes up to 60000 even though the script specifies 64000.
Quote:
Setting channel to 27
/dev/video0: 241.250 MHz (Signal Detected)

Settings before:
ioctl: VIDIOC_QUERYCTRL
Brightness = 127
Contrast = 63
Saturation = 63
Hue = 0
Volume = 58950
Mute = 0

Settings after:
ioctl: VIDIOC_QUERYCTRL
Brightness = 0
Contrast = 63
Saturation = 63
Hue = 0
Volume = 60000
Mute = 0
/usr/local/bin/change_tuner0.sh: line 20: 127: command not found
/usr/local/bin/change_tuner0.sh: line 21: 0: command not found
/usr/local/bin/change_tuner0.sh: line 22: 63: command not found
/usr/local/bin/change_tuner0.sh: line 23: 63: command not found
/usr/local/bin/change_tuner0.sh: line 24: 64000: command not found

I see that others have posted some different ideas about how the scripts should be done but I just don't know how to implement them. Only tjc's post spelled everything out in a way I can understand (or maybe I didn't understand it as well as I thought).


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 25, 2006 8:00 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
Given those errors I'm guessing that you either have a line wrapping problem or extra spaces from the way you copied those scripts. Make your font smaller and stretch your browser window as wide as possible before you try to cut and paste. Pay particular attention to trailing spaces, since cut and paste from the forums tends to add one at the end of each line and that's a no-no after a \ continuation character.

BTW - For future reference here is a bit of script to clean up files like that:
Code:
sed -si'.old' -e 's/[ \r]*$//'  YOUR.FILENAME.HERE

Edited to add script.


Last edited by tjc on Sun Jun 25, 2006 8:45 pm, edited 1 time in total.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 25, 2006 8:33 pm 
Offline
Joined: Thu Feb 02, 2006 3:57 am
Posts: 31
It was the trailing spaces. I removed them and it works great now.

Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 27, 2006 10:29 am 
Offline
Joined: Wed Mar 29, 2006 11:04 am
Posts: 5
tjc:

I am using your scripts and am having a problem.

When I run the script manually and specify the channel number like this:

change_tuner0.sh 7

The the script acts as it should. Here is the log file:

Setting channel to 7
/dev/video0: 175.250 MHz (Signal Detected)

Settings before:
ioctl: VIDIOC_QUERYCTRL
Brightness = 128
Contrast = 55
Saturation = 127
Hue = 251
Volume = 64000
Mute = 1

Settings after:
ioctl: VIDIOC_QUERYCTRL
Brightness = 128
Contrast = 55
Saturation = 127
Hue = 251
Volume = 64000
Mute = 0

When I use Myth to change the channel, myth shows me the browse of the new channel but when I select it there is a slight pause and then the same channel as before is tuned. If I browse in myth, myth thinks the channel changed. (ie: if I change from 7 to 11 the video stays on 7 and myth thinks I am on 11)

Here is the log from the channel change with myth:

Setting channel to 199250
Invalid channel for 'us-cable-irc'

Settings before:
ioctl: VIDIOC_QUERYCTRL
Brightness = 383
Contrast = 63
Saturation = 63
Hue = 0
Volume = 64000
Mute = 0


Obviously, the channel number (199250) is not recognized, wonder why? :wink: :D

I have tried us-cable, us-cable-irc, and us-cable-hrc (they all tuned the correct channel manually, and did not when tuned from myth. BTW us-cable-irc gives me the best quality)

Without the script in the change channel command, myth tunes the channels correctly.

I think the problem is the command line I put in MythSetup. I just put the scripit location/name in the change channel command line and nothing else. Is this it?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 27, 2006 10:19 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
Quote:
I just put the scripit location/name in the change channel command line and nothing else. Is this it?
That is how mine is setup.

Based on that number I'm guessing that it's a frequency rather than a channel as expected by the script. Double check your channel table in the mythconverg DB schema. My channum and freqid numbers are identical. if yours aren't, you can either change the DB table or the ivtv-tune commands in the scripts. Running:
Code:
ivtv-tune --help
should provide the necessary details.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 28, 2006 6:37 pm 
Offline
Joined: Wed Mar 29, 2006 11:04 am
Posts: 5
Quote:
Based on that number I'm guessing that it's a frequency rather than a channel as expected by the script.


Right you are. Using the biggest hammer I could find I was able to cobble enough code to take the number and turn it into a properly formated frequency :) .

Thanks for the script and thanks for the help.

Don


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 28, 2006 10:09 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
:shock: Big hammer? That should be a one liner in awk... If you have the frequency in a variable called FREQ, you can get the formatted frequency in a variable called FFREQ like this:
Code:
FFREQ=$(echo $FREQ | awk '{print $1/1000}')


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 29, 2006 11:48 am 
Offline
Joined: Wed Mar 29, 2006 11:04 am
Posts: 5
tjc wrote:
:shock: Big hammer? That should be a one liner in awk... If you have the frequency in a variable called FREQ, you can get the formatted frequency in a variable called FFREQ like this:
Code:
FFREQ=$(echo $FREQ | awk '{print $1/1000}')


Yikes!!!

Wellll, thanks for this and I still have MUCH to learn with bash scripting :wink:


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 02, 2006 10:06 am 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
donb - Take a look at this thread, it seems like the basic problem might be strange values in the freqid column of you channel table - http://mysettopbox.tv/phpBB2/viewtopic.php?t=10662


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 27 posts ] 
Go to page Previous  1, 2



All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu