Skip to content

Instructions and helper scripts for running mjpg-streamer on Raspberry Pi

Notifications You must be signed in to change notification settings

meinside/rpi-mjpg-streamer

Repository files navigation

rpi-mjpg-streamer

Instructions and helper scripts for running mjpg-streamer on Raspberry Pi.

A. Setup mjpg-streamer

Enable Raspberry Pi Camera module from raspi-config

$ sudo raspi-config

Install necessary packages for mjpg-streamer

$ sudo apt-get update
$ sudo apt-get install build-essential libjpeg-dev imagemagick libv4l-dev git cmake uvcdynctrl

Build mjpg-streamer

$ sudo ln -s /usr/include/linux/videodev2.h /usr/include/linux/videodev.h
$ git clone https://github.com/jacksonliam/mjpg-streamer
$ cd mjpg-streamer/mjpg-streamer-experimental
$ cmake -DCMAKE_INSTALL_PREFIX:PATH=.. .
$ make install

Setup video4linux for Raspberry Pi Camera module

$ sudo modprobe bcm2835-v4l2
$ sudo vi /etc/modules

# add following line:
bcm2835-v4l2

$ sudo vi /boot/config.txt

# add following line if you want to disable RPi camera's LED:
disable_camera_led=1

Add yourself to the video group

$ sudo usermod -a -G video $USER

B. Run mjpg-streamer

1. Clone this repository

$ git clone https://github.com/meinside/rpi-mjpg-streamer.git

2-a. Run mjpg-streamer from the shell directly

# copy & edit run-mjpg-streamer.sh to your environment or needs
$ cp rpi-mjpg-streamer/run-mjpg-streamer.sh.sample somewhere/run-mjpg-streamer.sh
$ vi somewhere/run-mjpg-streamer.sh

# then run
$ somewhere/run-mjpg-streamer.sh

2-b. Run mjpg-streamer as a service

systemd

# copy & edit systemd/mjpg-streamer.service file,
$ sudo cp rpi-mjpg-streamer/systemd/mjpg-streamer.service.sample /lib/systemd/system/mjpg-streamer.service
$ sudo vi /lib/systemd/system/mjpg-streamer.service

# then register as a service
$ sudo systemctl enable mjpg-streamer.service

# or remove it
$ sudo systemctl disable mjpg-streamer.service

# and start/stop it
$ sudo systemctl start mjpg-streamer.service
$ sudo systemctl stop mjpg-streamer.service

3. Or run with docker

With docker, you don't have to build mjpg-streamer manually.

(A) With docker

Build with essential build arguments, (see the argument names and sample values in .env file)

$ docker build -t streamer:latest \
		--build-arg PORT=9999 \
		--build-arg RESOLUTION=400x300 \
		--build-arg FPS=24 \
		--build-arg ANGLE=0 \
		--build-arg FLIPPED=false \
		--build-arg MIRRORED=false \
		--build-arg USERNAME=user \
		--build-arg PASSWORD=some-password \
		.

then run with:

$ docker run -p 9999:9999 --device /dev/video0 -it streamer:latest

(B) With docker-compose

Build with optional build arguments, (see the argument names and default values in .env file)

# build with the default values
$ docker-compose build

# or with custom values
$ docker-compose build --build-arg PORT=9999 --build-arg USERNAME=user --build-arg PASSWORD=some-password

then run with:

$ docker-compose up -d

If you set custom port number, you should run with that value:

$ PORT=9999 docker-compose up -d

C. Connect

Connect through the web browser:

Connected

Most modern browsers(including mobile browsers like Safari and Chrome) will show the live stream immediately.

About

Instructions and helper scripts for running mjpg-streamer on Raspberry Pi

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •