Sitemap / Advertise

Information



Tags



Share

How to stream video from a USB Webcam via Raspberry Pi

Advertisement:


read_later

Read Later

Keywords



Keywords



read_later

Read Later

Information

Tags

Share





Advertisement

Advertisement




Definition

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.

Code

📄 First of all, open the terminal and install the Motion module on Raspberry Pi.

sudo apt-get install motion

project-image
Figure - 152.1

📄 Then, connect your USB webcam to Raspberry Pi and make sure the camera is detected accurately with the command below:

lsusb

project-image
Figure - 152.2

📄 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

project-image
Figure - 152.3

📄 Then, change the settings as follows:

project-image
Figure - 152.4

📄 To activate the Motion module on start, enter the following command and set the start_motion_daemon to yes.

sudo nano /etc/default/motion

project-image
Figure - 152.5

After starting the Motion module for the first time, you should see the live stream on the 8081 port.

sudo service motion restart

sudo motion

project-image
Figure - 152.6

IP_Address:8081

project-image
Figure - 152.7

Result:

You can inspect my electronics project in which I used the same instructions to stream video from here.