Motion JPEG (MJPEG) is a video codec in which each frame is compressed separately as a JPEG image. It is a video compression format that has been widely used in various applications for many years. Unlike traditional video codecs that compress entire frames, M-JPEG compresses each frame of a video sequence individually as a series of JPEG images. This approach offers certain advantages and trade-offs, making M-JPEG suitable for specific use cases.
Understanding Motion JPEG (MJPEG)
In contrast to those compressed with MPEG, the videos compressed with MJPEG have a quality independent of the movement of the image. This standard is often used on security cameras and older digital cameras. Due to the individual compression of all individual frames, it is possible to cut a video clip with image accuracy without the need for recoding, which is generally only possible on I-frames (keyframes) with MPEG.
This means that instead of compressing a series of frames into a single compressed stream, each frame is compressed independently. As a result, M-JPEG does not take advantage of inter-frame redundancies, which are exploited by other video codecs like H.264 or HEVC (H.265).
---
One of the primary advantages of MJPEG is its simplicity. Since each frame is compressed independently, MJPEG encoding and decoding processes are straightforward, making it easy to implement in software and hardware.
Another benefit of MJPEG is its ability to provide random access to individual frames within a video sequence. Because each frame is self-contained, it is possible to seek to any frame in the video without decoding preceding frames.
MJPEG preserves image quality well, especially at higher compression ratios compared to other codecs. This makes it suitable for applications where maintaining image fidelity is crucial, such as medical imaging or surveillance.
However, MJPEG tends to produce larger file sizes compared to codecs that exploit inter-frame redundancies. This can be a limitation in bandwidth-constrained environments or when storage space is a concern.
The compression ratio of 1:5 to 1:13 is between uncompressed formats such as RGB/8 (1:1) or YCbCr/8 (1:1–1:3) and MPEG-2 compression (approx. 1:25 to 1:100). For high quality, this corresponds to about 30 Mbit/s for PAL video, and about 150 Mbit/s for Full HD. In the (semi-)professional studio sector, MJPEG is still partly used as an intermediate format for post-production (editing). Many internet/IP cameras also use this format. Newer cameras (from about 2010 onwards) usually use the newer H.264 codec instead of MJPEG.
Applications of MJPEG
MJPEG has been widely used in security and surveillance systems where high-quality video with minimal latency is essential. The ability to access individual frames quickly makes it suitable for applications that require real-time monitoring and analysis. The stream is often sent via the HTTP protocol. Example implementations can be found in Cambozola and MJPEG streamers. For surveillance cameras, streaming via RTP protocol has become the standard.
In medical imaging applications, such as endoscopy or digital microscopy, MJPEG is often preferred for its ability to preserve image quality and provide rapid access to individual frames for analysis and diagnosis. Although less common in professional broadcasting due to its larger file sizes, MJPEG is sometimes used in live streaming applications, especially when real-time encoding and decoding are required.

ESP32 dev board playing MJPEG Video
Credit: https://www.instructables.com/Play-Video-With-ESP32/
Frequently used clients for displaying MJPEG streams are common web browsers (Safari, Google Chrome, Mozilla Firefox and Microsoft Edge now support MJPG natively). Network-compatible multimedia players such as VLC and MPlayer as well as any software that uses the FFmpeg libraries are also suitable for displaying an MJPEG stream. In addition, Nintendo’s Wii game consoles as well as Sony’s PlayStation 3 and PlayStation Portable as well as the Safari browser of Apple’s iPhone can play movies in MJPEG format from the factory.
Considerations and Limitations of Motion JPEG (MJPEG)
MJPEG tends to produce larger file sizes compared to codecs that employ inter-frame compression, which may not be suitable for bandwidth-constrained environments. It is less efficient in terms of compression compared to modern video codecs like H.264 or HEVC, which can achieve higher compression ratios while maintaining comparable quality.
Although widely supported, MJPEG may not be as universally compatible as some other codecs, especially in web-based or streaming applications. There are numerous variants of the format, some of which are not compatible with each other. Apple has defined two types of encoding for the Quicktime format: MJPEG-A and MJPEG-B. The second variant is no longer compatible with the JPEG File Interchange Format – individual images can no longer be easily converted from the video stream to a JPEG image without changing the information in the header data area of the file.