mjpg-streamer is a command line application that copies JPEG frames from one or more input plugins to multiple output plugins. It can be used to stream JPEG files over an IP-based network from a webcam to various types of viewers such as Chrome, Firefox, Cambozola, VLC, mplayer, and other software capable of receiving MJPG streams.
It was originally written for embedded devices with very limited resources in terms of RAM and CPU. Its predecessor uvc_streamer was created because Linux-UVC compatible cameras directly produce JPEG data, allowing fast and performant M-JPEG streams even from an embedded device running OpenWRT. The input module input_uvc.so captures such JPG frames from a connected webcam. mjpg-streamer now supports a variety of different input devices.
[Edit 22 April, 2017]: Dev dependencies were not installing for some people. Updated instructions to fix that problem.
Open terminal window.
Update local package lists.
Always do this before installing packages.
sudo apt-get update
sudo apt-get install libjpeg8-dev imagemagick libv4l-dev
Make a symbolic link of
videodev.h for backward-compatibility.
sudo ln -s /usr/include/linux/videodev2.h /usr/include/linux/videodev.h
Change directory to home directory.
Clone mjpg-streamer repository from GitHub.
This will download the source to
/home/<username>/mjpg-streamer. The default username is
git clone https://github.com/jacksonliam/mjpg-streamer.git
Enter into code directory.
Build and install mjpg-streamer and dependencies.
sudo make install
Connect webcam to Raspberry Pi and check if everything works.
mjpg_streamer -o "output_http.so -p 9000" -i "input_uvc.so -r 640x480 -n"