← Back to Recovery methods

MP4 and MOV Container Repair and Validation

An MP4 or MOV file can hold intact compressed media while missing the sample tables and timing metadata that map those bytes into playable tracks. Container repair can rebuild that map when the payload survives; it cannot recreate media that was never written or was overwritten, and a repaired file that opens still has to be checked from start to end.

In short
  • Find out first which layer failed: the storage fragments, the container metadata, or the codec stream inside it.
  • An unfinished normal MP4 often lacks its index; fragmented MP4 can survive interruption, but only if initialization data and complete fragments exist.
  • Atom size problems are evidence of truncation or damage, not always proof of a single cause.
  • Remuxing and faststart work with streams a parser can already read; they do not rebuild missing sample tables.
  • Open is not done: check beginning, middle and end, seeking, decoding and audio-video continuity, and keep the original.
Diagram comparing the MP4/MOV moov atom and mdat atom and their failure modes.
Two separate failure modes. Rebuilding a missing moov around a surviving mdat is repair work; missing or overwritten media fragments are a data-recovery problem that no metadata fix can solve.

Which layer is damaged

Three problems look the same in a player and need different work:

  • Storage. Parts of the file were never recovered, or were assembled from the wrong fragments. That belongs to Recovering Fragmented Video from Memory Cards.
  • Container. The media bytes exist, but the metadata that locates and times them is missing or damaged. This page is about that layer.
  • Codec stream. The compressed video or audio itself is damaged. A container can be valid while the frames inside it are not, and intact H.264 or HEVC data can sit inside an unusable container.

Knowing how the device records also matters: a normal MP4 or MOV, a fragmented MP4, or a vendor-specific structure fail differently when recording stops unexpectedly.

Atoms, boxes and what is actually required

Apple’s QuickTime File Format documentation describes files built from atoms, which it calls functionally identical to the boxes of the ISO MPEG-4 specifications. Each atom starts with a size and a type, and atoms can contain other atoms. The movie atom moov describes the tracks, the location of sample data and how to interpret it; the movie data atom mdat holds the samples, which, as Apple puts it, can usually be interpreted only by using the movie resource.

Layouts drawn in tutorials, including the diagram above, are illustrations rather than rules. Apple states that atoms can generally appear in any order and that not all atoms are required. The file type atom ftyp must precede movie and media data if present, but is not present in QuickTime movie files created before 2004. A MOV without ftyp, or with mdat before moov, is not damaged for that reason alone. MP4 files follow the related ISO format, whose own requirements are not restated here.

Sample tables map payload to tracks

moov is a hierarchy, not “the header”. Inside it, each track has sample tables that describe sample sizes, timing, chunk layout, which samples belong to which chunk, key frames and byte offsets into the media data. Finding a given frame means going from the sample number to a chunk and then to an offset in mdat. A damaged moov is like a file system that lost its extent map: the payload may be untouched, but nothing says where each sample starts.

Apple also notes that a single movie data atom can hold samples for several media at once. Video and audio chunks are often interleaved, so mdat cannot be treated as one continuous video stream.

Interrupted recordings: normal and fragmented files

FFmpeg’s documentation explains that a normal MOV/MP4 has all metadata about all packets stored in one location, usually written at the end, and is undecodable if it is not properly finished. Battery loss, a crash, a full card or removing the card during recording can leave such a file with a payload and no index.

A fragmented MP4 stores packets and their metadata together in a series of fragments, and FFmpeg notes that it is decodable even if writing is interrupted. That holds for the fragments that were completed, and only if the initialization information describing the tracks and codecs also survived. A file with moof and mdat boxes is not automatically playable after an interruption: the last fragment may be incomplete, and if the initialization data is missing or damaged, the fragments cannot be decoded on their own.

What atom sizes can show

Parsing the atom sequence is more informative than a player’s “file is corrupt” message, but sizes are evidence, not a verdict. Apple documents two special values: a size of 1 means a 64-bit extended size follows, and a size of 0, allowed only for a top-level atom, means the atom extends to the end of the file. A parser that ignores either rule will misreport a valid file.

A declared size that runs past the end of the file is consistent with truncation. It can also come from a damaged size field, from a recording that was still in progress when it was copied, or from a recovery that assembled the wrong fragments. The boundary shows where parsing stops making sense; finding out why takes the recording context and the storage evidence.

Illustration: a repaired file that opens

Observed

A player opens a repaired MP4. After the middle of the recording, frames repeat and the sound disappears.

Interpretation

The rebuilt sample tables may be wrong from that point, or the payload there may be missing or belong to another file.

Next step

Keep the output labelled as partial, compare it with the original’s structure, and check whether the storage layer recovered the later part correctly.

Limit

A conceptual example, not a documented case. Opening successfully does not end the check either way.

Remuxing is not reconstruction

Remuxing copies streams that a parser can already read into a new container without re-encoding them. It helps when the container is readable but awkward, not when the map is missing. FFmpeg’s faststart option runs a second pass that moves the existing moov to the beginning of the file, and FFmpeg notes it does not work in some situations, such as fragmented output. It does not create a moov that was never written.

Reconstruction is different work: building new sample tables from the payload itself, identifying sample boundaries, codec configuration and timing. Copying a moov from another file into a damaged one without recomputing offsets, sizes and timing produces a file whose index describes someone else’s recording.

Using a reference clip

A clean clip recorded on the same camera model, in the same mode, resolution, frame rate, codec profile and audio settings can show the expected track layout, codec configuration, timescale, sample descriptions, interleaving and vendor-specific atoms. It is a template, not a replacement: sample counts, offsets and timing for the damaged recording still come from that recording’s own data.

Record the reference clip on a different card or device. Writing it to the card that holds the lost recording can overwrite exactly the fragments being recovered. Work on copies of the damaged file, and keep the original unchanged.

Validating a repaired file

A repaired file can be missing frames or an audio track, have a different duration from the original, or drift out of sync. Check it at the beginning, the middle and the end; seek to several points; decode it fully, not just play the first seconds; and watch audio-video continuity. Compare duration and frame count with what the recording should contain where that is known. Label repaired and partial outputs separately from the untouched original. See How to Validate Recovered Data and Media Recovery, File Repair and Content Validation.

Practical rule

Identify whether the file is a normal or fragmented MP4, and whether the payload actually survived, before choosing repair. Do not treat faststart or a remux as a fix for a missing index.

Technical references: Apple: QuickTime File Format, Atoms — size and type, extended size, size zero · Apple: QuickTime movie files — atom order, ftyp optional, moov and mdat roles · FFmpeg Formats, mov/mp4 muxer — fragmentation, interruption, faststart. Pages checked October 2026; MP4 rules come from the ISO base media format, which Apple describes as closely related but distinct, and FFmpeg options can change between releases.

Related: Media Recovery, File Repair and Content Validation · Recovering Fragmented Video from Memory Cards · Corrupted or Deleted Video from a Memory Card · File-System Recovery vs. File Carving · How to Validate Recovered Data · VM, Database and Application-Container Recovery Tools