Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ivtv: users

Channel surfing script, volume script, and input script

 

 

ivtv users RSS feed   Index | Next | Previous | View Threaded


the_q123 at hotmail

Jul 1, 2010, 12:44 AM

Post #1 of 1 (1213 views)
Permalink
Channel surfing script, volume script, and input script

Oops, posted from the wrong e-mail address. Apologies if this ends up
duplicated, but I think my previous attempt may have been
/dev/nullified.

I've had lots of trouble getting things to operate my card, mostly
because nearly all of the players available want to mess with hardware
settings or re-encode the video stream and fail to do so.
v4l2-ctl and ivtv-tools "just work"; unfortunately, command line
interface is neither friendly nor comfortable (no matter how well
thought-out and simple) and people get confused when I changed the
channel in a terminal (it often becomes a point of discussion on why I
bother to use linux if it's so difficult.... even though it's not
difficult, just not pretty). Also, it's not very fast.

In response, I'm working on my own viewer-independent,
easier-than-command-line interface, using the media keys of a keyboard
and notify-send for output.

First up, tvchannel
It's just a shell script, but it makes a decent front-end to ivtv-tune.
You'll need a channel map for xawtv, but xawtv itself is unnecessary.
You can generate the channel map with scantv.
I recommend to put the file in /usr/local/sbin/tvchannel, make it
executable, and assign it to some hotkeys.
I used WinKey+MediaKeyNext for "tvchannel up" and
WinKey+MediaKeyPrevious for "tvchannel down".
This way you can channel surf no matter what front end you use to
watch the stream; even when the display is in the background (or
off..).

###BEGIN###
#! /bin/bash
# This script changes channels using ivtv-tune and an xawtv channel
map, but xawtv is not required.

# Get the last channel
CHANNEL=`cat ~/.tvchannelrc`

case "$1" in
up) # Surf channel up if mapped.
CHANGE="`expr $CHANNEL + 1`"
echo $CHANGE > ~/.tvchannelrc
;;
down) # Surf channel down if mapped.
CHANGE="`expr $CHANNEL - 1`"
echo $CHANGE > ~/.tvchannelrc
;;
*) # Switch to named or numbered channel if mapped.
CHANGE="$1"
;;
esac

notify-send --icon=gtk-info --urgency=critical --expire-time=999
"Channel $CHANGE" "`ivtv-tune -x $CHANGE`"
###END###

Wish-list:
1. More universal notification method? I'm not sure if "notify-send"
works everywhere. This was designed for and tested with Notify-OSD in
Ubuntu Lucid amd64. Notify-OSD itself could stand for numerous
improvements. https://bugs.launchpad.net/ubuntu/+source/notify-osd/+bug/390508
2. Clamp notification to video. Currently the notification is placed
in the default location (top right corner of screen for Ubuntu) it
would feel more natural if it displayed over the video stream. (I can
imagine x-windows is keeping track of the ivtv video stream's display
location with some variable... any idea what it might be?)
3. GUI for the third input type, specific number or name of a channel
in ~/.xawtv, preferably using the notifications OSD.
4. Find another way to map channels. scantv solved a problem for me:
My channel map is not standard. i have both japan-bcast AND
japan-cable on the same line. I used scantv to make two channel maps
and put them into one by hand. I wish there was a better way.

Next up, tvvolume
Same idea with v4l2-ctl + notfy-send.
I recommend to put the file in /usr/local/sbin/tvvolume, make it
executable, and assign it to some hotkeys.
I used WinKey+MediaKeyVol+ for "tvvolume up" and WinKey+MediaKeyVol-
for "tvvolume down", and WinKey+MediaKeyVolMute for "tvvolume mute".
This way you can change the volume no matter what front end you use to
watch the stream; even when the display is in the background (or
off..).

###BEGIN###
#! /bin/bash
# This script changes volume using v4l2-ctl.

# Get the last volume
VOLUME=`cat ~/.tvvolumerc`

case "$1" in
up) # Turn volume up.
CHANGE="`expr $VOLUME + 1000`"
echo $CHANGE > ~/.tvvolumerc
;;
down) # Turn volume down.
CHANGE="`expr $VOLUME - 1000`"
echo $CHANGE > ~/.tvvolumerc
;;
mute) # Mute volume, but don't save the value!
CHANGE="0"
;;
*) # No input or bad input (actually a number would be ok, but we'll
exit here just to be safe).
notify-send --icon=gtk-info --urgency=critical --expire-time=1000
"Volume $CHANGE" "Invalid input"
exit
;;
esac

v4l2-ctl -c volume="$CHANGE"
notify-send --icon=gtk-info --urgency=critical --expire-time=999
"Volume" "`v4l2-ctl -C volume`"
###END###

Wish-list:
1. Various improvements in notify-send so as to avoid having to write
an actual program.
https://bugs.launchpad.net/ubuntu/+source/libnotify/+bug/257135
2. Clamp notification to video.
3. A way to make mute/unmute on one button without using a separate
configuration file... this is my lack of skill.

And last, tvon
Same idea with v4l2-ctl + notfy-send. Same script style.
I recommend to put the file in /usr/local/sbin/tvon, make it
executable, and assign it to some hotkeys.
I used WinKey+MediaPlayPause for "tvon" and haven't decided what to do
with "tvon s-video" and "tvon composite".
You'll have to stop the stream before switching inputs, but you can
use any front end you like (default is totem). It feels nice summoning
television from the keyboard.

###BEGIN###
#! /bin/bash
# This script displays an ivtv stream from one of various sources in totem.

case "$1" in
s-video) # Set input to S-Video.
CHANGE=1
;;
composite) # Set input to Composite.
CHANGE=2
;;
*) # If otherwise or unspecified, set input to Tuner.
CHANGE=0
;;
esac

# open PVR stream in totem (for hardware-encoded MPEG)
notify-send --icon=gtk-info --urgency=critical --expire-time=1000
"Television" "`v4l2-ctl -i $CHANGE`"
totem /dev/video0
###END###

Wish-list:
1. Detect active stream, close it, and reopen with selected input.
(v4l2-ctl --streamoff returns invalid argument?)
2. Clamp notification to video.
3. A way to make mute/unmute on one button without using a separate
configuration file... this is my lack of skill.

So now, for the first time ever, my girlfriend can use something on my
computer and other people don't look quite as bewildered when I change
the channel. Also, thanks to the marvelous ivtv-driver support for
hardware encoding cards, I can watch PVR in totem, the only player I
like.

_______________________________________________
ivtv-users mailing list
ivtv-users [at] ivtvdriver
http://ivtvdriver.org/mailman/listinfo/ivtv-users

ivtv users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.