In this tutorial, I will show you how to stream video from a USB Webcam and watch it live on a web server hosted by Raspberry Pi.
We need to create a Webcam server to be able to live stream with Raspberry Pi. Luckily, creating a Webcam server is easy with the help of the Motion module in Python.
You can get more information about the Motion module here.
📄 First of all, open the terminal and install the Motion module on Raspberry Pi.
sudo apt-get install motion
📄 Then, connect your USB webcam to Raspberry Pi and make sure the camera is detected accurately with the command below:
📄 Now, you need to change some settings in the configuration file to start live streaming. Enter the command below to view the configuration file.
sudo nano /etc/motion/motion.conf
📄 Then, change the settings as follows:
📄 To activate the Motion module on start, enter the following command and set the start_motion_daemon to yes.
sudo nano /etc/default/motion
After starting the Motion module for the first time, you should see the live stream on the 8081 port.
sudo service motion restart
You can inspect my electronics project in which I used the same instructions to stream video from here.