Using motion to stream image from a webcam

by solusipse

Motion is probably best capturing software if you need to store and stream image from webcam connected to your Raspberry Pi. It don’t consume much ram and it is fully configurable. To install it on Raspbian simply run as root that command:

apt-get install motion

Ok, we’ve got it installed. Now it requires little configuration. Edit /etc/motion/motion.conf with your favourite text editor (I use nano). Everything there is clearly described so I’ll show here only the most important options and describe some of them.

Motion should automatically detect your video device, if you’ve got more than one connected to RPI change that value. To check all of them type:

ls /dev/video*

  • width and height

These values are based on parameters of your webcam.

  • framerate
  • minimum_frame_rate

If you want to stream image slower than 2 fps put there value that in equal to number of seconds you want to wait between every capture.

  • ffmpeg_cap_new
  • ffmpeg_video_codec

That is useful only for those who want to keep not only images but also video. I turned it off on my device. To use it you’ll need to have ffmpeg installed.

  • target_dir

Location where motion will store its files. I strongly recommend to change default setting because /tmp on Raspbian is mounted on smaller partition (about 60MB). /tmp is also automatically cleaned during every booting so if you can easily lost your photos.

  • webcam_port
  • webcam_localhost

Set it to off to be able to connect from another computer.

  • control_port
  • control_localhost

You can use that to manage motion from another computer without editing motion.conf.

Save file (if you’re using nano press ctrl + x). Now type in console:

motion

After that you should be able to connect to it with your browser. Just type its address and port, for example:

192.168.1.67:8081

Image

Image

Advertisements