Sunday, April 12, 2015

Raspbian - Stream - Webcam+Motion Or Pi Camera+MMAL Motion

Raspbian v2015-02-16
Motion
MMAL Motion




Status:

  • 20150412 - It's working.
Notes:
  • Pi camera works at 10~14fps.
  • Webcam works at 30?fps.
  • Using 50% for jpeg quality and size: 256x144px (Pi Camera).
  • With this configuration, CPU use is about  33%~96% for motion with webcam, and about 19%~53% for mmal-motion and Pi Camera.
  • It only works with firefox (Windows and Android? version).

Installing Motion for Webcam:

  • Install Motion:
  • sudo mkdir /home/webcam
  • sudo chmod 777 /home/webcam
  • cd /home/webcam
  • sudo apt-get install motion
  • Configure Motion:
  • sudo nano /etc/motion/motion.conf
  • Changing config file:
  • daemon on
  • framerate 15
  • threshold 500
  • gap 10
  • max_mpeg_time 30
  • output_normal center
  • ffmpeg_video_codec msmpeg4
  • target_dir /home/webcam
  • webcam_motion on
  • webcam_maxrate 30
  • webcam_port 8085
  • webcam_localhost off
  • Configure autostart of Motion:
  • sudo nano /etc/default/motion
  • Start Motion:
  • sudo motion
  • Troubleshooting:
  • "cannot create process id file ..."
  • mkdir /var/run/motion
  • chmod a+rwxt /var/run/motion

Testing Motion for Webcam:

  • http://<Raspberry-pi_IP-address>:8085

Installing MMAL Motion for Pi Camera:

  • Install Motion, dependencies and MMAL Motion:
  • sudo apt-get install motion libjpeg62
  • cd ~/
  • mkdir mmal
  • cd mmal
  • wget https://www.dropbox.com/s/jw5r1wss32tdibb/motion-mmal-opt.tar.gz
  • tar -zxvf motion-mmal-opt.tar.gz
  • cd ./motion-mmal
  • Configure Motion:
  • nano motion-mmalcam.conf
  • Changing config file:
  • daemon on
  • gap 10
  • mmalcam_secondary_buffer_upscale 2
  • stream_secondary off  (ON to use with mmalcam_secondary_buffer_upscale)
  • output_secondary_pictures off  (ON to use with mmalcam_secondary_buffer_upscale)
  • ffmpeg_output_secondary_movies off (ON to use with mmalcam_secondary_buffer_upscale)
  • Start MMAL Motion:
  • cd ~/mmal/motion-mmal/
  • ./motion-mmal -n -c motion-mmalcam.conf
Testing  MMAL Motion for Pi Camera:
  • http://<Raspberry-pi_IP-address>:8081


References:

Other options for Streaming:
If you like this content, feel free to