How to repair an MP4 file

An MP4 that won't play usually lost its index, the part written when recording stops. Check it in VLC first. If VLC or ffmpeg can read it, re-wrap it into a new file for free. If ffmpeg says "moov atom not found", the index has to be rebuilt using a working MP4 from the same camera.

Updated · 7 min read

Why MP4 files break

An MP4 file holds two things: the footage (the picture and sound, in a long block called mdat) and the index (a block called moov that lists where every frame starts, how big it is and when it plays). A player reads the index first. Without it, it has no idea where one frame ends and the next begins.

Most cameras and phones can’t write the index until they know how long the recording is, so they write it last, when you press stop. That’s the weak point. If the battery dies, the card fills up, the card is pulled out, or the camera app crashes, the footage that was already written stays on the card, but the index never gets written.

The result is a file that’s the right size (often several gigabytes) and won’t open in anything. The same thing happens to MOV files, which use the same structure; see MP4 vs MOV below.

Is it the player or the file?

Before you repair anything, find out whether the file is really broken. Two quick checks:

1. Open it in VLC. QuickTime Player is strict, so a file it refuses may still play in VLC. If VLC plays it with a sensible duration, the file is readable and you only need a clean copy (see the free fixes below). If VLC lists it at 00:00 and plays nothing, the index is missing.

VLC media player playlist showing h264-mp4-30-broken.mp4 with a duration of 00:00
VLC 3.0.20 on macOS 27.0.1 with h264-mp4-30-broken.mp4, one of our test MP4s, made on a Mac and cut off before its index was written. A 00:00 duration on a file with real size means no index.

2. Ask ffprobe. If you have ffmpeg installed (on a Mac, brew install ffmpeg), run:

ffprobe broken.mp4

If it prints a duration and stream details, the index is there. If it prints moov atom not found, it isn’t. This is ffprobe 6.1.1 on our 20 MB test file, h264-mp4-30-broken.mp4:

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7bcac78000] moov atom not found
h264-mp4-30-broken.mp4: Invalid data found when processing input

Free fixes, and when each one works

VLC: Convert / Stream

If VLC can play the file, it can also write a clean copy:

  1. In VLC, choose File › Convert / Stream.
  2. Drag your MP4 into the window.
  3. Under Choose Profile, pick Video – H.264 + MP3 (MP4).
  4. Click Save as File, then Browse to choose a new name and folder, and click Save.

VLC re-encodes the video when it converts, so the copy can look very slightly softer than the original. Keep the original either way.

This works when the index is there but damaged or the end of the file is missing. In our tests on macOS 27.0.1, VLC 3.0.20 turned an interrupted copy of a Canon clip into a 6.5-second file that plays. On a file with no index, it wrote an empty 160-byte file, because there was nothing it could read.

ffmpeg: re-wrap without re-encoding

ffmpeg can copy the video and sound into a fresh MP4, writing a brand-new index from what it can read:

ffmpeg -i broken.mp4 -c copy fixed.mp4

-c copy copies the streams as they are, so there’s no quality loss and it’s quick even on large files. The original isn’t touched. On our interrupted Canon copy, ffmpeg 6.1.1 printed a “corrupt input packet” warning for the last, half-written frame and then wrote a 6.7-second file that plays.

If ffmpeg stops partway because of errors near the end of the file, you can ask it to carry on past them:

ffmpeg -err_detect ignore_err -i broken.mp4 -c copy fixed.mp4

On our Canon copy this gave the same 6.7 seconds. Neither command helps when the index is missing. ffmpeg needs the index to know where the frames are, so it stops at “moov atom not found” before doing anything.

Copy it from the card again

If the MP4 came off a memory card and the card still has it, copy it again before trying anything else. An interrupted copy is the one kind of “broken” file you can fix by getting a better copy. Check the size: if the file on the card is bigger than the one on your Mac, the copy was cut off.

Rebuilding a missing index

When the index is missing, it has to be rebuilt from the footage. That’s harder than it sounds. The mdat block is a long run of compressed video and audio frames with nothing marking where each one starts. To split it back into frames, a tool has to know exactly how your camera writes video: the codec and its settings, the frame rate, how many slices make up each picture, how the sound is interleaved with the picture, and any padding or private data the camera adds between them.

None of that is in the broken file, but all of it is in any working MP4 from the same camera filmed in the same mode (same resolution and frame rate). That’s why repair tools ask for a reference or helper clip. The tool learns the camera’s pattern from the helper, then walks through the broken file checking every frame against it, and writes a new index that matches.

Done carefully, the result is exact: the frames themselves are copied byte for byte, and only the index is new. In our tests of the VideoRescue engine, MP4s that we cut short on purpose came back frame-identical to the original up to the cut, and a 1 GB file was rebuilt without being loaded into memory, in under a second from the Mac’s own drive in our test; from a memory card it takes longer.

VideoRescue showing 19 s of video found in h264-mp4-30-broken.mp4, with a similar video suggested as the helper
VideoRescue on macOS 27 with h264-mp4-30-broken.mp4, our 20 MB test MP4 that QuickTime, VLC and ffmpeg all refused. It found the whole 19 seconds and suggested the helper clip next to it.

VideoRescue does this on your Mac

Drop the video, and it finds a helper clip from the same camera by itself. Watch a 10-second preview for free, then save the whole video for $9 once.

A repaired video playing in VideoRescue
The repaired test MP4 playing in VideoRescue's preview
The free 10-second preview of the repaired test file, played from the rebuilt MP4 on macOS 27.

MP4 vs MOV

MOV is Apple’s QuickTime format, and MP4 is based on it. They share the same structure: a moov index and an mdat block of footage. Cameras that record MOV break in exactly the same way, and the same fixes apply: VLC and ffmpeg for readable files, an index rebuild for files whose index is missing. The ffmpeg -c copy command works on MOV too; keep the .mov extension on the output.

Two differences matter in practice. Some cameras that record MOV store uncompressed (LPCM) sound instead of AAC; a repair tool has to handle both, and in our tests the VideoRescue engine repaired MOVs with each. And some cameras write the index at the start of the file and leave space for it to grow, so an interrupted copy can carry a complete index with missing footage. In that case, no helper clip is needed.

What can’t be fixed

An MP4 repair rebuilds what’s in the file. It can’t recover footage that was never written. If the copy from the card stopped at 60%, you get the first 60% of the recording. From an interrupted copy of a real Canon clip, about 6 seconds came back. If the file is all zeros (some cameras reserve the space and never write the recording), there’s nothing to rebuild at all.

For the bigger picture, including how to tell these cases apart, see how to fix a corrupted video. If your camera or phone switched off mid-recording, my camera died while recording covers what to do first.

Questions

What does "moov atom not found" mean?

The moov atom is the MP4's index. ffmpeg prints this when it reaches the end of the file without finding one, which almost always means recording stopped before the camera could write it. The footage is usually still in the file.

Can I repair an MP4 without a reference video?

Sometimes. If the index is intact and only the end of the footage is missing, as after an interrupted copy, no reference is needed. If the index is missing, a repair tool needs a working clip from the same camera to learn how it writes video.

Does renaming .mp4 to .mov help?

No. The extension is just a label; players look inside the file. Renaming doesn't create the missing index.

Will repair lower the quality?

Re-wrapping and index rebuilding copy the video as it is, without re-encoding, so the picture is identical to what was recorded.