37

I've been googling like mad and can't find any file format specifications for mjpeg.

What should the header look like? Do i just append a series of jpegs after the header?

I know it's the usually in the .avi container, does that have a standardized format for codecs that might be in it?

The goal is to make it in actionscript 3, but other languages would be good to port from. I've tried looking at ffmpeg and mplayer but c is not my strong side (yet).

Any suggestions would be appreciated!

Robert Sköld
  • 752
  • 2
  • 9
  • 19

8 Answers8

16

There isn't an official standard.

In practice, in its simplest form, an mjpeg is just a concatenation of jpeg files, one after the other in the same file.

ffmpeg supports this using the -f mjpeg or -vcodec mjpeg switches.

JPEG decoders that decode multiple images should remember and use the same jpeg tables for subsequent images if those images fail to provide replacements. The jpeg standard describes this as 'abbreviated jpeg streams', and libjpeg supports this.

So an mjpeg might contain a full jpeg image, and then subsequent SOI..EOI blocks that do not specify those headers that are duplicates to the previous frame.

Will
  • 73,905
  • 40
  • 169
  • 246
10

Apparently there is no single specifiaction. From wikipedia:

Criticisms

Unlike the video formats specified in international standards such as MPEG-2 and the format specified in the JPEG still-picture coding standard, there is no document that defines a single exact format that is universally recognized as a complete specification of “Motion JPEG” for use in all contexts. This raises compatibility concerns about file outputs from different manufacturers.

hlovdal
  • 26,565
  • 10
  • 94
  • 165
6

The IETF has the standard defined as RFC 2435. I don't know what codecs will support this, but this appears to be the data spec.

Community
  • 1
  • 1
Kekoa
  • 27,892
  • 14
  • 72
  • 91
3

There is no single official specification. But some company made their own specification:

QuickTime File Format Specification (https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFPreface/qtffPreface.html)

Motion JPEG Format, QuickTime M-JPEG Specification (http://staticky.com/dl/ftp.apple.com/developer/Development_Kits/QuickTime/Programming_Stuff/Documentation/QuickTime-JPEGSpec.pdf)

Microsoft OpenDML AVI File Format Extensions (http://www.jmcgowan.com/odmlff2.pdf)

Derzu
  • 7,011
  • 3
  • 57
  • 60
2

MJPEG over HTTP at least has a pretty standard implementation. It is returned as a multi-part HTTP response.

The Wikipedia article discusses the exact mechanism:

https://en.wikipedia.org/wiki/Motion_JPEG#M-JPEG_over_HTTP

jdmichal
  • 10,984
  • 4
  • 43
  • 42
1

You can find this document in other places on the Net though I don't know which one is an authoritative source: http://www.cajunbot.com/wiki/images/7/71/USB_Video_Payload_MJPEG_1.1.pdf

Leo
  • 790
  • 8
  • 10
0

In Motion JPEG each video frame or interlaced field of a digital video sequence is compressed separately as a JPEG image. So specification of each frame (such as quality factor) stored in It's Header. in another words your problem reduced to this : "How to read header of a frame in a video?"

Maybe you can use Phil Sallee's JPEG Toolbax. Note that it has some function to read/write a jpeg image and some to display DCT Matrices,Quality Factor,Huffman Coding Tables , etc.

If you find how to use this function in video and/or how to read specification of a MJPEG video please share us

0

After many days of Internet searching, I could not find full documentation either, nor a binary example of the file protocol.

For the most informative resource I have found so far, see http://www.digitalpreservation.gov/formats/fdd/fdd000127.shtml (Motion JPEG 2000 File Format -- has many "Useful references URLs" at end including "Overview of Motion JPEG2000" which at least go some way towards answering the question).

You will find Apple MOV PDF's abound, which apparently encompasses Motion JPEG, but it would take weeks to decipher. I can only suggest to others that the above URL is a good starting place for further research.

David
  • 208,112
  • 36
  • 198
  • 279
www-0av-Com
  • 707
  • 10
  • 14