Motion, a software motion detector, is a free software CCTV software application developed for Linux. (Wikipedia)
apt-get install motion
Give Motion user access to directory where it stores recordings. Add a user to this group.
chown motion:motion /var/lib/motion/ usermod -a -G motion <user>
Adjust configuration in /etc/motion/motion.conf if neeeded.
Enable the daemon in the file /etc/default/motion
Enable the service and show its status
systemctl enable motion service motion status
width 1280 height 720 framerate 15
Stream to network
Enable a stream at
Change recordings file name pattern
Errors and problems
The logs can be found in /var/log/motion/motion.log.
Device or resource busy
- Error message
[1:ml1] [ERR] [VID] [Apr 11 01:32:20] v4l2_select_input: Error selecting input 0 VIDIOC_S_INPUT: Device or resource busy [1:ml1] [ERR] [ALL] [Apr 11 01:32:20] mlp_capture: Video device fatal error - Closing video device
Disable the other services that is using the webcam and restart the motion service
systemctl stop webcamd.service /etc/init.d/motion restart