Inside a MP4 File: Signature, Structure and MIME Type

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

Learn how MP4 is identified and what its internal components mean.

Binary Identification: The MP4 Signature

An MP4 file announces its format through a fixed file signature in the first eight bytes. The sequence 00 00 00 18 66 74 79 70 is the most common opening, where bytes 4–7 decode to the ASCII string ftyp. This identifies the File Type Box, which the ISO Base Media File Format specification requires as the first box in every conformant MP4.

A secondary signature pattern, 00 00 00 14 66 74 79 70, appears in files using a more compact box header, but the ftyp identifier remains constant across both variants. If a hex dump shows anything other than ftyp at offset 4, the file is either corrupted, mislabeled with an .mp4 extension, or belongs to an entirely different format. The Library of Congress confirms this requirement in its MP4 format description (LOC FDD000155).

Validation Check

Open the file in any hex editor. Confirm that bytes 4–7 read 66 74 79 70 (ASCII ftyp). Absence of this string at that exact offset is a hard failure for MP4 identification, regardless of what the file extension claims.


Box Architecture: The ISO Base Media File Format

MP4 inherits its structure from the ISO Base Media File Format (ISO/IEC 14496-12), which organizes all data into boxes (historically called atoms). Every box shares a common header:

  • 4-byte size (big-endian unsigned integer): the total byte length of the box, including the size field itself.
  • 4-byte type (ASCII-encoded): a four-character identifier such as moov, mdat, or moof.
  • Payload: box-specific data, which may contain nested sub-boxes.

Boxes nest recursively. A parser must walk the hierarchy by reading each box's size, consuming that many bytes, and then examining the next box at the resulting offset. The format imposes no global index; the structure is discovered entirely through sequential traversal.


Critical Top-Level Boxes

ftyp — File Type Box

The ftyp box must occupy the first position in the file. It declares a major brand (typically isom for ISO Base Media, mp42 for MP4 version 2, or avc1 for AVC-encoded content) and a minor version integer. The major brand signals which specification the file claims conformance to. A player that recognizes only isom may reject a file branded mp42, even though both are valid MP4 containers. The ftyp box also lists compatible brands — additional four-character codes that a parser can check to determine whether it supports the file.

moov — Movie Box

The moov box is the metadata container for the entire presentation. It holds:

  • mvhd (Movie Header): timescale, duration, and playback rate.
  • trak (Track Box): one per stream (video, audio, subtitle). Each trak contains an mdia (Media Box) and an stbl (Sample Table Box).
  • stbl: maps decoding timestamps and composition offsets to byte ranges inside the mdat box. Without a valid stbl, a player cannot locate individual frames.

The position of moov within the file directly affects streaming behavior. When moov precedes mdat, a player can begin playback after downloading only the metadata. When moov follows mdat, the player must download the entire file before it can parse the sample tables and start decoding.

mdat — Media Data Box

The mdat box stores the actual encoded media: compressed video frames (H.264, H.265, AV1), audio samples (AAC, MP3, Opus), and timed text. It is typically the largest box in the file. Its internal layout has no self-describing structure — only the stbl entries in moov define which byte ranges correspond to which samples. If the moov box is missing or damaged, the mdat payload becomes opaque and unplayable.


MIME Type and Server Configuration

The IANA-registered MIME type for MP4 is video/mp4 (RFC 4337). Three variants appear in practice:

MIME Type Context Risk
video/mp4 Files containing at least one video track Correct for HTML5 <video> elements
audio/mp4 Audio-only files (commonly .m4a) Browsers may suppress video player UI
application/mp4 Legacy deployments, fragmented MP4 Often triggers a download prompt instead of inline playback

When a server delivers an MP4 with application/octet-stream or a missing Content-Type header, browsers default to downloading the file rather than streaming it. The LOC reference designates video/mp4 as the preferred type for any file that includes a video track. Server configuration must set this header explicitly; relying on extension-to-MIME mappings alone can produce the wrong type for .m4a or .mp4 files with audio-only content.


Fragmented MP4: The moof-Based Structure

A standard MP4 places all metadata in a single moov box. Fragmented MP4 (defined in ISO/IEC 14496-12, Amendment 3) distributes metadata across multiple movie fragment boxes (moof), each paired with a corresponding mdat segment. A final Movie Fragment Random Access box (mfra) at the end of the file provides an index for seeking.

This design enables:

  • Live streaming: fragments can be written and served as they are produced.
  • Reduced startup latency: the initial moov is small, and playback can begin after the first moof/mdat pair arrives.
  • Adaptive bitrate delivery: each fragment can reference a different quality level.

To identify a fragmented MP4, look for a moof box anywhere after ftyp. If moof appears and the file lacks a traditional moov before mdat, the file uses fragmentation. Tools such as ffprobe report this structure explicitly. Many desktop players (VLC, MPC-HC) handle fragmented files, but some embedded hardware decoders and older browser versions do not. Compatibility testing against the target playback environment is necessary before deploying fragmented MP4.


Structural Limits and What Boxes Cannot Guarantee

The box hierarchy describes container layout, not content validity. Several hard limits and blind spots exist:

  • Codec support: a file may pass all structural checks but contain H.265 video that a given decoder cannot process. The ftyp brand identifies the container, not the codecs within the trak boxes. Codec identification requires parsing the sample description entries inside stbl.
  • moov placement: the specification permits moov at the start, middle, or end of the file. Players that require moov before mdat will fail on structurally valid files where moov appears later. This is a player limitation, not a format violation.
  • Corruption scope: a damaged stbl box can produce a file that opens and displays a duration but seeks erratically or crashes during playback. Top-level box sizes may appear correct while internal sample offsets are garbage.
  • Trailing data: the specification states that a conformant MP4 must contain no bytes outside a box. Any data between the end of one box and the start of the next, or after the final box, renders the file non-compliant.

Manual Box Traversal Procedure

When automated tools are unavailable, a hex editor provides direct verification of box structure:

  1. Open the file and read bytes 0–3 as a 32-bit big-endian integer. This is the size of the first box.
  2. Read bytes 4–7 as ASCII. This is the box type.
  3. Advance to the offset given by the size value. The next box begins at that position.
  4. Repeat until the end of the file.

For a typical MP4, the first box decodes to size 32 (0x00000020), type ftyp. The second box starts at byte 32. If the sum of all box sizes does not equal the total file size, the file is truncated or contains extraneous data. Any discrepancy indicates a non-conformant file, regardless of whether a player tolerates it.