What Is Motion JPEG and How Does It Work?

Motion JPEG (M-JPEG or MJPEG) is a video compression format where every single frame of a video sequence is compressed separately as a standard JPEG image. Unlike modern video codecs that analyze changes between consecutive frames to save space, Motion JPEG treats video simply as a rapid slideshow of standalone pictures. This article explains the technical mechanics behind Motion JPEG, how it handles individual frames, its primary advantages and drawbacks, and where it is still used today.

How Motion JPEG Uses Individual Frames

Traditional video compression formats (such as H.264, H.265, or AV1) use temporal compression—also known as inter-frame compression. These formats identify keyframes (I-frames) and then only encode the differences or movement across subsequent frames (P-frames and B-frames).

Motion JPEG operates entirely differently by using strictly spatial compression, known as intra-frame compression:

  1. Frame Capture: The video source captures raw visual data at a specified frame rate (e.g., 30 frames per second).
  2. Independent JPEG Compression: Instead of evaluating movement from frame to frame, the encoder takes each raw frame and applies standard lossy JPEG compression to it in isolation. This involves color space conversion, discrete cosine transform (DCT), quantization, and Huffman encoding.
  3. Sequential Assembly: The compressed JPEG images are placed consecutively in a container format (such as AVI, QuickTime, or raw network streams).
  4. Playback: The media player decodes each JPEG image sequentially at the designated playback speed, creating the illusion of smooth motion.

Because there is no mathematical dependency between frames, each individual image in an M-JPEG stream is complete and can be viewed independently as a standard still photograph.

Advantages of Motion JPEG

Disadvantages of Motion JPEG

Common Applications

Despite the dominance of advanced video codecs, Motion JPEG remains relevant in specific niches: