Let’s say you want to monitor a room and have a running linux machine(in our case ubuntu) with a webcam attached.
Problems that could appear:
- Recording continuously for a long period can result in extremely large video files, especially when uncompressed, and a pretty high CPU usage.
- In the case above you would have to compress and “logrotate” your video streams periodically
- Maybe you do not want to record anything if nothing happens
Our solution:
$ sudo apt-get install webcam
use the following configuration file (webcam.conf)
[grab]
device = /dev/video0
text = "my office %Y-%m-%d %H:%M:%S"
infofile = filename
fg_red = 255
fg_green = 255
fg_blue = 255
width = 320
height = 240
delay = 5
wait = 0
rotate = 0
top = 0
left = 0
bottom = -1
right = -1
quality = 80
trigger = 175
once = 0
archive = take %Y-%m-%d %H:%M:%S
[ftp]
dir = /path/to/images/temp
file = webcam_l.jpeg
tmp = uploading_l.jpeg
passive = 0
debug = 0
auto = 0
local = 1
ssh = 0
And now run
$ webcam webcam.conf &
Now you will get a JPG image from your webcam (quality = 80) every 5 seconds (delay = 5) but only if something changed. The “something changed”-condition is given by the setting trigger = 175.