.MP4
MPEG-4 Part 14
Introduction
MP4 is the most widely used video file. It is a container: it holds video, audio and subtitle tracks together, with the timing needed to play them in step. The video inside is usually H.264, H.265 or AV1 and the audio usually AAC, but the container itself does not decide the codec.
The format is defined by ISO/IEC 14496-14. It is built on the ISO base media file
format (ISO/IEC 14496-12), which grew out of Apple’s QuickTime format. The same
structure underlies .m4v video, .m4a audio, .mov
and the HEIF and AVIF image formats.
Software
- VLC media player (Windows, macOS, Linux, mobile)
- mpv (Windows, macOS, Linux)
- HandBrake (Windows, macOS, Linux)
- FFmpeg (Windows, macOS, Linux)
- Adobe Premiere Pro (Windows, macOS)
- DaVinci Resolve (Windows, macOS, Linux)
- Shotcut (Windows, macOS, Linux)
- Kdenlive (Windows, macOS, Linux)
- GPAC and MP4Box (Windows, macOS, Linux)
- Bento4 (Windows, macOS, Linux)
Structure
An MP4 file is a sequence of boxes, also called atoms. Each box starts with a 32-bit big-endian size and a four-letter type, and many boxes contain further boxes. A size of 1 means a 64-bit size follows the type, and a size of 0 means the box runs to the end of the file.
Three boxes sit at the top level of every file. ftyp names the brands
the file conforms to. moov holds the description of the whole movie: one
trak per track, each with sample tables that give the size, time and file
position of every frame. mdat holds the encoded frames themselves. A file
with moov before mdat can start playing before it has fully
downloaded. A fragmented MP4, used for streaming, repeats moof and
mdat pairs, each describing a few seconds of media.
0ftyp major brand, version, compatible brandsvaries…moov the movie descriptionvaries…mvhd timescale and duration of the movievaries…trak one per track: header, media info and sample tablesrepeated
…mdat the encoded audio and video samplesvaries