#!/usr/bin/perl # veo-stream.cgi - M. Schoemaker # # Based on : webveo.pl - James A. Russo jr@halo3.net - August 14th, 2004. # # Script to allow a veo webcam to function as an MJPEG stream. Just put this under a CGI capable web server and point your cam # software to the URL. Tested under kmotion / motion. # # Note: There is no locking done, only one stream can work at a time! # # This script uses Veo.pm from Tobias Hoellrich. See http://www.kahunaburger.com/blog/archives/000157.html for more info. # use IO::Handle qw( ); # For flush use CGI; use Veo; my $USER = "admin"; my $PASSWORD = "password"; my $HOST = "x.x.x.x"; my $PORT = 1600; # Other options for STREAM. # Veo::VEO_STREAM_640X480; # Veo::VEO_STREAM_160X120; # Veo::VEO_STREAM_320X240 my $STREAM = Veo::VEO_STREAM_640X480; ## Nothing below this line needs editing.. my $CGI = new CGI; my $PICOK = 0; my $VEO = Veo->new(host => $HOST, port => $PORT); $VEO->login(user => $USER, password => $PASSWORD); print 'Content-type: multipart/x-mixed-replace;boundary="boundary"'."\n\n"; while ($PICOK == 0) { $VEO->selectStream($STREAM,1); $VEO->stream(\&image_cb); } $VEO->logout; exit(1); # Called for each frame sub image_cb { my($type,$frame,$data)=@_; { use bytes; my $size = length($data); print "--boundary\nContent-Type: image/jpeg\nContent-Length: $size\n\n" } print $data; STDOUT->flush(); return 0; }