A stalker of IP cameras
What is this?
A high performance caching web proxy for serving MJPG streams to the masses.
Features
- Easy to use.
- Done with Go programming language.
- Compatible with http.HandlerFunc.
- No unnecessary network traffic to IP-camera.
- Serves MJPEG-stream as single jpeg-images.
- Works with every browser.
- Supports client-side caching.
IPCamera (1) <-> (1) Paparazzo.go (1) <-> (N) Users
IP cameras can't handle web traffic
IP cameras are slow devices that can't handle a regular amount of web traffic. So if you plan to go public with an IP camera you have the following options:
- The naive approach - Embed the camera service directly in your site, e.g. http://201.166.63.44/axis-cgi/jpg/image.cgi?resolution=CIF.
- Ye olde approach - Serve images as static files in your server. I've found that several sites use this approach through messy PHP background jobs that update this files at slow intervals, generating excessive (and unnecessary) disk accesses.
- Plug n' pray approach - Embed a flash or Java-based player, such as the Cambozola player. This requires plugins.
- MJPG proxy - Serve the MJPG stream directly if you are targeting only grade A browsers, (sorry IE).
- Paparazzo.go: A web service of dynamic images - Build a MJPG proxy server which parses the stream, updates images in memory, and delivers new images on demand. This approach is scalable, elegant, blazing fast and doesn't require disk access.
Get Paparazzo and start demo:
go get github.com/putsi/paparazzogo
cd $GOPATH/src/github.com/putsi/paparazzogo/demo
go run demo.go
open demo.html
Customization of settings:
mjpegHandler := &paparazzogo.Mjpegproxy{
// Max MJPEG-frame size (5Mb by default).
partbufsize: 625000,
// Sleep time between error and reconnecting to stream (one second by default).
waittime: time.Second * 1,
// How long to use one stream response before reconnecting (one hour by default).
responseduration: time.Hour,
// Caching enables/disables support for client-side caching
// of jpg-files. If enabled, saves bandwidth.
// If disabled, allows more than one frame per second.
// Enabled by default.
caching: true,
}
See more examples in demo-folder.
Use of this source code is governed by a MIT-style licence that can be found in the LICENCE-file.