Update your package lists:
sudo apt updateInstall necessary dependencies:
sudo apt install git cmake libjpeg-dev imagemagick libv4l-devNavigate to your desired directory:
cd ~/ProjectsClone the MJPG Streamer repository:
git clone https://github.com/jacksonliam/mjpg-streamer.gitNavigate into the cloned repository:
cd mjpg-streamer/mjpg-streamer-experimentalCreate a build directory and navigate into it:
mkdir build && cd buildRun CMake to generate build files:
cmake ..Build the project:
makeInstall MJPG Streamer:
sudo make installSet 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_PATHStart 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.serviceAdd 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-reloadStart the service:
sudo systemctl start mjpg_streamerEnable the service to start automatically on boot:
sudo systemctl enable mjpg_streamerCheck the status of the service:
sudo systemctl status mjpg_streamerYou 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.
Awesome guide - thanks for sharing!