How to Diagnose and Repair a Corrupted MP4 File

November 08, 2026 · MP4.now Editorial · MP4 Essentials

Separate storage failure, structural damage and unsupported MP4 features before attempting repair.

Diagnose the Failure Before You Attempt Repair

A corrupted MP4 file rarely announces what went wrong. The same “file not supported” error can stem from a failed hard drive sector, a truncated network download, or a missing metadata atom that tells a player where the video stream begins. Attempting repair without understanding the root cause will overwrite salvageable data or waste hours on unrecoverable damage.

MP4 is a container based on the ISO Base Media File Format (ISOBMFF), defined in ISO/IEC 14496-12. Its structure is a nested tree of atoms (also called boxes). Every atom carries a four-character type code (e.g., ftyp, moov, mdat, moof). The moov atom contains the movie header, track metadata, and sample tables that map timestamps to byte offsets inside the mdat atom where the actual compressed audio and video frames live. If the moov atom is missing or incomplete, a player has no map and cannot parse the file regardless of whether the video data itself is intact.

The three distinct failure modes for MP4 files are:

  • Storage failure: physical or logical damage to the drive, leaving gaps, substituted bytes, or zeroed sectors in the file.
  • Structural damage: valid bytes exist but the atom hierarchy is broken—missing headers, incorrect atom size fields, or a truncated moov atom.
  • Unsupported feature: the file is structurally sound but uses an encoding, profile, or atom extension that your player or repair tool does not understand.

Diagnose which mode you are facing before running any repair command.

Check the File Signature and Atom Skeleton

Every MP4 file must begin with an ftyp atom (file type box). The first four bytes are the atom size (big-endian unsigned integer), the next four bytes are the type ftyp, and the following four bytes contain the major brand (e.g., isom, mp42, avc1). A hex dump or a dedicated parser will reveal whether the signature is present.

# Quick signature check with xxd (first 12 bytes)
xxd -l 12 corrupt.mp4

# Expected output example:
# 00000000: 0000 001c 6674 7970 6973 6f6d       ....ftypisom

If the first four bytes are not a valid atom size (the value must be at least 8 and, for the root-level ftyp, typically less than 256) or the type is not ftyp, the file likely suffered storage failure or was overwritten. If the signature is correct, inspect the atom tree with a tool like mp4dump (part of the Bento4 suite):

mp4dump corrupt.mp4 2>&1 | head -50

A healthy file shows a root atom list starting with ftyp, followed by moov (or moof for fragmented files), then mdat. A truncated or missing moov atom—or an atom size field that points beyond the file length—indicates structural damage.

Distinguish Missing moov from Damaged mdat

If moov is intact but mdat contains garbage or stops abruptly, the video stream itself is corrupt. Validate this by checking the stco or co64 chunk offset table inside the moov atom. Each entry must point to a byte offset within the file’s actual size. Offsets beyond the file length confirm truncation.

If moov is missing entirely, the file may still be repairable by rebuilding the metadata from the raw frames—but only if the encoding is a simple, single-track format. H.264/AVC baseline profile without B-frames is the most recoverable codec. High-profile H.264 with B-frames, HEVC, or interleaved audio tracks drastically reduce the probability of successful reconstruction.

Identify Fragmented MP4 (fMP4) and Other Unsupported Features

The Library of Congress format description notes that the moof atom (movie fragment) is used in streaming or live-recording scenarios (see LOC FDD000155). If your file contains moof atoms instead of a single moov, standard desktop players may refuse it. This is not corruption—it is an unsupported feature. Converting fragmented MP4 to a non-fragmented container is a remux operation, not a repair.

Check for moof atoms explicitly:

mp4dump corrupt.mp4 2>&1 | grep -c "moof"

A count greater than zero confirms a fragmented structure. Other unsupported features include encryption (check for pssh, schm, or senc atoms), subtitles in tx3g or wvtt tracks, or codecs outside the player’s capabilities (VP9, AV1, H.265 High 10 profile). The avcC or hvcC atom inside the track’s stsd box contains the codec configuration; a player that cannot parse this configuration will reject the file even if the container is valid.

Repair Based on Diagnosis

Storage Failure: Extract Surviving Data

A drive with bad sectors produces files with zeroed blocks or repeated byte patterns. No software can reconstruct the original video data from zeroes. Your only option is to extract any undamaged portion of the stream:

# Use ffmpeg to ignore errors and copy the decodable portion
ffmpeg -err_detect ignore_err -i corrupt.mp4 -c copy recovered.mp4

Set -err_detect ignore_err only for diagnostic extraction. The output will likely be shorter than the original and may have visible artifacts or audio gaps. If the file is completely unparseable (no ftyp or zero-length file), the data is unrecoverable.

Structural Damage: Rebuild the moov Atom

When moov is missing but mdat is present, tools like untrunc (for AVC/H.264) or recover_mp4 can reconstruct atom headers by scanning the raw bitstream for frame boundaries. These tools require a reference MP4 recorded with the exact same camera or encoder settings to generate a valid moov template.

General remux attempts without a reference file:

# Attempt remux without re-encoding
ffmpeg -i corrupt.mp4 -c copy -movflags +faststart repaired.mp4

If ffmpeg refuses to read the file, try mp4box:

mp4box -add corrupt.mp4 -new repaired.mp4

mp4box will attempt to parse any valid tracks and rebuild the atom hierarchy. If it fails, the structural damage is too severe for automatic repair.

Unsupported Feature: Remux to a Compatible Profile

For fragmented MP4 (moof atoms) or rare brand extensions, remux to a standard isom profile:

ffmpeg -i fragmented.mp4 -c copy -f mp4 -movflags +faststart -brand isom output.mp4

This does not re-encode the video; it rewrites the container structure. If the player still rejects the file, the underlying codec is the actual unsupported feature. In that case, re-encode to a baseline profile:

ffmpeg -i input.mp4 -c:v libx264 -profile:v baseline -c:a aac output.mp4

Hard Limits on Repairability

Not every MP4 file can be repaired. Stop and accept data loss when any of these conditions are true:

  • Zero-length or single-byte files: no data to salvage.
  • Files with overwritten mdat: if the file was truncated and then appended with unrelated data, the video frames are gone. Any repair produces garbage.
  • Files encrypted with DRM schemes (CENC, SAMPLE-AES, or pssh atoms present): the atoms are structurally valid but the sample data is ciphertext. Only the original license key can decrypt it.
  • Missing moov with complex codecs: HEVC, AV1, or H.264 High profile with B-frames cannot be reliably reconstructed from raw bitstreams without a reference file from the identical encoder.
  • Atom size fields that form circular references or point to negative offsets: these indicate intentional corruption or severe bit-flip damage that manual hex editing cannot resolve.