Motion
De enunpimpam
Sumario
Instalar
sudo apt-get install motion
apt-get install -y libjpeg62 libjpeg62-dev libavformat53 libavformat-dev libavcodec53 libavcodec-dev libavutil51 libavutil-dev libc6-dev zlib1g-dev libmysqlclient18 libmysqlclient-dev libpq5 libpq-dev
Activamos el daemon para que se inicie con el sistema
nano /etc/default/motion
Cambiamos no por yes
start_motion_daemon=yes
Motion versión MMAL
La versión oficial de los repositorios por defecto no funciona, pero un tal Dozencrows ha realizado un binario que funciona perfecto en la raspberry.
Lo unico que la instalación es diferente, primero es recomendable instalar la versión oficial, ya que esta instala todas las dependecias.
Descargamos la versión modificada
wget https://www.dropbox.com/s/xdfcxm5hu71s97d/motion-mmal.tar.gz
wget http://captain-slow.dk/motion/motion-mmal.tar.gz
tar zxvf motion-mmal.tar.gz sudo mv motion /usr/bin/motion sudo mv motion-mmalcam.conf /etc/motion.conf
Asignar permisos
sudo chmod 664 /etc/motion.conf sudo chmod 755 /usr/bin/motion sudo touch /tmp/motion.log sudo chmod 775 /tmp/motion.log sudo nano /etc/motion.conf
daemon on logfile /tmp/motion.log width 1280 height 720 framerate 2 max_mpeg_time 600 ffmpeg_video_codec mpeg4 stream_localhost off stream_auth_method 2 stream_authentication TUUSUARIO:TUCONTRASEÑA
Para que se inicie automaticamente Motion tenemos que añadir una linea en el archivo de inicio del demon
sudo nano /etc/init.d/motion
Añadir
Sleep 30
Estado
monit status
Configurar Motion
nano /etc/motion/motion.conf
############################################################ # Daemon ############################################################ # Start in daemon (background) mode and release terminal (default: off) daemon on
############################################################ # Basic Setup Mode ############################################################ # Start in Setup-Mode, daemon disabled. (default: off) setup_mode on
############################################################ # Live Webcam Server ############################################################ # Quality of the jpeg (in percent) images produced (default: 50) webcam_quality 100 # Restrict webcam connections to localhost only (default: on) webcam_localhost off
############################################################ # HTTP Based Control ############################################################ # Restrict control connections to localhost only (default: on) control_localhost off # Output for http server, select off to choose raw text plain (default: on) control_html_output off
# Image width (pixels). Valid range: Camera dependent, default: 352 width 640 # Image height (pixels). Valid range: Camera dependent, default: 288 height 480
# Target base directory for pictures and films # Recommended to use absolute path. (Default: current working directory) target_dir /media/webcam
Comprobar
# Minimum time in seconds between capturing picture frames from the camera. # Default: 0 = disabled - the capture rate is given by the camera framerate. # This option is used when you want to capture images at a rate lower than 2 per second. minimum_frame_time 5
# Specifies the number of pre-captured (buffered) pictures from before motion # was detected that will be output at motion detection. # Recommended range: 0 to 5 (default: 0) # Do not use large values! Large values will cause Motion to skip video frames and # cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead. pre_capture 2 # Number of frames to capture after motion is no longer detected (default: 0) post_capture 2
# Output pictures with only the pixels moving object (ghost images) (default: off) output_motion on # The quality (in percent) to be used by the jpeg compression (default: 75) quality 100
# Use ffmpeg to encode a timelapse movie # Default value 0 = off - else save frame every Nth second ffmpeg_timelapse 30
Comprobar el funcionamiento
./motion -n -c motion-mmalcam.conf
tail -f /var/log/syslog