What moov atom not found Means

An MP4 file is made of blocks called “atoms” (also called “boxes”). Two of them matter here:

  • mdat (media data): the video and audio themselves
  • moov (movie): the index, with the timestamps and the position of every sample in the file

Without the moov atom, neither a player nor FFmpeg can read the file.

Example error:
moov atom not found
Invalid data found when processing input

Why the moov Atom Ends Up at the End of the File

By default, FFmpeg writes the moov atom at the end of the file, after encoding has finished. Until encoding finishes, it does not know the number or size of the frames, so the contents and size of moov are not final.

[Default structure]
ftyp | mdat (huge video/audio data) | moov (index)

This layout causes two problems:

  1. Web playback starts late. If the server supports HTTP range requests (requests for part of a file), the player fetches the moov atom from the end first. Playback does not wait for the whole download, but it starts later.
  2. A crash leaves a broken file. If recording stops before moov is written, the file has no moov atom at all.

Moving moov to the Front: -movflags faststart

When FFmpeg writes an MP4 with -movflags faststart, it puts the moov atom at the start of the file. With -c copy, this works on an existing file without re-encoding:

ffmpeg -i input.mp4 -c copy -movflags faststart output_fast.mp4

If the file has several audio or subtitle tracks, add -map 0; without it only one video, one audio and one subtitle stream are kept.

With the index first, a browser can start playing the video before the whole file has downloaded.

[faststart structure]
ftyp | moov (index) | mdat (video/audio data)

Specifying faststart During Encoding

If you are re-encoding anyway, add the flag to the same command:

ffmpeg -i input.mp4 -c:v libx264 -crf 23 -c:a aac -movflags faststart output.mp4

Optimizing an Existing File with qt-faststart

qt-faststart is a separate tool that does the same thing, but the gyan.dev Windows builds do not include it. ffmpeg -c copy -movflags faststart gives the same result.

Repairing a File Broken by a Recording Crash

FFmpeg alone cannot repair a file that lost its moov atom because recording stopped early. If you have a good file recorded on the same device with the same settings, the open-source tool untrunc can sometimes rebuild the moov atom from it.

untrunc ok.mp4 broken.mp4

ok.mp4 is the good file and broken.mp4 is the damaged one. If the repair works, you get broken_fixed.mp4.

Fragmented MP4 for Better Crash Resilience

For recordings, a fragmented MP4 holds up better when something crashes. It writes an empty moov atom at the start, then adds the media in short fragments (each one a moof + mdat pair):

ffmpeg -i input.mp4 -c copy \
  -movflags frag_keyframe+empty_moov \
  -frag_duration 4000000 \
  output_frag.mp4
  • frag_keyframe: starts a new fragment at each keyframe
  • empty_moov: writes an empty moov atom at the start of the file
  • -frag_duration 4000000: makes each fragment at most 4 seconds long (the value is in microseconds). frag_keyframe can start the next fragment earlier, at a keyframe

If a crash happens partway through, the part already written can still be played. The layout is close to HLS/DASH segments. -movflags +hybrid_fragmented records as a fragmented MP4 and turns it into a regular MP4 when writing finishes (it cannot be combined with faststart). A cut-off fragmented MP4 can be turned into a regular MP4 with ffmpeg -i broken.mp4 -c copy fixed.mp4.

Measured: time and size

The measured command:

ffmpeg -i input.mp4 -c copy -movflags +faststart output.mp4
Metric Measured
Wall time 0.49 s
Output size 353.29 MB

Test machine: Core i9-14900KF (32 threads), FFmpeg 8.1 (gyan.dev). Source: an MP4 made from a 1920x1080, 30 fps, 120 s, 351.4 MB video (Big Buck Bunny, looped, CC BY 3.0) plus one 128 kb/s AAC audio track, 353.29 MB in total. Measured 2026-09-05. The raw numbers are in the dataset.

Why it is so fast

faststart does not re-encode: it only rewrites the packets and moves the index to the front, so it takes about half a second on this 353 MB file. Re-encoding similar source clips took about 28 seconds.

If you forget the flag, you can add it afterwards (0.49 s for this file).

How to Inspect the Atom Structure of an MP4

ffprobe can list the atoms in the order they appear in the file:

ffprobe -v trace -i input.mp4 2>&1 | grep -E "type:'(ftyp|moov|mdat)'"
ffprobe -v trace -i input.mp4 2>&1 | Select-String "type:'(ftyp|moov|mdat)'"

If moov comes before mdat, the index is already at the front.

Frequently Asked Questions

Q: Can I just re-encode a file that gives moov atom not found?

No. Without the moov atom, FFmpeg cannot tell where the frames are, so it cannot read the file at all. Repair it with a tool such as untrunc first.

Q: Should I always use -movflags faststart?

Use it for video that plays on the web or streams. Files you only play locally do not need it. For recording, frag_keyframe+empty_moov survives crashes better.