Motion
Introduction
Motion is a program that monitors the video signal from cameras. It is able to detect if a significant part of the picture has changed; in other words, it can detect motion.
https://motion-project.github.io/
http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome
Installation
Gentoo Linux
Even though 'motion' is in the Portage tree, you will need to download and use the svn ebuild, because the official ebuilds do not work with the latest kernels, specifically the 'v4l' drivers.
https://bugs.gentoo.org/show_bug.cgi?id=376225
su - root mkdir -p /usr/local/portage/media-video/motion/files cd /usr/local/portage/media-video/motion/ wget https://376225.bugs.gentoo.org/attachment.cgi?id=288617 -O motion-9999.ebuild cd /usr/local/portage/media-video/motion/files/ wget http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/media-video/motion/files/motion.initd-r2 wget http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/media-video/motion/files/motion.confd echo "media-video/motion **" >>/etc/portage/package.keywords emerge motion
Ubuntu Linux
https://github.com/Motion-Project/motion/releases
sudo dpkg -i bionic_motion_4.3.1-1_amd64.deb sudo apt-get -f install
Configuration
https://motion-project.github.io/motion_config.html
Basic
nano /etc/motion.conf target_dir /tmp/cam1 (or /path/to/saved/files)
RTSP Stream from Wi-fi webcam camera
https://motion-project.github.io/motion_config.html#netcam_url
You can use Motion to capture movement in an RTSP stream from a cheap wi-fi camera like this one...
http://wiki.indie-it.com/wiki/Security#V380_Shenzhen_Trolink_Technology
Create your configuration folder and copy the master settings file...
mkdir /tmp/cam1 mkdir ~/.motion sudo cp /etc/motion/motion.conf ~/.motion/ nano ~/.motion/motion.conf
Comment out the videodevice setting and add the stream settings...
target_dir /tmp/cam1 # videodevice /dev/video0 netcam_url rtsp://192.168.0.165:554/mpeg4 netcam_userpass admin:password
Run motion pointing to the configuration file...
motion -c ~/.motion/motion.conf
Check the logs...
[1:ml1] [NTC] [EVT] event_newfile: File of type 8 saved to: /tmp//0-01-20200720144621.mkv [1:ml1] [NTC] [ALL] motion_detected: Motion detected - starting event 1 [1:ml1] [NTC] [ALL] mlp_actions: End of event 1
View the live feed..
firefox http://localhost:8081/
Watch the videos...
mpv /tmp/cam1/0-01-20200720144621.mkv
You can send an email or a push notification on an event...
https://github.com/aaronfagan/pushover-cli/blob/master/pushover
on_event_start /usr/bin/pushover-cli --quiet --title "Webcam Motion" --message "...started." on_event_end /usr/bin/pushover-cli --quiet --title "Webcam Motion" --message "...ended." on_movie_end /usr/bin/pushover-cli --quiet --title "Webcam Motion" --message "...recorded."
Running
/etc/init.d/motion start
Testing
tail /var/log/syslog motion_startup: Motion trunkREV544 Started become_daemon: Motion going to daemon mode main: Thread 1 is from /etc/motion.conf main: Thread 1 is device: /dev/video0 input -1 motion_init: Started motion-stream server in port 8081
Fire up your web browser to address - http://127.0.0.1:8081
motion_detected: Motion detected - starting event 1 create_path: creating directory /tmp/cam1 event_newfile: File of type 1 saved to: /tmp/cam1/01-20111102170811-00.jpg