Zoneminder est une solution open source efficace de vidéosurveillance,
acceptant des sources vidéo analogiques (connectées via une carte
d'acquisition), des webcams ou encore des caméras réseau. Il est capable
d'envoyer les images capturées sur un serveur déporté via
FTP ou
SMTP
(mail) mais dispose également d'un serveur web dédié permettant de
consulter les images et vidéos capturées ainsi que de contrôler le
système de vidéo-surveillance…
/janhellevik.com
ZoneMinder Client firefox add-on
Autres:
MJPG-streamer
<
source>
The webcam I have available for testing is a
Microsoft LifeCam 720p 30fps
, the important thing to note is that it outputs as mjpg which means
the raspberrt pi will not need to do any CPU intensive encoding.
|
phillips321@raspberrypi /etc/init.d $ lsusb
Bus 001 Device 004: ID 045e:075d Microsoft Corp. LifeCam Cinema
|
The first thing to do is install some required dependencies:
|
sudo apt-get install subversion libv4l-dev libjpeg8-dev imagemagick fswebcam
|
Then check that your webcam supports mjpg:
|
phillips321@raspberrypi ~ $ sudo fswebcam --verbose
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
<SNIP>
src_v4l2_set_pix_format,541: Device offers the following V4L2 pixel formats:
src_v4l2_set_pix_format,554: 0: [0x56595559] 'YUYV' (YUV 4:2:2 (YUYV))
src_v4l2_set_pix_format,554: 1: [0x47504A4D] 'MJPG' (MJPEG)
Using palette MJPEG
<SNIP>
|
If it does that’s great, otherwise you’ll need to do a small bit of messing around to ensure the stream gets converted.
Now we need to install mjpg_streamer, to do this download the source via svn and then compile it:
|
svn co https://mjpg-streamer.svn.sourceforge.net/svnroot/mjpg-streamer
mjpg-streamer
cd mjpg-streamer/mjpg-streamer
make USE_LIBV4L2=true clean all
sudo make DESTDIR=/usr install
cd ../.. ; rm -rf mjpg-streamer
|
Now test that you can stream your webcam using:
|
mjpg_streamer -i "/usr/lib/input_uvc.so -d /dev/video0" -o
"/usr/lib/output_http.so -p 80 -w /var/www/mjpg_streamer -n"
|
and access the stream using
http://IP/?action=stream.
Once you have it working you can adjust the webcam resolution and fps using:
|
[-r
| --resolution ]...: the resolution of the video device, can be one of
the following strings: QSIF QCIF CGA QVGA CIF VGA SVGA XGA SXGA or a
custom value like the following example: 640x480
[-f | --fps ]..........: frames per second
|
Now once you have your command to start the stream you need to set it
to run at boot. To do this we’ll need to create an init script. Copy
the following to a file called /etc/init.d/mjpg_streamer.sh and make is
executable. Here’s mine which you can copy/paste and then change for
your own use:
|
#!/bin/sh
# /etc/init.d/mjpg_streamer.sh
# v0.2 phillips321.co.uk
### BEGIN INIT INFO
# Provides: mjpg_streamer.sh
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: mjpg_streamer for webcam
# Description: Streams /dev/video0 to http://IP/?action=stream
### END INIT INFO
f_message(){
echo "[+] $1"
}
# Carry out specific functions when asked to by the system
case "$1" in
start)
f_message "Starting mjpg_streamer"
mjpg_streamer -b -i "/usr/lib/input_uvc.so -d /dev/video0" -o "/usr/lib/output_http.so -p 80 -w /var/www/mjpg_streamer -n"
sleep 2
f_message "mjpg_streamer started"
;;
stop)
f_message "Stopping mjpg_streamer..."
killall mjpg_streamer
f_message "mjpg_streamer stopped"
;;
restart)
f_message "Restarting daemon: mjpg_streamer"
killall mjpg_streamer
mjpg_streamer -b -i "/usr/lib/input_uvc.so -d /dev/video0" -o "/usr/lib/output_http.so -p 80 -w /var/www/mjpg_streamer -n"
sleep 2
f_message "Restarted daemon: mjpg_streamer"
;;
status)
pid=`ps -A | grep mjpg_streamer | grep -v "grep" | grep -v mjpg_streamer. | awk '{print $1}' | head -n 1`
if [ -n "$pid" ];
then
f_message "mjpg_streamer is running with pid ${pid}"
f_message "mjpg_streamer was started with the following command line"
cat /proc/${pid}/cmdline ; echo ""
else
f_message "Could not find mjpg_streamer running"
fi
;;
*)
f_message "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
exit 0
|
Once that is done you’ll need to instruct the command to be run at boot, you can do that using the following:
|
sudo update-rc.d mjpg_streamer.sh defaults
|