A pure C Linux MJPEG over HTTP server
mjpeg2http is a minimalistic server primarily targeted to run on embedded computers, like routers, raspberry pi, with a Linux OS.
It can be used to stream JPEG files over an IP-based network from a webcam to various types of viewers such as Google Chrome, Mozilla Firefox, VLC, mplayer, and other software capable of receiving MJPG streams.
The implementation uses epoll on non-blocking file descriptors and is not thread-based.
Install dependencies:
$ sudo apt install build-essential libv4l-dev
Compile with:
$ make
Compile with:
$ mkdir build
$ cmake ..
$ make
Run:
$ ./mjpeg2http 192.168.2.1 8080 /dev/video0 my_secret_token
Open browser on http://192.168.2.1:8080/path?my_secret_token
Run:
$ ./mjpeg2http 192.168.2.1 8080 /dev/video0 my_secret_token /tmp/mjpeg2http_token
Book access:
$ echo "12345678901234567890" > /tmp/mjpeg2http_token
Open browser on http://192.168.2.1:8080/path?12345678901234567890
The token will be valid exactly for one access after that it gets invalid
- mjpeg2http should be used in private network because it does not use TLS connections. If you would like to use it while on a public network it is highly recommended to use TLS, some ideas:
- you can try stunnel.
- nginx or apache httpd placed in front of mjpeg2http with a reverse proxy.
- for encryption between mjpeg2http and server it can be used ssh tunnels or wireguard.
- token length must be exactly TOKEN_SIZE (see constants.h)