This guide covers installation and setup of mjpg-streamer daemon for Raspberry Pi
This setup instruction relies on legacy Raspberry Pi camera stack. To enable legacy camera stack, follow the official Raspberry pi camera documentation
These installation steps follow the contents of included mjpg-streamer-install.sh script.
-
Update the system
sudo apt-get update sudo apt-get dist-upgrade -y
-
Install required dependencies
sudo apt-get install git cmake libjpeg-dev rubygems -y sudo gem install fpm
-
Clone the mjpg-streamer repository and change directory
git clone https://github.com/jacksonliam/mjpg-streamer.git cd mjpg-streamer/mjpg-streamer-experimental
-
Patch the setup files to configure mjpg-streamer to use Raspberry Pi camera
sed -i 's/\/opt\/vc\/include/\/usr\/include/g' plugins/input_raspicam/CMakeLists.txt sed -i '/ExecStart/c\ExecStart=/usr/bin/mjpg_streamer -i "input_raspicam.so -x 400 -y 300 -fps 30" -o "output_http.so -w /usr/share/mjpg_streamer/www -p 8000"' mjpg_streamer@.service sed -i '/install -D mjpg_streamer@.service/c\install -D mjpg_streamer@.service _pkg/etc/systemd/system/mjpg_streamer.service' makedeb.sh
-
build the mjpg-streamer project
make
-
create debian package
./makedeb.sh
-
install debian package
sudo dpkg -i mjpg-streamer_*.deb
-
enable & start daemon
sudo systemctl enable mjpg_streamer sudo systemctl start mjpg_streamer
Once the installation is successfully completed, you can access camera stream using your browser and navigating to URL http://%RASPBERRY-PI-HOST%:8000/?action=stream
By default, mjpg-streamer daemon is configured to produce camera feed with resolution of 400x300.
If you wish to change the output resolution or any other settings, you can do it via updating the etc/systemd/system/mjpg_streamer.service
file and changing the line starting with ExecStart
(see Documentation for parameter reference):
ExecStart=/usr/bin/mjpg_streamer -i "input_raspicam.so -x 400 -y 300 -fps 30" -o "output_http.so -w /usr/share/mjpg_streamer/www -p 8000"
Once you have updated the mjpg-streamer configuration, you should reload the configuration and restart the daemon:
sudo systemctl daemon-reload
sudo systemctl restart mjpg_streamer