Installing Motion with a USB Camera
We will be using a package called motion if you want to learn more about it you can check out their website: Motion.
- We will be using the terminal so open up terminal on the Pi or via SSH.
- Let’s check for any updates for Raspbian and its packages.
sudo apt-get update
sudo apt-get upgrade
- First we will need to download and install motion, to do this enter the following command:
sudo apt-get install motion
- Now we need to make some edits to the configuration file (motion.conf)
sudo nano /etc/motion/motion.conf
- Find the following lines and change them to the following.
- daemon on
- webcam_localhost off
- Optional (Don’t include the text in brackets)
- webcam_maxrate 100 (This will allow for real-time streaming but requires more bandwidth)
- framerate 100 (This will allow for 100 frames to be captured per second allowing for smooth video)
- width 640 (This changes the width of the image displayed)
- height 480 (This changes the height of the image displayed)
- Now we need to setup up the daemon, first we need to edit the motion file.
sudo nano /etc/default/motion
- Find the following line and change it to the following:
start_motion_daemon=yes
- Now make sure the camera is connected and run the following line
sudo service motion start
- If you need to stop the service simply run the following command
sudo service motion stop
- Now to test it out! We can check out the Raspberry Pi Web Cam Stream at the ip address of our Pi so in your browser go to the following address:
192.168.1.103:8081
There we have it a fully working Raspberry Pi Webcam server that you can place where ever you would like (Given it is within Wifi range) and be able to view via the web browser. If you want allow external access to it check out my instructions towards the bottom of this tutorial.
I found this information here.