Install mjpg-streamer on Raspberry Pi for video streaming!
Introduction
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.
Steps
-
Open terminal window.
-
Update local package lists.
Always do this before installing packages.
sudo apt-get update
-
Install dependencies.
sudo apt-get install libjpeg8-dev imagemagick libv4l-dev
-
Make a symbolic link of
videodev2.h
tovideodev.h
for backward-compatibility.
sudo ln -s /usr/include/linux/videodev2.h /usr/include/linux/videodev.h
-
Change directory to home directory.
cd
-
Clone mjpg-streamer repository from GitHub.
This will download the source to/home/<username>/mjpg-streamer
. The default username ispi
.
git clone https://github.com/jacksonliam/mjpg-streamer.git
-
Enter into code directory.
cd mjpg-streamer/mjpg-streamer-experimental
-
Build and install mjpg-streamer and dependencies.
make
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"
-
Exit mjpg-streamer.
Pressctrl-c
References
- https://github.com/jacksonliam/mjpg-streamer
- https://blog.miguelgrinberg.com/post/how-to-build-and-run-mjpg-streamer-on-the-raspberry-pi
#Robots #Robotics
#raspberrypi #robotics