Deploying a Network Camera with Raspberry Pi

Every day a little progress

Friends who love playing with Raspberry Pi can communicate more!
Recently, I did a small test using Raspberry Pi + USB camera to achieve a network camera. Let’s operate step by step. If you have time, you can tinker with it.
Tools needed:
  • Raspberry Pi development board with USB Type-A interface
  • USB camera
  • mjpg-streamer software package
1. Prepare the software environment
Use WindTerm to connect to Raspberry Pi via SSH and install the following software:
# Update software list
sudo apt-get update
# Install JPEG support library
sudo apt-get install libjpeg62-turbo-dev
sudo apt-get install imagemagick
sudo apt-get install libv4l-dev
sudo apt-get install cmake
sudo apt-get install git
2. Download the mjpg-streamer software package
Software package GitHub address:
https://github.com/jacksonliam/mjpg-streamer.git
Create a new mjpg-streamer folder where you want it.
Here it is placed in ~/soft/mjpg-streamer
# Enter the newly created folder
cd ~/soft/mjpg-streamer
# Pull mjpg-streamer project files
git clone https://github.com/jacksonliam/mjpg-streamer.git

Deploying a Network Camera with Raspberry Pi

3. Compile and install the mjpg-streamer software package

# Enter mjpg-streamer/mjpg-streamer-experimental folder
# Execute the following commands one by one
sudo make
sudo make install

Deploying a Network Camera with Raspberry Pi

Deploying a Network Camera with Raspberry Pi

4. Recognize the USB camera

# Check video devices
ls -l /dev/video*
After inserting the USB camera, two new video devices video5 and video6 are added.

Deploying a Network Camera with Raspberry Pi

Generally, the first device has image and video functions. You can use the following commands to compare the two devices. Only the video capture device can output video, so here we choose the /dev/video5 device.

v4l2-ctl --all --device=/dev/video5
v4l2-ctl --all --device=/dev/video6

Deploying a Network Camera with Raspberry Pi

Deploying a Network Camera with Raspberry Pi

5. Configure the mjpg-streamer software

Enter the mjpt-streamer/mjpg-streamer-experimental folder:

Edit the startup command in start.sh

sudo vim start.sh

Deploying a Network Camera with Raspberry Pi

# Original startup command
./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -w ./www"
# Modified startup command
./mjpg_streamer -i "./input_uvc.so -f 10 -q 40 -r 1280x720 -d /dev/video5 -y" -o "./output_http.so -p 8080 -w ./www"
# Parameter explanation: -f frame rate, the smaller, the less bandwidth consumed, default 30
-q video clarity, the smaller the smoother, default 80, 0-100
-r resolution
-d device number
-y yuyv format support
-p http service port, here use port 8080
-w http file path, here in the www folder of the current file directory

After modifying the start.sh file, save it. It is recommended to comment out the previous line and add the new line.

Deploying a Network Camera with Raspberry Pi

6. Start the mjpg-streamer service and test the web display

Enter the mjpt-streamer/mjpg-streamer-experimental folder:

Run start.sh directly to start

sh start.sh
# Just ignore the error message

Deploying a Network Camera with Raspberry Pi

Open the web page and enter the Raspberry Pi board IP:8080 to see the mjpg-streamer web page. Click on the left side “stream” to see the video stream.

Deploying a Network Camera with Raspberry Pi

Extended explanation:
  • You can use tmux or screen and other multi-terminal software to create a terminal to run sh start.sh separately.
  • You can enter the mjpt-streamer/mjpg-streamer-experimental/www folder to modify the web display content
  • You can use internal network penetration software to set the Raspberry Pi’s port 8080 to be externally accessible, allowing remote viewing of the camera video stream, but be sure to set a password. Also, the video frame rate should not be too high to avoid lag.
For the tutorial on using internal network penetration software, you can refer to a previous document, direct link:
Using internal network penetration tools on Raspberry Pi

Thank you for watching, and friends are welcome to contact and communicate at any time!Deploying a Network Camera with Raspberry PiDeploying a Network Camera with Raspberry PiDeploying a Network Camera with Raspberry Pi

Deploying a Network Camera with Raspberry Pi

Welcome to follow!Deploying a Network Camera with Raspberry PiDeploying a Network Camera with Raspberry PiDeploying a Network Camera with Raspberry Pi

Or add my WeChat: gzswood

Leave a Comment

×