Skip to content

MJPEG stream

Thomas T. Jarløv edited this page Aug 7, 2018 · 6 revisions

You can view a MJPEG stream from the dashboard. NimHA cannot setup this stream for you, but there's a tutorial below.

Show stream on the dashboard

Goto to Video->MJPEG stream page and add the url to your stream.

Tutorial

This example will use a Raspberry Pi 3.

Requirements

  1. You need to have a USB camera plugged into your RPi. This could be a Sony PS3.

  2. You need ffmpeg to create the stream:

Update sources.list

Open sources:

sudo nano /etc/apt/sources.list

Append the following to the bottom of file:

deb http://ftp.debian.org/debian jessie-backports main

Exchange keys

gpg --keyserver pgpkeys.mit.edu --recv-key  7638D0442B90D010
gpg -a --export 7638D0442B90D010 | sudo apt-key add -

Install ffmpeg

sudo apt update
sudo apt install ffmpeg

ffserver configuration

You have to update the ffserver's configuration file.

Backup the original config and create a new

sudo mv /etc/ffserver.conf /etc/ffserver.conf.bak
sudo nano /etc/ffserver.conf

Insert the following data

HTTPPort 9090
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 100000
#NoDaemon

<Feed feed1.ffm>
        File /tmp/feed1.ffm
        FileMaxSize 200K
        ACL allow 127.0.0.1
</Feed>

<Stream test.mjpeg>
        Feed feed1.ffm
        Format mpjpeg
        VideoFrameRate 15
        VideoIntraOnly
        VideoBitRate 4096
        VideoBufferSize 4096
        VideoSize 640x480
        VideoQMin 5
        VideoQMax 51
        NoAudio
        Strict -1
</Stream>

<Stream stat.html>
        Format status
        # Only allow local people to get the status
        ACL allow localhost
        ACL allow 192.168.0.0 192.168.255.255
</Stream>

Find your camera

Run the following and you should see your camera:

lsusb

If you can see your camera, identify the video device with:

ls -ltrh /dev/video*

Run ffserver and ffmpeg

ffserver -f /etc/ffserver.conf & ffmpeg -r 15 -s 640x480 -f video4linux2 -i /dev/video0 http://127.0.0.1:9090/feed1.ffm

Access the stream

Go to http://lan-ip-or-127:9090/test.mjpeg