Hawkeye

Short version: I wanted to build a video baby monitor using a Raspberry Pi and some cheap Logitech web cams. The software that existed for this purpose was either not very easy to use or did not have all the features I wanted. Because of that I created hawkeye.

Hawkeye baby monitor in action

You can install hawkeye on Debian, Ubuntu, or Raspbian like so:

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 2272781B
echo "deb http://debs.ridgebit.net/qoSBonHMiqBNAAe5TNm3M0PuZaV91peH/ custom main" | sudo tee /etc/apt/sources.list.d/ridgebit.list
sudo apt-get update
sudo apt-get install hawkeye

Then simply point your browser to http://localhost:8000/ and you will see the video stream from your first USB webcam.

Here's a short list of supported features:

  • Built-in web server
  • Multiple camera support
  • SSL support for secure web streaming over HTTPS
  • HTTP Basic Authentication (combined with HTTPS lets you stream securely over the Internet)
  • IPv4 and IPv6 support
  • Low overhead and memory footprint. You can run hawkeye on a Raspberry Pi supporting a decent number of users.
  • Included HTML5 video player. You can include the video stream in your own web pages, but you can start using the built-in player with no modifications. It can also be run as a web app on iOS (and possibly Android).

One of my main goals when building Hawkeye was to make sure it can run on a Raspberry Pi. This is a challenge because the RPi does not have a whole lot of RAM and its processor is not the most performant. While Hawkeye is not a shining beacon of efficency, it uses an event loop for serving the video streams and static files to the browser. It also uses simple yet robust frame rate adjustment and time keeping mechanisms to ensure that the video stream does not lag more than a few frames behind real time. In my tests Hawkeye can sustain a 15 fps stream to several clients without breaking a sweat.

There is one caveat (there always is): the Raspberry Pi lacks hardware crypto instructions set. Because of this, if you use SSL/HTTPS the CPU use will rise and the number of concurrent users it can support will drop to around 10 or so. This should not deter you from using HTTPS when appropriate (when streaming video over the Internet).

Here are some pictures of the baby monitor hardware I have set up (second camera is on the way):

Raspberry Pi baby monitor

Webcam for the baby monitor

Why

The reason for why I decided to create Hawkeye is that the alternatives didn't quite meet my requirements: a low overhead web server capable of streaming video from multiple cheap webcams securely over the Internet. Here are the alternatives I looked at:

MJPG-streamer comes highly recommended on the Raspberry Pi forums. It actually includes almost all the features I was looking for, aside HTTPS support. The drawbacks to using MJPG-stream is that it is complex to get running (get source code from subversion, compile, etc.) It also uses a threads to support concurrent users which creates more overhead than necessary. To be fair to MJPG-streamer it includes many more features than Hawkeye: it can use HTTP as an input, stream to a file on disk, etc. I can see some situations where you might want to use it over Hawkeye.

Also, I used some of the video capture code from MJPG-streamer for Hawkeye.

ffserver is a part of the ffmpeg suite. It is able to stream over HTTP and does support multiple video inputs. The biggest issue I found with it is the complexity of configuring it. It is able to transcode video on the fly which isn't the best thing to do on a low power device like the Raspberry Pi. In the end I found the configuration for it too complex as I wanted something that was more plug and play.

motion is a very popular motion detection server. I did not investigate it beyond the initial precursory look as it seems to mostly be aimed at the security use case. What I would like is to be able to look at the video stream at any time and see a reasonably real-time video stream (more than 10 fps).

I also just wanted to stretch my C muscles as it's been a while since I used it.

License and Contributing

Most of Hawkeye is licensed under GPL-3, except as noted elsewhere in the source code.

If you want to contribute, send a pull request on GitHub. If you don't want to use GitHub, simply send me a patch via email.

You can report issues using GitHub issues.