Raspberry Pi may very well work with quite a large number of USB webcams.
Today we look at how you can connect one of these cameras to our Raspberry Pi and configure Stream video that can be viewed through a local network or even the Internet. To do this we must have:
1. Raspberry Pi with installed OS Raspbian Whezzy and included into network with access to the Internet.
2. Actually USB webcam.
3. IP Address of our Raspberry Pi (can be found by using the ifconfig or router settings, for example)
We work with the Raspberry Pi in the command line (someone Terminal GUI or remotely by ssh). I Connecting to the Raspberry Pi with Windows, so using putty.
Upon entering, execute commands:
sudo apt-get update && sudo apt-get upgrade
In order that we can work with our webcam, we need to install software motion from the repository. This is done by using the:
sudo apt-get install motion
After installation of motion, necessary to carry out its settings. Open the file motion.conf with:
sudo nano /etc/motion/motion.conf
This file is quite large, but we are interested in only two lines:
DAEMON = OFF (change to ON)
Webcam_localhost = ON (change to OFF)
Save the changes (CTRL + O keys and Enter) and close the file (CTRL + X).
sudo nano /etc/default/motion
And in it:
start_motion_daemon = no (change to yes)
To start broadcasting video:
sudo service motion start
To stop the broadcast:
sudo service motion stop
To Stream broadcast automatically after shutdown or reboot Raspberry Pi:
sudo nano /etc/rc.local
under exit 0 ADD motion. File rc.local must contain something like below:
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
# Start motion
Now our Stream available on the local network at http://IP_adress_yours_raspberri_pi:8081.
:8081 – this port for broadcast video.
If you want to broadcast video over the internet, previously open this port for the internal IP address of Raspbery Pi on your router. And refer to video over the internet via http://IP_adress_yours_router:8081.