Friday, November 24, 2006

Setting Up a Webcam in OS X

We began running a webcam many years ago to see how our pets were doing while we were away on vacation. Here are some fundamentals about setting up a webcam on Mac OS X.

CAMERAS


A webcam camera can be a number of possibilities (in no particular order):

Network Camera - This is a relatively recent type of product - wired cameras which plug into Ethernet patch cables which can be hundreds of feet long and wireless (802.11/WiFi) video cameras which (if you already have a wireless network) only require AC power, and can be placed anywhere they can hit your wireless network. Wired cameras area available for under $100 and wireless cameras start at under $200. If you've already got a wireless network, webcam software that *supports* the camera and you don't mind the expense, this is the easiest path to getting a camera. This page at the EvoCam webcam software site (more below) lists compatible network cameras.

USB Camera - Though inexpensive (as little as $30-40), these suffer from a number of drawbacks, chief among them a short (typically under 6 foot) USB cables, meaning that the camera is forced to be near the computer. USB extension cables up to 10 feet or so can get your camera as far as 16 feet away from your computer. You can buy _powered_ USB extensions which amplify the signal - but each 15 feet costs $35-40. These cameras won't perform well in low light, and will generally have a "normal" focal length lens - meaning that covering a wide area means having the camera far back from the subject.

FireWire Camera - Some webcam software (see below) supports DV cameras connected via FireWire, including iSights. Similar cable length issues to USB exist. I've seen 100-foot FireWire cables, but they cost $300 (FireWire specifications limit single cables to 4.5 meters - 15 feet).

FireWire Converter - This is an expensive solution, but if you already have one around, an analog-to-digital FireWire converter (such as the ADVC-50 from Canopus) allows you to connect an analog camera at the end of a very long conventional video cable. This is kind of overkill, but if it's something you already have or want...

USB Video Digitizer - For all the reasons I've already mentioned, I use this somewhat obscure solution - an "InterView Lite" USB video digitizer and USBVision for Mac OS X driver software. This is a hardware product from a now defunct company, sold now by EchoFX who wrote their own software to support it. Actually, I use their software to connect to an InterView Lite (purchased from someone else, I think) *and* an older Belkin USB video capture device (USBVision can drive many USB video devices, including USB cameras).

The two digitizers are plugged into one computer (our server, a 450MHz G4), and 50-foot video cables cross our house (through a wall, in one case) where they are connected to small low-light, high-resolution monochrome video cameras. These cameras have really come down in price in recent years - here's a typical example which advertises for $35 mail order (we've paid over twice as much for both of our non-illuminated cameras), and features built-in infrared illumination (which means you'll be able to see things relatively close to the camera without visible light).

If you have an old VHS camcorder or camera lying around and it has composite or S-video output, this can serve as a camera as well (we had an old full-sized video camera as our CatCam for almost a year), though it'll use far more power and be generally hard to discreetly position in your house.

SOFTWARE

I've used two pieces of webcam software, and reviewed perhaps a half-dozen over the years when seeking replacements. For many years I used Oculus, which had really nice features, but was never stable. On a ridiculous number of occasions I had to ask our cat-sitting friend to restart our server because Oculus had locked up.

Today I run EvoCam. I miss a few cool features of Oculus (automatic thumbnails, NOAA weather data overlays), but EvoCam also has a few tricks that Oculus didn't - especially live video, where it allows you to view live full-motion video (at very low frame rates - even over ADSL, it delivers 2fps at best). This is pretty exciting, to be able to see your webcam right now from anywhere in the world. This live video is viewable by any modern browser via Java technology, and doesn't require that the viewing computer have any special software installed. EvoCam has proven to be tremendously stable - running now for 10 months or so with no noticeable problems.

I've considered the kind of big project of having multiple X-10 (remote control over AC power lines) controlled cameras, switched remotely over the Internet via web page, feeding the live EvoCam stream. That means we could switch around our house to our cats' favorite six places and see who is where at any time. Geeky, fer sure.

As mentioned earlier, EvoCam supports all kinds of cameras (see their site), even supporting multiple cameras (we run two cameras all the time).

"Motion sensing" features in EvoCam and Oculus store images based on how much has changed in the frame. The webcams can also take periodic stills. But with motion sensing set up, we see only when our pets actually spent time in a particular location - which is exactly what we want to know.

WEB PAGE

There are a lot of variations possible here. I try to "tune" the motion-sensing so that in the 30 "recent" images on our CatCam page allow us to see something like most of a full day of activity at a glance. Oculus and EvoCam provide a way to retain recent images (actually renaming all the old images every time a new one is added). Super-simple pages included as examples with webcam software often only display one recent image.

EvoCam and Oculus also support archiving QuickTime movies of every image taken when motion is sensed.

COMPUTER

In order to host a webcam, you'll need a computer. I'm assuming you'll want that to be a Mac. This could be all kinds of things, but you want something that can run OS X. If you want a dedicated server, any old iMac would be just fine, though you can't turn off the CRT - a bit of power use you don't need. An old blue-and-white G3 or newer (I don't recommend trying to run OS X on a beige G3) would be a good web server. Of course, you can use any existing Mac you might have, as long as you're willing to let it run whenever you want the webcam to work.

There are actually computerless solutions to webcams - network cameras that upload to Internet ftp locations - but they don't allow you a lot of flexibility about how the site looks and works.

INTERNET SERVING

In order to view your webcam's images, you have basically two alternatives: 1) have the webcam upload images to a remote FTP space hosted by a private or public server (such as your ISP); or 2) serve the images directly from your home computer.

Sending images to a remote FTP server is less difficult than serving the files yourself. However, depending upon the amount of activity your webcam sees, this means your webcam may create a large amount of outbound traffic over your Internet connection. Not only does the image file need to be uploaded whenever the camera takes an image, but if you (like us) have a page with multiple previous webcam images, there will be a lot of traffic while the software renames all the previous files on the remote server. I did this years ago, but we've run our own server with our own domain name (see below) for years.

OS X has a built-in web server, the famous Unix-based Apache. So you don't need any other software to host web pages from an OS X Mac.

DOMAIN NAME

We've used two free services to maintain domain names with a dynamic IP ("dynamic IP" means that your broadband ISP might reassign your home's Internet address at any time - allowing them to have a smaller number of IP addresses than users). For years I've used a free service from DynDNS. This service uses a piece of software running on your Mac which informs the DynDNS servers what your current IP is. The software checks every few minutes and updates the DynDNS servers - this Domain Name Server (DNS) begins to propagate throughout the Internet. We've almost never had to wait to connect to our server because our IP had not been updated at the time we were making the connection attempt. And the process is transparent - ours has been running for several years without maintenance.

There's a bit more complication here (like there hasn't been enough already) - if you don't already have a "router" between your home LAN and your broadband connection (DSL/cable "modem"), you'll definitely want one to act as a firewall (you shouldn't be connected to the Internet without the protections of a router anyway). Then you'll need to set up the router to "forward" HTTP requests (by web browsers) to your home's domain name/IP to the right computer on your LAN.

A substantial collateral benefit of having a domain name is being able to communicate with your home computer(s) from anywhere in the world. Not only can you make HTTP connections with one computer's web server, but you can make AFP (Apple File-sharing Protocol), FTP, SSH, and a host of other kinds of connections to any of the computers on your home LAN (though each service can only be associated with *one* of the computers, you can have all the services on one, or a different service on each computer). So you can access files on a Mac at home from anywhere in the world. With Apple Remote Desktop, Netopia Timbuktu, or even *free* VNC software you can even remotely control your Mac from anywhere in the world.

EPILOGUE

With a small amount of effort, an old Mac can become a 24/7 webcam server so you can easily see the activities your family, pets, home or whatever is important to you.

No comments: