UK tech experts · info@vividrepairs.co.uk
Vivid Repairs
A Windows laptop on a dark desk showing a hex editor with MJPEG binary data and corrupted video frame markers highlighted in red
Fix It Yourself · Troubleshooting

corrupt MJPEG frame

Published 26 August 202613 min read
As an Amazon Associate, we may earn from qualifying purchases. Our ranking is independent.

Your video was recording fine, then something went wrong. Now you've got a file that stutters, freezes, or throws up visual garbage at the same point every single time you play it. That's a corrupt MJPEG frame, and yes, it's fixable in most cases. This guide goes from the quick five-minute checks right through to byte-level hex inspection, so you can find exactly where the damage is and salvage as much footage as possible.

TL;DR

A corrupt MJPEG frame is usually caused by an interrupted recording or transfer. Start by testing in VLC vs Windows Media Player to rule out codec issues. If the problem is real, use FFmpeg to log decode errors and a hex editor to find missing or broken SOI (FF D8) and EOI (FF D9) markers. Trim the corrupt section and re-encode the rest.

⏱️ 13 min read ✅ 50-70% success rate 📅 Updated August 2026

Key Takeaways

  • A corrupt MJPEG frame has broken or missing SOI (FF D8) and EOI (FF D9) byte markers.
  • If corruption only shows in one player, it's a codec problem, not actual file damage.
  • FFmpeg can log the exact frame timestamps where decoding fails.
  • MJPEG frames are independent, so you can trim a corrupt frame without affecting the rest of the file.
  • AVI MJPEG files sometimes fail because of missing Huffman tables (DHT), not corrupt frame data.
  • Dedicated data recovery software can automate much of this process if manual methods feel out of reach.

At a Glance

  • Difficulty: Advanced
  • Time Required: 15 to 45 mins
  • Success Rate: 50 to 70% depending on extent of damage

What Actually Causes a Corrupt MJPEG Frame?

MJPEG (Motion JPEG) is exactly what it sounds like: a video format where every single frame is a full, self-contained JPEG image. That's useful because one bad frame doesn't cascade into the next, unlike H.264 where inter-frame dependencies mean one corrupt packet can ruin seconds of footage. But it also means that when something goes wrong during recording or transfer, the damage shows up as one or more visually broken frames at a specific point in the file.

The most common cause, by a long way, is an interrupted write. Power cuts out mid-recording, the capture app crashes, someone yanks the USB cable, the SD card fills up and the writer doesn't close the file cleanly. Any of those can leave you with a file where the last few frames are truncated or the container index is broken. The file exists, it opens, but at some point playback just falls apart.

Beyond that, there are a few other culprits worth knowing about. Faulty storage media is a big one. SD cards in particular degrade over time, and a sector error on the card can corrupt the bytes that make up a JPEG frame mid-write. You won't necessarily see any warning before it happens. File system errors from an incomplete download or a dodgy network transfer can do the same thing.

Then there's a subtler problem specific to AVI MJPEG containers. Some cameras and capture devices store the Huffman table (DHT) for JPEG decoding once in the container header rather than embedding it in every frame. If the decoder on your Windows machine doesn't know to look for it there, every frame looks corrupt even though the data is fine. According to Microsoft's DirectShow documentation on the MJPEG Decompressor filter, this is a known quirk of the AVI MJPEG format and affects compatibility between different decoders.

Finally, sometimes it's not the file at all. The wrong codec installed on Windows, or a player that doesn't properly support the specific MJPEG variant from your camera, can make a perfectly good file look broken. That's why the first step is always to test across multiple players before you start digging into the file itself.

Corrupt MJPEG Frame: Quick Fix

Before you do anything complicated, run through these checks. In a decent chunk of cases, the problem is a codec or transfer issue rather than actual frame damage, and these steps will sort it in under ten minutes.

1

Cross-Player Test and Re-Copy Easy

  1. Test in VLC and Windows Media Player
    Open your MJPEG file in VLC first. Scrub through the timeline to the point where you know the problem is. Note the exact timecode. Then open the same file in Windows Media Player and go to the same point. If the corruption only appears in one player, you don't have a corrupt MJPEG frame in the file itself. You have a codec issue on Windows. VLC uses its own internal MJPEG decoder which is much more tolerant of minor frame issues, while Windows Media Player relies on DirectShow decoders that can be stricter or simply missing.
  2. Re-copy from the original source
    If you copied the file from an SD card or external drive, copy it again. Don't drag and drop; use a proper file copy that verifies completion. On Windows, you can use robocopy from the command prompt: robocopy D:\DCIM C:\Videos\Recovery /E /LOG:copy_log.txt. This logs the transfer and flags any errors. If the fresh copy plays cleanly, the original copy was corrupted during transfer, not at the source.
  3. Run a VLC re-wrap pass
    Open VLC. Go to Media > Convert/Save. Add your MJPEG file. Click Convert/Save at the bottom. Choose a profile (MP4 is fine) and under Video Codec, tick 'Keep original video track' so it doesn't re-encode. Set an output path and click Start. Test the resulting file at the same timecode. This fixes container-level index corruption without touching the actual frame data.
If corruption disappears after re-copy or re-wrap, you're done. The frame data was fine all along.
A corrupt MJPEG frame that only shows in Windows Media Player but not VLC almost always points to a missing or mismatched codec on your system rather than damaged file data. Check your installed codecs before going further.

If the same corruption appears in every player and survives a fresh re-copy, the frame data itself is damaged and you'll need to go deeper. Dedicated data recovery software can automate the frame scanning process and is worth considering if you're not comfortable with command-line tools. The manual methods below give you full control, but they take time.

More Corrupt MJPEG Frame Solutions

These intermediate steps work well when the corruption is localised to a small section of the file and your video editor can step through frames accurately enough to find it.

2

Frame-by-Frame Inspection and Trim Medium

  1. Open in a frame-accurate editor
    You need a video editor that lets you step one frame at a time. Most professional editors and many free ones support this. Open your MJPEG file and navigate to roughly where the corruption appears based on your earlier player test.
  2. Step through frame by frame
    Use the frame-step key (usually the period key in most editors, or the right arrow in some players) to advance one frame at a time. Watch for the exact frame where the image breaks down: visual artifacts, a completely garbled frame, a freeze, or a black frame. Note the timecode. That's your corrupt MJPEG frame location.
  3. Trim around the corrupt segment
    Cut a few frames either side of the corrupt frame to be safe. Export the good section before it and the good section after it as separate clips. Since MJPEG has no inter-frame dependencies (unlike H.264 or HEVC), cutting out a bad frame has zero effect on the frames around it. You won't get a cascade of broken frames from the trim.
  4. Re-encode to a modern format
    Bring the trimmed good clips into your editor and re-encode to H.264 MP4. This gives you a file that will play reliably on any Windows machine without needing a specific MJPEG codec. For reference on what MJPEG actually is and how it compares to other formats, HowToGeek has a solid explainer that's worth a read if you're new to the format.
If you can identify and trim the corrupt frame region, you'll recover everything before and after it cleanly. The lost footage is just the corrupt frames themselves, which were unplayable anyway.
If the corruption spans a large continuous section rather than a few isolated frames, trimming won't recover much. In that case, move to the advanced steps below to understand the full extent of the damage before deciding whether recovery is worth pursuing.

One thing worth checking at this stage: if your MJPEG file came from a camera that records to AVI, and every frame looks garbled rather than just one or two, you may be dealing with the missing DHT problem rather than actual corrupt MJPEG frame data. A decoder that doesn't supply the correct Huffman table will fail on every frame. The advanced section covers how to diagnose this.

If you're also dealing with general video file issues beyond MJPEG, it's worth reading our video file repair guide for Windows which covers a wider range of container formats and recovery approaches.

Advanced Corrupt MJPEG Frame Fixes

This is where you get into the actual byte structure of the file. You'll need FFmpeg (free, command-line) and a hex editor. Both are available for Windows. FFmpeg can be downloaded from the official FFmpeg documentation site and added to your system PATH. For the hex editor, any free Windows hex editor will do the job.

3

FFmpeg Error Logging to Pinpoint Corrupt Frames Advanced

  1. Extract the raw MJPEG stream from the container
    If your file is an AVI, the MJPEG video stream is wrapped in the container. Extract it first so you're working with raw frame data:
    ffmpeg -i input.avi -map 0:v:0 -c copy output.mjpeg
    This copies the video track only, no re-encoding, into a raw MJPEG stream file. If your file is already a raw .mjpeg file, skip this step.
  2. Run FFmpeg with error verbosity
    Now tell FFmpeg to decode every frame and report any it can't handle:
    ffmpeg -v error -i output.mjpeg -f null -
    Watch the console output. FFmpeg will print error messages for each frame it cannot decode properly, including the timestamp or frame index. Those timestamps are your corrupt MJPEG frame locations. Write them down.
  3. Verify the frame count and timestamps
    Cross-reference the reported timestamps with what you saw during frame-by-frame inspection in your editor. If they match, you've confirmed the exact corrupt frames. If FFmpeg reports no errors but you still see corruption in players, the issue is likely a missing DHT (see Step 4 below).
FFmpeg error output gives you exact frame-level timestamps for every corrupt MJPEG frame in the file, which is far faster than manual frame stepping for long recordings.
4

Hex Editor Inspection for Bad SOI and EOI Markers Advanced

  1. Open the raw MJPEG in a hex editor
    Open your output.mjpeg file in a Windows hex editor. You're looking at the raw bytes of the file. Each MJPEG frame must start with the SOI marker FF D8 and end with the EOI marker FF D9. Use the editor's search function to find each occurrence of FF D8 and FF D9 in sequence.
  2. Check for missing EOI markers
    If you find an FF D8 (start of frame) followed by another FF D8 before any FF D9 appears, the first frame is truncated. Its EOI is missing. That's a corrupt MJPEG frame. The frame data ends somewhere in the middle and the decoder has no clean termination point.
  3. Check for garbage bytes after EOI
    Look at what comes after each FF D9. In a clean file, the next thing should be FF D8 (start of the next frame) or container framing data. If there are random bytes between FF D9 and the next FF D8, those are garbage bytes, possibly from a write error or buffer overflow. You can edit them out in the hex editor, but be careful: only remove bytes you're certain are outside the frame boundaries.
  4. Check for out-of-order markers
    An FF D9 appearing before its matching FF D8, or markers in a sequence that doesn't make sense, points to a more severe corruption where the frame structure itself is scrambled. At that point, the frame data is unrecoverable and should be skipped entirely.
  5. Supply missing Huffman tables if needed
    If FFmpeg reports no errors but frames still decode badly, and your file is from an AVI MJPEG source, the problem may be a missing DHT. AVI MJPEG containers sometimes store the Huffman table once in the container header rather than in each frame. When you extract the raw stream, that table gets lost. FFmpeg can add it back: use the -huffman optimal flag or use a decoder script that prepends the correct JFIF header and DHT before each frame. This is a known quirk of the AVI MJPEG format.
Once you've identified exactly which frames have broken markers, you know precisely what to trim and what to keep. The rest of the file is clean.
5

Rebuild and Re-encode the Cleaned File Medium

  1. Re-encode the cleaned stream to a new container
    Once you've identified and trimmed the corrupt MJPEG frame regions, re-encode to a clean output. To stay in MJPEG format:
    ffmpeg -i cleaned.mjpeg -c:v mjpeg -qscale:v 2 -an repaired.avi
    The -qscale:v 2 sets high quality (scale is 2 to 31, lower is better). The -an flag drops audio, which you'd add back separately if needed.
  2. Or convert to H.264 MP4 for better compatibility
    If you don't need to stay in MJPEG format, convert to H.264:
    ffmpeg -i cleaned.mjpeg -c:v libx264 -crf 18 -preset slow -an repaired.mp4
    CRF 18 is visually near-lossless. This output will play on any Windows machine without any special codec installed.
  3. Verify the output
    Run the repaired file through the same FFmpeg error check:
    ffmpeg -v error -i repaired.mp4 -f null -
    No output means no decode errors. Play it in both VLC and Windows Media Player to confirm the corrupt MJPEG frame is gone.
A clean FFmpeg error check and successful playback in both players confirms the repair is complete.

If you're dealing with storage-level damage rather than just file-level corruption, the underlying problem might be a failing drive. Our hard drive health check guide covers how to test your storage media and catch problems before they cause more data loss.

Preventing a Corrupt MJPEG Frame

Most MJPEG corruption is preventable. The number one cause is an interrupted write, so the single most important habit is stopping your recording cleanly before you power off or disconnect anything. Don't pull the SD card while the camera is still writing. Don't force-close your capture application. Give the device a moment to finish closing the file properly. It sounds obvious, but this is behind the majority of corrupt MJPEG frame cases I see.

Beyond that, here are the things worth doing in rough order of importance:

  1. Stop recording cleanly every time. Never pull power or disconnect storage mid-recording.
  2. Check your SD cards and drives regularly. Use your camera's built-in format tool rather than formatting on Windows, and replace cards that are more than a few years old or show any errors during transfer.
  3. Never interrupt a file transfer. If a copy gets interrupted, delete the partial file and start again from scratch. A half-copied MJPEG file is often worse than no file at all because it looks complete but plays back with corruption.
  4. Use the right codec and player. Install the vendor-recommended MJPEG codec for your specific camera or capture device. Generic Windows codecs sometimes mishandle device-specific MJPEG variants.
  5. Keep your capture system stable during recording. Avoid Windows updates, sleep mode, or heavy background tasks while an MJPEG stream is being written. An OS interruption mid-write is just as bad as a power cut.

If you're capturing MJPEG from a network camera or streaming source, also check that your capture hardware correctly signals packet boundaries. Partial frame buffering in custom pipelines is a less common but genuinely tricky cause of corrupt MJPEG frame problems that's hard to diagnose without reviewing the capture code or hardware documentation. Our network camera troubleshooting guide has more on that side of things.

Corrupt MJPEG Frame: Summary

A corrupt MJPEG frame is frustrating but usually fixable, especially when the damage is localised to a small section of the file. Start with the simple checks: test in VLC and Windows Media Player, re-copy from the source, and try a VLC re-wrap pass. Those three steps alone resolve a good portion of cases where the corruption is container-level or codec-related rather than actual frame damage.

When the corrupt MJPEG frame is genuinely in the file data, FFmpeg is your best diagnostic tool. The error verbosity mode gives you exact timestamps for every frame that fails to decode, which saves a lot of time compared to manual frame stepping. From there, hex editor inspection of the SOI and EOI markers tells you exactly what's broken at the byte level, whether it's a missing EOI, garbage bytes after a frame end, or a missing Huffman table causing every frame to fail.

The key advantage of MJPEG over inter-frame formats is that one corrupt MJPEG frame doesn't take down the frames around it. Trim the bad section, re-encode the rest, and in most cases you'll get back a clean, playable file with only a small gap where the damage was. That's a much better outcome than the same corruption in an H.264 file would give you.

Frequently Asked Questions

SOI (Start of Image) is the byte sequence FF D8 that marks the beginning of each JPEG frame. EOI (End of Image) is FF D9 that marks the end. A corrupt MJPEG frame often has one or both of these missing or in the wrong order. You can spot them by opening the raw stream in a hex editor and searching for those byte pairs.

VLC uses a more tolerant MJPEG decoder that can skip over minor frame issues. Windows Media Player uses stricter DirectShow-based decoders that fail hard on malformed frames. If corruption only shows in one player, the file is likely technically valid and you have a codec compatibility problem rather than a genuine corrupt MJPEG frame.

Not really. If a frame is missing large chunks of data, reconstruction is not possible without external reference data. The good news is that MJPEG frames are fully independent, so you can simply trim or skip the corrupt frame without affecting the frames before or after it.

DHT stands for Huffman table, which is used to decode compressed JPEG data. Some AVI MJPEG containers store a single DHT externally rather than embedding it in each frame to save space. If your decoder does not supply this table, frames cannot be decoded and will appear corrupt even if the frame data itself is fine. Professional decoders and tools like FFmpeg handle this automatically.

Yes, and it is often the best recovery strategy. Modern encoders tolerate minor MJPEG frame issues and can skip or work around corrupt frames, producing a clean output file. Just trim out the worst affected section first if you can identify it, then re-encode the rest.