Repairing MP4 files with FFmpeg: commands that work (and what it cannot fix)

FFmpeg can fix many MP4 and MOV problems, but not all of them. It repairs files that it can still read: broken timestamps, a misplaced index, damaged frames in the middle, an incompatible audio track. It cannot repair a file whose index (moov atom) is missing, which is the most common damage after an interrupted recording; FFmpeg then stops with "moov atom not found". For that case, rebuild the index first, then use the commands below if needed.

First: diagnose

`` ffprobe -hide_banner damaged.mp4 ``

  • "moov atom not found": the index is missing. FFmpeg cannot help directly; see the section at the end.
  • "Invalid data found when processing input": the file is not readable as MP4 at all; see invalid data found.
  • Streams listed normally: FFmpeg can read the file. Use the commands below.

To find damage inside the streams, decode everything and print only errors:

`` ffmpeg -v error -i damaged.mp4 -f null - 2> errors.txt ``

An empty errors.txt means every frame decoded cleanly.

1. Remux: rebuild the container without re-encoding

Fixes odd container structures, broken edit lists and some timestamp issues. Lossless and fast.

`` ffmpeg -i input.mp4 -map 0 -c copy output.mp4 ``

If FFmpeg complains about a data or timecode track, map only audio and video:

`` ffmpeg -i input.mp4 -map 0:v -map 0:a? -c copy output.mp4 ``

2. Regenerate timestamps

Fixes wrong duration, seeking that jumps, or audio drifting out of sync in an otherwise readable file.

`` ffmpeg -fflags +genpts -i input.mp4 -map 0 -c copy output.mp4 ``

For files with gaps, re-encoding with a constant frame rate is more thorough:

`` ffmpeg -i input.mp4 -vf fps=30 -c:v libx264 -crf 18 -c:a aac -af aresample=async=1 output.mp4 ``

Replace 30 with the original frame rate.

3. Re-encode around damaged frames

Fixes green blocks, smearing, freezes and players that stop at a certain point. FFmpeg conceals what it can and drops the rest:

`` ffmpeg -err_detect ignore_err -i damaged.mp4 -c:v libx264 -crf 18 -preset medium -c:a aac -b:a 192k fixed.mp4 ``

The damaged moments remain imperfect, but the output is a clean, consistent file. For HEVC sources, use -c:v libx265 -crf 22 -tag:v hvc1 to keep the file smaller.

4. Cut out the broken part

If a recording is fine up to a point, keep only the good part (here the first 12 minutes 30 seconds):

`` ffmpeg -i damaged.mp4 -t 00:12:30 -c copy good-part.mp4 ``

Or skip a damaged start:

`` ffmpeg -ss 00:00:05 -i damaged.mp4 -c copy rest.mp4 ``

With -c copy, cuts snap to the nearest keyframe.

5. Move the index to the front (faststart)

Not damage, but a common reason a video will not start playing online until fully downloaded:

`` ffmpeg -i input.mp4 -c copy -movflags +faststart output.mp4 ``

6. Fix the audio track

Convert an audio codec that players reject (PCM, AC-3, Opus) to AAC while copying the video:

`` ffmpeg -i input.mp4 -c:v copy -c:a aac -b:a 192k output.mp4 ``

Drop a broken audio track entirely:

`` ffmpeg -i input.mp4 -map 0:v -c copy -an video-only.mp4 ``

7. Salvage a fragmented or streamed recording

Recordings from OBS (fragmented MP4), screen recorders and some security systems may be readable as a raw stream even when the container is confused. Forcing the demuxer sometimes helps:

`` ffmpeg -f mp4 -i recording.mp4 -c copy salvaged.mp4 ``

For a raw H.264 stream file (.h264, .264), wrap it into MP4:

`` ffmpeg -framerate 30 -i video.h264 -c copy video.mp4 ``

When the moov atom is missing

FFmpeg reads an MP4 by first reading its index. Without the moov box, it does not know the codec parameters, the frame sizes or where each frame starts, so it gives up. The data is usually still there, and it can be indexed again by a tool that scans the raw media and uses a reference file from the same camera to learn the codec settings:

Once the index is rebuilt, the result is a normal MP4 that every command on this page can process.

Common FFmpeg errors and what they mean

MessageMeaningWhat to try
moov atom not foundIndex missingRebuild the index (untrunc, FixMP4)
Invalid data found when processing inputNot readable as the expected formatCheck the real format; repair or recover
error while decoding MBA damaged frameRe-encode (command 3)
Non-monotonous DTSBroken timestampsRegenerate timestamps (command 2)
Could not find tag for codecCodec not allowed in MP4 in copy modeConvert that stream (command 6)
Packet corrupt / stream ends earlyFile truncatedCut to the good part (command 4)

Always keep the original file untouched and write FFmpeg output to a new name: every command here creates a new file and leaves the source as it was, so you can try several approaches in turn and compare the results side by side.

If ffprobe warns that it could not find codec parameters for a stream, read FFmpeg "Could not find codec parameters" to tell a probing limit from a stream with no usable data.

FixMP4 compared with other options

FeatureFixMP4Desktop repair suitesuntrunc (CLI)VLC
Runs whereBrowser, on your deviceDesktop appCommand lineDesktop player
Keeps your file on your device✓✓✓✓
Nothing to install✓✕✕✕
Rebuilds a missing MP4/MOV index✓✓✓✕
Preview of your own repaired file before paying✓Trial (varies)Free tooln/a
Voice Memos / AAC without a referenceUsuallyVaries✕✕
Formats beyond MP4/MOV/M4A✕✓Many (FFmpeg)Plays many

Try it on your file

Free diagnosis and 15-second preview. Nothing is uploaded.

Open the repair tool

Frequently asked questions

Can FFmpeg fix 'moov atom not found'?

No. FFmpeg needs the index to read an MP4. Rebuild the index first with untrunc or FixMP4, then use FFmpeg if needed.

Does -c copy lose quality?

No. It copies the compressed streams unchanged into a new container.

How do I find errors in a video with FFmpeg?

Run ffmpeg -v error -i video.mp4 -f null - . It decodes every frame and prints only errors.

Which FFmpeg version should I use?

Any recent release (6.x or 7.x). Older versions handle HEVC and damaged files less well.