Update your package lists:
sudo apt update
Install necessary dependencies:
sudo apt install git cmake libjpeg-dev imagemagick libv4l-dev
Navigate to your desired directory:
cd ~/Projects
Clone the MJPG Streamer repository:
git clone https://github.com/jacksonliam/mjpg-streamer.git
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
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
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.
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.
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
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.