Video Switcher Scripts
Both of our video webcasts,
the RealVideo and
JPEG slideshow versions,
take a single NTSC baseband video signal as input to their
respective video capture cards. We've got a bunch of cameras
in the club, so something needs to switch between the cameras
in order to feed different signals to the webcast.
That something is a
Knox RS16x16 video matrix switcher. Basically, it's
a big box that has 16 inputs and 16 outputs, and you get to pick
which of the inputs each of the outputs is fed from (so each input
could go to all of the outputs, none of them, or anywhere in between.)
There's a keypad on the front panel that lets you change the routing
and program simple loops. But the cool thing is that it also has a
serial port on the back, so you can do your switching from a computer.
We used to have a small computer up there next to it, and it
talked to the serial port directly. But these days we have a
Lantronix UDS-10 serial port to ethernet adapter
plugged in to the switcher instead, and the software that controls
it is running on a computer that is physically elsewhere.
One of the outputs from the switcher goes directly into the video
cards on the webcast computers; the other fifteen outputs go into a
set of RF encoders
(NetMedia MM73
Triple Play) that put each of those signals onto a different UHF
channel on the private cable TV system we've got running through the
club. We've got a bunch of televisions scattered around, and by just
plugging them into the cable and picking a channel, we can have them all
displaying random images from the various cameras. Since there are
15 channels to choose from, it's easy to set things up so that no
adjacent TVs have the same image on them.
When there are folks in the club doing video projections or other
visuals, this setup makes it easy for us to put their imagery on the
TVs; they just need to plug into one or more of the spare inputs on the
switcher, and then click a few checkboxes on a web page to put their
content into the mix.
|
switcher-cmd.pl
|
This is a shell script that talks to the
Knox switcher over the serial port (or network, via the
serial-to-ethernet adapter). Command line options
control what gets switched where. It also has provisions
for looping and for randomly switching certain ranges of
inputs to certain ranges of outputs.
|
|
switcher-initd
|
A simple init.d script that launches
switcher-cmd.pl and
pancam.pl daemons
at boot-time: they runs in a loop and poll the file
/etc/switcher.conf for the current command-line to use.
To change what the switcher is doing, I can just change
a single file, instead of having to kill and restart the
program.
|
|
switcher.cgi
|
This is a CGI script that controls the
switcher remotely: it lets you edit the switcher.conf
file graphically. The
switcher-cmd daemon will notice
and react to the changes.
Here's an example of what it
looks like when it is running (no, you can't use this page to
control our cameras!) The rows represent inputs (cameras)
and the columns represent outputs (TV channels, and the
webcam.) A checked box means that the switcher may
connect that input to that output. So, each time
delay seconds pass, the switcher looks at the set of
allowed inputs for each output and picks one at random.
|
One unfortunate thing I've noticed is that the switcher doesn't
seem to like to be told to switch more than about twice a second:
any faster than that, and it seems to suffer serial port overruns,
or something along those lines.
This makes me sad, because it turns out that our lighting
controller can output MIDI, so I had this idea that some of the video
switching could be keyed along with lighting changes by simply
putting a MIDI card in an adjascent Linux box. But alas, it seems
that it can't switch fast enough to make that be realistic...
_______________________________________________
In addition to the scripts to control the Knox switcher, I also
have scripts to control a
Panasonic WV-NS324 servo-mounted video camera. This
camera is pretty cool in that it has a "real" video output, but also
has an ethernet interface and a built-in web server, so you can
directly control it over the net.
But, it's very much not cool in that every now and
then it gets confused and all of its preset camera positions shift
by around 30 degrees, so it will suddenly be pointing at completely
different parts of the room than you wanted until you manually
re-enter all the presets. Maybe there's a belt or gear slipping
inside it or something; I can't figure out what the cause is. This
problem started only a few weeks after I bought the camera, and the
response from both Panasonic and the store I bought it from was,
basically, "sucks to be you."
So I wouldn't recommend this camera at all, and I would have
returned it if they hadn't refused to give me my money back.
|
pancam.pl
|
This script that reads the same config file
that switcher-cmd does, and
based on the commands in that file, tells the camera to
point at one of its preset positions. In this way, I have
a single config file that controls both the switcher and
the robo-camera (and that file is written by the
switcher.cgi web page.)
|
|
pancam.cgi
|
The WV-NS324 has a built-in web server,
with controls that let you manually zoom the camera,
save positions as presets, etc. Those web pages have
some problems, however. They're overly complicated
(many commands are spread out across multiple pages),
but most importantly, the "joystick" control on the
web pages (by which you actually move the camera)
doesn't work in Mozilla
or Safari (it
was coded for MSIE and Netscape 4.x only.)
So, I wrote my own UI for camera control, that works
by posting to the underlying "control" URLs on the camera,
bypassing the on-camera user interface. Works pretty good.
|
_______________________________________________