In the neverending quest for boredom-alleviating toys and entertainment, I recently came into possession of a Grand Multi Capture Card, bought from Allthings, based in Perth, who happened to be having a deal on card and camera packages.
It's another one of these delightful toys that consists of a single piece of super-integrated silicon (in this case, a BT878) mounted on a PCI board whose sole purpose is to provide some current paths between the pins on the chip and the pins on the PCI bus. Endless amusement, and no doubt a significant profit margin on a minimal outlay for the manufacturers. But I digress.
The card is intriguing for the reason that it has four video inputs on it. Most of the video software that I found (after searching for all of seventeen seconds) can switch between inputs, but isn't terribly good at handling multiple ones simultaneously. To compound the problem, there doesn't appear to be a cardtype that precisely matches in Linux' bttv driver, circa 2.2.x. At any rate, trial and error soon showed that cardtype 13 gives 3 working inputs, which, having three working cameras, is entirely adequate.
On with the show. Camserv is a reasonably cute streaming video server, that happily talks to bttv cards via Video4Linux. Half an hour after the camera and card arrived, one live webcam.
Camserv as shipped does a jpeg conversion on the grabbed frames, and spits them out as individual parts of a multipart/mixed page. This caused me no end of grief when I was trying to get around the first glaring problem, namely that Netscape isn't terribly clever about this Content-Type. It displays an image, then wipes it and does incremental rendering on the next one... and again clears it as soon as it finished. Some elementary calculus will show that, all other things being equal, you're going to spend a hell of a lot of time watching a mostly empty image.
So, the search for a solution begins. As usual, when faced with a user-interface problem, my mind turns to Java. I don't like doing UI. I also don't like Java, but I keep forgetting this because I do UI so rarely. Let me re-emphasize this - I hate Java. Just so you know.
Java. Yes. Specifically, Swing. Swing is funky. Ask anyone who did anything with AWT directly, and they'll tell you - Swing is cool. Swing also features classes that double-buffer by default. Isn't that clever? More importantly, isn't that useful? So, after bashing my head against the brick wall that is Java helpfulness for a few hours, this emerged. Don't bother trying to run it unless you have a 1.2 jdk (get one from Blackdown if you're on a linux box). It does very little. This is principally because the Java MIME handling classes are incredibly stupid. Mind-buggeringly, incredibly, dumb. In fact, unusable for handling an infinite stream of data. Which makes them unusable in general - ask anybody who uses a functional language.
Anyhow, that was that part of the problem, which sated my immediate needs for exhibitionstic ego gratification. This left the question of how exactly to use the other inputs on the card. Camserv is fun, but it's depressingly well structured. Things are rather neatly isolated in modules, which makes quick hacks rather unspeakable. This patch adds support for multiple inputs. It does so very badly. Incredibly badly. In fact, it doesn't work with a 320x240 resolution, although it does with 640x480. Usually - sometimes it blends images from various inputs together, and it all looks a bit odd. I don't know why - I'm so impressed with it working at all that I don't particularly care. The number of channels is hardwired (in several places), at 3. It won't work unless you're running on the default port (9192). But, it does work. I'm so impressed.
The latest incarnation, in the name of vanity, is here.