What is a M-JPEG?

MJPEG stands for “Motion JPEG” (wikipedia).

I have a sample PHP that will create one
https://github.com/studio-1b/php-mjpeg

Demo of Uploaded Image (shows last image):

Demo of MJPEG (shows last 60 images, and will update live after a new upload):

Above might have problems if you are visiting the https tictawf.com. Change the protocol to http:// without s, and reload, and you should see the images and the MJPEG video feed.

There are plenty of files named with extension “.mjpeg” on internet, that I play play with VLC or ffplay, but cannot be served on a webserver. These files I suspect separate their frames with the “–” character sequence, but I’m just speculating based on trying to serve these files on apache2, with multipart/x-mixed-replace; boundary= or video/x-motion-jpeg.

In apache, you can add Content-Type for each file extension
/etc/apache2/mods-enabled/mime.conf

AddType ‘multipart/x-mixed-replace; boundary=’ .mjpeg
AddType video/x-motion-jpeg .mjpg

And try to serve the “MJPEG” files yourself.

MJPEG is a old video technology that came after animated GIF. Unlike animated GIF, it is only a HTML streaming protocol, and not a image format. This means you can load any animated gif on a browser and you can see it’s animation. MJPEG requires that the HTTP protocol send a HTML header indicating what character sequence separates the frames. See below.

curl -v "http:///img.php?cmd=mjpeg&key=E" > outputtest.txt
> GET /img.php?cmd=mjpeg&key=E HTTP/1.1
> Host: 100.24.142.145:10000
> User-Agent: curl/8.7.1
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 200 OK
< Date: Sun, 11 Aug 2024 01:35:03 GMT
< Server: Apache/2.4.38 (Debian)
< Transfer-Encoding: chunked
< Content-Type: multipart/x-mixed-replace; boundary=bob_boundary
<

The content in the HTTP stream looks like

--bob_boundary
Content-Type: image/jpeg
Content-Length: 1397718

...Exif... start of JPG sometimes looks like this
...jpg binary data...
--bob_boundary
Content-Type: image/jpeg
Content-Length: 1397718

...Exif... start of JPG sometimes looks like this
...jpg binary data...
--bob_boundary
Content-Type: image/jpeg
Content-Length: 1397718

...Exif... start of JPG sometimes looks like this
...jpg binary data...
...etc, continues with new --bobBoundary, then Content-Type, then Content-Length, then empty line, then JPEG data.  Next frame start with --bobBoundary, etc

or using a boundary=myboundary

--myboundary
Content-Type: image/jpeg
Content-Length: 190014

...JFIF... start of JPG looks like this
...jpg binary data...
--myboundary
Content-Type: image/jpeg
Content-Length: 190014

...JFIF... start of JPG looks like this
...jpg binary data...
--myboundary
Content-Type: image/jpeg
Content-Length: 190014

...JFIF... start of JPG looks like this
...jpg binary data...
...etc, continues with new --myBoundary, then Content-Type, then Content-Length, then empty line, then JPEG data.  Next frame start with --myBoundary, etc

There are only a few live MJPEG streams left on the internet, that Google searches will come up with. Most have been replaced with video streaming software, and Youtube Live stream content. MJPEG is very inefficient, and probably cost a lot of bandwidth and money when it was streamed.

But MJPEG is free, and easy, so many free software use it. Such as Linux Motion, which is a free Linux based camera recorder for webcams, uses it to display a live view of the webcam. And the built-in web server for most Network Cameras, have this protocol built-in.

Here is one of the very very few sites I found with MJPEG streams:
https://github.com/fury999io/public-ip-cams?tab=readme-ov-file

None of these below work, or have been replaced with Youtube Live, or streaming software using a more modern method:
https://cctvview.info/Cameras

Leave a Reply

Your email address will not be published. Required fields are marked *