Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save asad-albadi/ca1577c3f368b45a73b687324a72b1a3 to your computer and use it in GitHub Desktop.
Save asad-albadi/ca1577c3f368b45a73b687324a72b1a3 to your computer and use it in GitHub Desktop.

MJPG Streamer Installation and Setup Guide

Step 1: Install Required Dependencies

Update your package lists:

sudo apt update

Install necessary dependencies:

sudo apt install git cmake libjpeg-dev imagemagick libv4l-dev

Step 2: Clone MJPG Streamer Repository

Navigate to your desired directory:

cd ~/Projects

Clone the MJPG Streamer repository:

git clone https://github.com/jacksonliam/mjpg-streamer.git

Step 3: Build and Install MJPG Streamer

Navigate into the cloned repository:

cd mjpg-streamer/mjpg-streamer-experimental

Create a build directory and navigate into it:

mkdir build && cd build

Run CMake to generate build files:

cmake ..

Build the project:

make

Install MJPG Streamer:

sudo make install

Step 4: Configure MJPG Streamer

Set up the webcam input. Replace /dev/video0 with the correct device path for your webcam:

export LD_LIBRARY_PATH=/usr/local/lib/mjpg-streamer:$LD_LIBRARY_PATH

Step 5: Test MJPG Streamer

Start MJPG Streamer with the appropriate input and output plugins:

mjpg_streamer -i "input_uvc.so -r 1280x720" -o "output_http.so -w /usr/local/share/mjpg-streamer/www/"

Open a web browser and enter the URL:

http://localhost:8080

You should see the live video stream from your webcam.

Step 6: Create a systemd Service

Create a systemd service unit file:

sudo nano /etc/systemd/system/mjpg_streamer.service

Add the following content to the file:

[Unit]
Description=MJPG Streamer Service
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/mjpg_streamer -i "input_uvc.so -r 1280x720" -o "output_http.so -w /usr/local/share/mjpg-streamer/www/"
Restart=always

[Install]
WantedBy=multi-user.target

Save and close the file.

Step 7: Enable and Start the Service

Reload systemd daemon:

sudo systemctl daemon-reload

Start the service:

sudo systemctl start mjpg_streamer

Enable the service to start automatically on boot:

sudo systemctl enable mjpg_streamer

Step 8: Verify Service Status

Check the status of the service:

sudo systemctl status mjpg_streamer

You should see output indicating that the service is active and running.

That's it! You've now installed MJPG Streamer, configured it to stream video from your webcam, and set it up as a service on your Linux system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment