A pure C Mjpeg-over-HTTP server

Hacker News - Tue Jan 18 15:34

A pure C linux MJPEG over HTTP server

License: MIT


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:



$ ./mjpeg2http 8080 /dev/video0 my_secret_token

Open browser on

One time token


$ ./mjpeg2http 8080 /dev/video0 my_secret_token /tmp/mjpeg2http_token

Book access:

$ echo "12345678901234567890" > /tmp/mjpeg2http_token

Open browser on

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
  • token length must be exactly TOKEN_SIZE (see constants.h)