File types · Explainer

The MP4 file (.mp4)

An MP4 file is a container that holds video, audio and the information a player needs to keep them in sync. This guide explains what's inside one, why the same .mp4 plays on one device and not another, the quirks worth knowing, and has free sample MP4 files to download for testing.

At a glance

Full name
MPEG-4 Part 14 (MP4 file format)
Extensions
.mp4; also .m4v (video) and .m4a (audio only)
MIME type
video/mp4; audio/mp4 for audio-only files
Kind
Binary container: holds compressed video and audio, it doesn't compress anything itself
Standard
ISO/IEC 14496-14, built on the ISO base media file format (ISO/IEC 14496-12), which grew out of Apple's QuickTime format
First released
2003 as Part 14 of MPEG-4; an earlier version was part of MPEG-4 Part 1 (1999)
Common codecs
Video: H.264, H.265 (HEVC), AV1. Audio: AAC
Opens with
Every current web browser, phones, VLC, QuickTime Player, the Windows Media Player app
Magic number
66 74 79 70 (ftyp) at byte 4, after the 4-byte size of the first box
Maximum size
No practical limit: boxes can use 64-bit sizes, so files over 4 GB are normal

The basics

What is an MP4 file?

MP4 is the standard file format for video. Android phones and most cameras record into it (iPhones use the closely related MOV), editing apps export to it, and every current browser, TV and phone can play it. A single MP4 file can hold several streams side by side: usually one video track and one audio track, sometimes extra audio languages, subtitles, chapters and cover art, plus metadata such as the title and the date it was recorded.

The key idea is that MP4 is a container, not a way of compressing video. The container organises the streams and records the timing. The compression is done by a codec: H.264, H.265 or AV1 for the pictures, usually AAC for the sound. The .mp4 extension says which container is used. It doesn't say which codecs are inside, and that explains most MP4 problems.

An analogy

Think of the MP4 file as a ring binder and the codecs as the language the pages are written in. Every player can open the binder; a player can only read the pages if it knows that language.

Anatomy

What's inside an MP4 file

An MP4 file is a sequence of boxes (QuickTime calls them atoms). Each box starts with 4 bytes giving its size and 4 letters giving its type, and some boxes contain other boxes. Here is the box tree of sample-720p-h264-aac.mp4, our 10-second sample, as read from the file. Offsets and sizes are in bytes; a few boxes in the audio track are left out to save space.

sample-720p-h264-aac.mp4 (box tree)
offset      size        box
0           32          ftyp   file type
                               00 00 00 20 66 74 79 70 69 73 6F 6D 00 00 02 00
                               69 73 6F 6D 69 73 6F 32 61 76 63 31 6D 70 34 31
32          12,235      moov   the index
40          108           mvhd   movie header: timescale, duration
148         5,042         trak   track 1: video
156         92              tkhd   1280×720, display matrix
248         36              edts   edit list
284         4,906           mdia
292         32                mdhd   media timescale and duration
324         45                hdlr   handler type "vide"
369         4,821             minf
433         4,757               stbl   sample table
441         193                   stsd   sample entry "avc1" (H.264 High)
634         24                    stts   timing: 300 frames, equal length
658         36                    stss   5 keyframes
694         2,024                 ctts   display offsets (B-frames)
2,718       40                    stsc   frames per chunk
2,758       1,220                 stsz   size of every frame
3,978       1,212                 stco   where each chunk starts
5,190       6,761         trak   track 2: audio
5,366       45                hdlr   handler type "soun"
5,479       126                   stsd   sample entry "mp4a" (AAC-LC)
11,951      316           udta   title, artist, comment
12,267      8           free   empty filler box
12,275      1,184,494   mdat   the media: H.264 and AAC frames
  1. 100 00 00 20

    The box size

    Every box begins with its own length as a 32-bit big-endian number, here 0x20 = 32 bytes. A reader skips a box it doesn't understand by jumping that many bytes ahead, which is how the format stays extensible. A size of 1 means a 64-bit size follows, for boxes over 4 GB.

  2. 266 74 79 70 (ftyp)

    The file type box

    Normally the very first box. Its type, ftyp, sits at byte 4, which is why file-type detectors look there rather than at byte 0. There's no fixed signature before it, because the size in bytes 0 to 3 varies.

  3. 3isom … iso2 avc1 mp41

    The brands

    A major brand (isom) and a list of compatible brands, which say which specifications the file follows. avc1 signals H.264 video. Apple's .m4a and .m4v files use brands such as M4A and M4V .

  4. 4moov

    The movie box: the index

    Everything about the content except the content itself: duration, tracks, codecs, and tables that say where every frame is. A player needs moov before it can play anything. Here it sits near the start, because the file was written with faststart.

  5. 5trak / tkhd

    A track

    One trak per stream: this file has a video track and an audio track. The track header holds the display size and a transformation matrix, which is how a phone marks a video as rotated without re-encoding it.

  6. 6stsd: avc1, mp4a

    The sample description: which codec

    Names the codec of each track and carries its setup data. avc1 is H.264, hvc1 or hev1 is H.265, av01 is AV1 and mp4a is AAC. This is the line that decides whether a device can play the file.

  7. 7stts, stss, stsz, stco

    The sample tables

    Timing for each frame, which frames are keyframes (a player can only start decoding at one), the byte size of every frame and where each chunk of frames starts in the file. Seeking is a lookup in these tables.

  8. 8udta

    Metadata

    Title, artist and a comment in Apple-style tags (©nam, ©ART, ©cmt). Phones also store things like the recording location in metadata boxes like this one.

  9. 9free

    Filler

    A box that readers skip. FFmpeg writes this 8-byte one in front of mdat so it can become a 64-bit size header if the media grows past 4 GB. Other tools use free boxes to leave room for editing metadata in place.

  10. 10mdat

    The media data

    The compressed video and audio frames, interleaved, with no structure of their own. Without the tables in moov, this 1.2 MB of data can't be decoded, which is why a recording cut off before moov was written won't open.

Codecs

Container vs codec: H.264, H.265 and AV1

Video codecs trade file size against how much work it takes to decode. Newer codecs make smaller files at the same quality, but older devices can't decode them, or can only do so without hardware help, which drains batteries and drops frames.

The codecs you're most likely to find in an MP4 file
CodecTrack typeCode in the fileWhere it plays
H.264 / AVC (2003)Videoavc1Everywhere: every current browser, phone, TV and editor. The safe choice.
H.265 / HEVC (2013)Videohvc1 or hev1Apple devices and Safari. Other browsers mostly only where the device has a hardware decoder. Designed to need about half the bit rate of H.264 for similar quality.
AV1 (2018)Videoav01Chrome, Edge and Firefox. Safari only on devices with an AV1 hardware decoder (M3 Macs and later, iPhone 15 Pro and later). Royalty-free.
AACAudiomp4aEverywhere. The default audio for MP4.
MP3, Opus, FLACAudiomp4a, Opus, fLaCAllowed in MP4 and supported by most browsers, but less common.
AC-3, E-AC-3 (Dolby Digital)Audioac-3, ec-3Common in files from TV and streaming sources. Many browsers can't decode it, so the video plays silently.

Two things in that table catch people out. iPhones record in HEVC by default in their high-efficiency setting, so a video that's fine on the phone can show a black picture with sound in another browser. And Apple players only accept HEVC tagged hvc1; the same video tagged hev1 may not play in Safari or QuickTime, even though it's valid. Our sample-hevc.mp4 uses hvc1.

Which codecs are in my file?

Run ffprobe yourfile.mp4 (part of FFmpeg) or open the file in VLC and choose Tools → Codec Information. On a Mac, QuickTime Player shows it under Window → Show Movie Inspector.

Under the hood

The moov atom and faststart: why some MP4s won't stream

A recording app doesn't know how long a video will be or where each frame will land until it stops recording. So it writes the frames (mdat) first and the index (moov) last, at the end of the file. That works on a disk, where a player can read the end straight away. Over the web it's a problem: a player that reads the file from the start can't play anything until it reaches the index.

  • moov at the end: the browser has to fetch the end of the file first, using an extra HTTP range request, before playback starts. If the server doesn't support range requests, the whole file downloads first.
  • moov at the start (faststart): the index arrives first, so the video starts as soon as the first frames arrive, and seeking can jump straight to the right bytes.

Moving moov to the front doesn't touch the video itself, so it takes seconds and loses nothing. With FFmpeg: ffmpeg -i input.mp4 -c copy -movflags +faststart output.mp4. Most video editors have a matching option called "optimise for web", "web optimised" or "fast start".

Fragmented MP4

Streaming services and live video use a variant called fragmented MP4: a short moov with no frame tables, followed by many small moof + mdat pairs, each describing a few seconds. Players can start anywhere, and a file can grow while it's being watched. It's the format behind most HLS and DASH streaming.

Related formats

MP4 vs MOV, M4V, WebM and MKV

FormatWhat it isWhen you'll meet it
.mp4MPEG-4 Part 14 container.The default for sharing and the web.
.movApple's QuickTime container, the ancestor of MP4. Same box structure, more codec options (ProRes, for example).iPhone and Mac recordings, editing workflows. A .mov with H.264 inside can often be renamed to .mp4 and played, but remuxing is the proper fix.
.m4vApple's variant of MP4. Videos bought from Apple may use its FairPlay copy protection and only play in Apple apps.Exports from Apple apps and the iTunes Store.
.m4aAn MP4 container with only audio, usually AAC.Music, voice memos.
.webmA container based on Matroska, limited to royalty-free codecs (VP8, VP9, AV1, Vorbis, Opus).Web video, screen recordings in browsers.
.mkvMatroska: a flexible container that holds almost any codec and many subtitle and audio tracks.Downloaded films and archiving. Browsers mostly don't play it.

Changing between containers without touching the codecs is called remuxing. It's fast and lossless: ffmpeg -i input.mov -c copy output.mp4. It only works if the target container supports the codecs inside.

Troubleshooting

Why won't my MP4 play? Common problems and fixes

SymptomUsual causeFix
Sound but black picture, or "unsupported format"The video codec isn't supported on this device, usually HEVC or AV1.Re-encode to H.264: ffmpeg -i in.mp4 -c:v libx264 -crf 20 -c:a copy out.mp4.
Picture but no soundThe audio codec isn't supported, often AC-3 or E-AC-3.Re-encode only the audio to AAC: -c:v copy -c:a aac.
Won't play until fully downloadedmoov is at the end of the file.Remux with -movflags +faststart.
"moov atom not found", file won't open at allRecording stopped before the index was written (battery died, app crashed, upload cut off).Copy the file again if it was a transfer. For a broken recording, repair tools rebuild moov using a good file from the same camera as a template.
Sideways or upside-down videoThe frames are stored landscape with a rotation flag, and the app ignores the flag.Use a player that respects it, or bake the rotation into the frames by re-encoding.
Huge fileHigh bit rate from a camera or screen recorder.Re-encode with a quality setting (-crf 23 for H.264) instead of a fixed high bit rate.

How to

How to open, edit and convert an MP4 file

  • Windows: double-click to open in the Media Player app. Clipchamp, included with Windows 11, trims and edits.
  • macOS: QuickTime Player opens it and can trim (Edit → Trim). iMovie edits.
  • Linux: VLC or mpv, both of which also handle codecs the built-in players don't.
  • Phone: iPhone and Android open MP4 in their gallery or files apps.
  • Browser: drag the file into a browser window, or put it online and it plays in a <video> element.
  • Convert or fix it: FFmpeg does almost anything from the command line; HandBrake is a free app for re-encoding to H.264 or H.265 with presets.

Copy before you convert

Re-encoding always loses a little quality, so convert from the original rather than from an earlier conversion. Remuxing with -c copy (changing the container, or moving moov) loses nothing.

Security

Is an MP4 file safe? Privacy and security

An MP4 file can't run code by itself the way a document with macros can. The risks are elsewhere:

  • Location metadata. Videos recorded on phones often store the GPS position where they were shot, plus the device model and recording time. Check before you publish a video taken at home: ffprobe lists the tags, and ffmpeg -i in.mp4 -map_metadata -1 -c copy out.mp4 drops them without re-encoding.
  • Bugs in video decoders. Parsing a complex binary format is hard, and media libraries have had serious flaws that a crafted video could trigger; the 2015 Stagefright bugs in Android are the best-known case. Keep your operating system, browser and players updated.
  • Fake videos. A file named video.mp4.exe is a program, not a video. Windows hides known extensions by default, so turn on "File name extensions" in File Explorer's View menu.

Free downloads

Sample MP4 files to download

Free sample MP4 files for testing players, uploads, transcoding pipelines and browser codec support. All are made from FFmpeg test patterns and generated tones, with the format written on screen. Each was checked with ffprobe and fully decoded without errors.

sample-720p-h264-aac.mp4 · 1.1 MBDownloadOpen

What's inside sample-720p-h264-aac.mp4

A 10-second, 1280×720 video at 30 fps: H.264 High profile video, AAC stereo audio, written with faststart. Everything on screen is there to help you test something.

  1. The label

    The bottom band shows the resolution, frame rate and codecs, so you can see at a glance if a pipeline changed something.

  2. Timecode and frame counter

    Burned into the top of each frame. If a player skips or repeats frames, the counter shows it.

  3. The flash and the beep

    A white square flashes in the top right for 3 frames on every whole second, in step with a 1 kHz beep on both channels. If they drift apart, audio and video are out of sync.

  4. Stereo test tones

    A steady 440 Hz tone on the left channel and 660 Hz on the right, so swapped or mixed-down channels are easy to hear.

  5. The moving pattern

    FFmpeg's testsrc2 pattern has colour bars and moving elements, which show compression artefacts and dropped frames.

  6. Faststart layout

    moov is at byte 32, before the media data, so the file starts playing as soon as it starts downloading.

  7. Metadata

    Title, artist and a comment naming this page, stored in the udta box. Run ffprobe on it to see them.

All sample MP4 files

  • 720p H.264 + AAC (faststart)

    sample-720p-h264-aac.mp4 · 1.1 MB (1,196,769 bytes)

    10 seconds at 1280×720, 30 fps. H.264 High profile with AAC-LC stereo at 128 kbps, moov at the start. Plays everywhere.

    • Checking a player, host or upload form handles standard MP4
    • Audio/video sync and channel tests
  • H.265 / HEVC

    sample-hevc.mp4 · 154.4 KB (158,135 bytes)

    4 seconds at 640×360, HEVC Main profile tagged hvc1 (the tag Apple players need), with AAC audio.

    • Testing whether a browser or device decodes HEVC
    • Transcoding pipelines that receive iPhone video
  • AV1

    sample-av1.mp4 · 183.8 KB (188,244 bytes)

    4 seconds at 640×360, AV1 Main profile with AAC audio, encoded with SVT-AV1.

    • Testing AV1 support, especially in Safari
    • Checking thumbnailers and transcoders handle AV1
  • moov at the end (no faststart)

    sample-moov-at-end.mp4 · 157.2 KB (160,996 bytes)

    4 seconds at 640×360, H.264 + AAC, written without faststart: ftyp, then mdat, then moov at the very end.

    • Testing progressive playback and range-request support
    • Checking a faststart fix in an upload pipeline
  • Portrait video with rotation metadata

    sample-rotated-portrait.mp4 · 152.5 KB (156,110 bytes)

    Frames stored as 640×360 landscape, with a 90° rotation in the track's display matrix, like a phone video. Players that respect it show an upright 360×640 portrait video with readable text.

    • Catching "sideways video" bugs in players and thumbnailers
    • Testing that width and height are read after rotation
  • 1 MB MP4 file

    sample-1mb.mp4 · 1 MB (1,048,576 bytes)

    15 seconds at 640×360, H.264 + AAC, with faststart, padded with a trailing free box to exactly 1,048,576 bytes (1 MiB). Players ignore the padding.

    • Upload and size-limit tests
    • Timeouts and progress bars

Ways to test with them

  • Codec support: open sample-hevc.mp4 and sample-av1.mp4 in the browser or device you care about. A black picture, an error or no playback means that codec isn't supported there.
  • Faststart: in your browser's developer tools (Network tab), compare loading the featured file with sample-moov-at-end.mp4: the second needs an extra range request for the end of the file before it can play.
  • Rotation: sample-rotated-portrait.mp4 should appear upright and taller than it is wide. If the text runs sideways, the player or thumbnail generator ignores the display matrix.
  • Sync: in the featured file, the white square and the beep should coincide on every second.
  • Upload limits: sample-1mb.mp4 is exactly 1 MiB, so you can test a limit at the boundary.

Free to use for testing, teaching and demos, commercially or not, with no attribution needed. A link back to this page is always appreciated.

Put it online

Have an MP4 file? Give it a link.

Drop an MP4 on 99helpers and it gets its own address that plays in the browser, on any device, without an app or a sign-in. Send the link instead of a large attachment.

Questions

MP4 files, frequently asked

What does MP4 stand for?

MPEG-4 Part 14. MPEG is the Moving Picture Experts Group, the ISO/IEC committee that wrote the standard, and Part 14 is the section of the MPEG-4 standard that defines the file format.

Is MP4 a codec?

No. MP4 is a container that holds video and audio streams compressed with codecs such as H.264, H.265, AV1 and AAC. Two MP4 files can use completely different codecs.

Why does my MP4 play on my phone but not on my computer?

Usually the video is in HEVC (H.265), which many phones record by default and some browsers and computers can't decode. Converting it to H.264 makes it play everywhere.

What's the difference between MP4 and MOV?

MOV is Apple's QuickTime format, and MP4 was based on it, so the structure is nearly the same. MP4 is the more widely supported choice for sharing. Converting between them is usually a fast remux without re-encoding.

What is the moov atom?

The index of an MP4 file: it lists the tracks, codecs and where each frame is. If it's at the end of the file, a video can't start playing until the end has been fetched. Moving it to the start is called faststart.

How do I make an MP4 smaller?

Re-encode it with a quality-based setting, for example ffmpeg -i in.mp4 -c:v libx264 -crf 26 -c:a aac -b:a 128k out.mp4, or use HandBrake. A lower resolution or HEVC/AV1 makes it smaller still, at the cost of compatibility.

Can an MP4 file contain a virus?

It can't run code by itself, but a crafted file could exploit a bug in a video player, so keep your software updated. Be wary of files ending in .mp4.exe or similar, which are programs.

How big can an MP4 file be?

The format uses 64-bit sizes where needed, so there's no practical limit. Limits come from elsewhere: FAT32 drives can't store a file over 4 GB, and upload services set their own caps.

Related formats

Other file types explained

Keep going

Related

Sources

Last reviewed 27 October 2026.