Summary
This is a basic setup of Rasberry PI. It allows out of the box streaming of the video feed to a web browser. It is based on the motion library. Pre-requisites: have a basic RasPi setup (covered elsewhere - you can try our headless setup guide) and make sure you can SSH into it. Also have reasonable fresh updates done.
If you don't feel you want to setup everything manually, try MotionEye or MotionEye OS we cover here.
Setup streaming
From this point on, all the setup is done via SSH. Log into your RPi via PuTTy or favourite client.
- Plug in your webcam. If you wish to use the RasPi camera module, you also need to run the below on every boot (otherwise ignore). In such a case, it is a good idea to put this command in /etc/rc.local to make it run on every boot automatically. Don't forget to also enable the RasPi camera module in raspi-config if this is your device.
sudo modprobe bcm2835-v4l2
- Next we need to install the motion service. This is a package that contains everything you need to stream your cam over the internet and view it from any browser.
sudo apt install motion
- Once the installation has completed we need to start the service. If your web cam has a light on it, you should see it light up.
sudo service motion start
- Now lets configure the motion software.
sudo nano /etc/motion/motion.conf
In here there are a few basic changes that you need to perform:
Daemon = OFF to ON
webcam_localhost = ON to OFF
webcam_port = desired port number or 8088
control_port = desired port number or 8089
To ensure that the motion service will actually start as a daemon we need to change another configuration setting, so enter the following:
sudo nano /etc/default/motion
- Then change the value start_motion_daemon=no to yes and restart the service
sudo service motion restart
- You can now open up a browser from another computer on the same network and view the feed:
http://<your Raspi Address>:8088
You can remotely control the web cam settings by going to
http://<your Raspi Address>:8089
- (optional) You will need to enable port forwarding on your home broadband router to the Raspberry PI on port 8088, that will mean you can access the web cam from anywhere in the world. You can also sign up with a service like www.dyndns.org
Links
Our video streaming articles: