Roll the Camera
What you will need for this bite-sized example
- a d:b system with Video for Linux capable video source
A quick look at the Video menu in d:b shows lots of interesting options. To enjoy the power of the live video options, you'll need to get your video gear working. Here is a path through the tools to get you started.
Video for Linux
Video for Linux (v4l) is the standard mechanism for connecting video hardware to a Linux system. There is constant activity in this area, so the answer to the seemingly simple question, "is my webcam supported?" might take a little more research than you might think it should. One good choice for use with d:b is a PCI capture card supported by the bttv module, such as a Conexant Bt878 based card, but this isn't required. Most supported PCI cards will be recognized and configured at boot time.
USB devices will require some extra steps. To find out specifics of a USB connected device, you can use this command in an xterm:
The output is terse, but you should be able to see your camera in the output. Here is an example of the output we are most interested in:
... P: Vendor=046d ProdID=0870 Rev= 1.00 S: Product=Camera ...
Using the Vendor and ProdID specifics for the camera, you can visit the working devices list and do a search to find out which module you need to load to enable it. To use the "Quick Search!" enter the Vendor or the ProdID, not both. Note that some Vendor/ProdID combinations have multiple entries, as they sometimes are used for similar, but not identical devices. Be sure to check them all, especially if you have troubles. To try a module, issue a modprobe command in an xterm window. For example, the camera shown above (a USB Quickcam) can be enabled with this command:
You can see a list of most of the available modules by looking in these directories:
Some devices may have limitations (usually 'mmap' support) which will prevent them from working with some programs. Also, don't forget that help is available through the dynebolic mailing list and on the Wiki.
Once you have the correct module(s) loaded you should be able to use
ls /dev/video* and see video0. If you have multiple cards or cameras, you may have multiple entries, i.e. video1, video2.
The next step is to fire up xawtv from the Video -> Play menu. This serves two purposes. First it will prove the video device is working. Second, it will give you a chance to tweak the settings and familiarize yourself with the control switches you will need to know to use some of the other tools. Bring up the Options menu by right clicking in the display window. Use the TV norm option to adjust to your gears standard, such as PAL or NTSC. The Video source can select between various inputs, such as Television, Composite or S-Video. With some setups, the video window might not fully correct itself as the options are selected. If you think the options are correct, and the display is still corrupted, try and save the options, exit and start xawtv again. The save option is on the Channel Editor menu.
If you have more than one v4l device, you might need to launch from the command line to specify an alternate device. For example:
xawtv -device /dev/video1
Palantir is a sophisticated video streaming solution. It only takes a moment, once you have v4l working, to be up and running. First, from an xterm, do:
nedit /etc/palantir.conf. The settings you determined with xawtv need to be applied. Look for the VideoDevice (i.e. /dev/video0) VideoNorm (i.e. PAL or NTSC) and Channel. Channel can be a bit confusing, as it doesn't refer to a TV channel, but to the video source channel. The typical possibilities are 0 for a TV tuner, 1 for Composite input, and 2 for S-Video input. There are lots of other options, but these are all we need to change for this example. Save any changes. Now do an
nedit /var/boa/htdocs/index.html. This is the front page for the Boa webserver built in to d:b. By default it is configured to show the Palantir stream on localhost. To stream to another machine on the net, you need to at least change the host name portion of the img tag to the local machine's real name or IP address. Leave the ":3000" portion alone, unless you change palantir.conf to match. For this example, the default should be OK. Now issue the following command:
palantir -C /etc/palantir.conf
Barring any errors, your video source is streaming! Notice that the video streaming is accomplished as a progressive jpeg, so most web browsers can view it with no extra plugins or controls. Launch the Firefox browser and enter http://localhost/ as the URL to watch the stream.
If Palantir is too bandwidth hungry for your tastes, or you just long for some Ascii Art goodness, try HasciiCam. Just running
hasciicam will bring up a live window. To run as a low tech stream, start it like this:
hasciicam --mode html -o /var/boa/htdocs/hasciicam.html -r 1
Then, point a web browser to http://localhost/hasciicam.html and enjoy.
There are lots of other tools and toys to try out, but that is enough for this bite. FreeJ deserves an article (or two or three) all to itself, and there is still more. Hopefully, this start will help you in your own explorations. Enjoy!
Now you've got power. Go create something wonderful!