MP4 MIME Type – Free, Online, Private
video/mp4 is the type for an MP4 movie. The file is ISOBMFF and should carry a codecs parameter when a client has to choose a decoder.
What .mp4 is
An MP4 file is a tree of boxes. It starts with a 4-byte size and the fourcc ftyp, then a list of compatible brands such as isom, mp42, or avc1. The moov box is the index. mdat holds the samples. H.264 video uses the avc1 or avc3 sample entry. H.265 uses hvc1 or hev1. AAC audio uses mp4a. RFC 6381 defines the codecs parameter so a client can refuse a file it cannot decode. video/mp4 with no codecs parameter is still correct. It is just less helpful. A fast-start file has moov before mdat.
IANA registers video/mp4 in RFC 4337 and RFC 6381. The media type is video/mp4. Extensions that use it on this page: .mp4. A client compares the type, not the filename, once the response has arrived. The filename still matters on disk and in Content-Disposition, which is why a wrong extension and a wrong header are two different bugs.
What sends video/mp4
What sends video/mp4: Send video/mp4 for a progressive .mp4 that a video element should play. Add codecs when you know them, for example video/mp4; codecs="avc1.4D401E,mp4a.40.2". Enable byte ranges. Without ranges, seeking downloads the file from the beginning or fails. Do not send video/mp4 for a DASH or HLS media segment unless that packager's client expects it. fMP4 segments are often video/mp4 too, and the playlist next to them is a different type. application/mp4 exists for a general MP4 box that is not specifically audio or video. A movie is video/mp4. The file on disk is still .mp4. Once the response exists, a client trusts video/mp4, not the filename. If you package HLS with MPEG-TS segments, those segments are video/mp2t and the playlist is application/vnd.apple.mpegurl. The .mp4 you give to a video src is a different response. Do not reuse one cache key for the transport stream and the fragmented MP4.
Content-Type for .mp4
Send video/mp4 and do not add a charset parameter. The body is binary. A charset tells a text decoder to reinterpret bytes that are not text, which corrupts a download and does not help a browser sniff the format.
Content-TypeContent-Type: video/mp4
nginx, Apache, and Express
These snippets map .mp4 to video/mp4. nginx reads the types block when it picks a type from the URL's extension. A location that sets default_type, or an application that sets the header itself, overrides that map. Apache AddType applies in the directory context where you put it. The Express static example writes the header for files ending in .mp4 so a stale mime database in the framework cannot disagree with the type on this page.
nginx# /etc/nginx/mime.types, inside the types { } block
video/mp4 mp4;
ApacheAddType video/mp4 .mp4
Expressimport express from "express";
const app = express();
app.use(express.static("public", {
setHeaders(res, filePath) {
if (filePath.endsWith(".mp4")) {
res.setHeader("Content-Type", "video/mp4");
}
},
}));
Pitfalls for video/mp4
Pitfalls that show up for video/mp4, and not for a neighboring type with a similar extension: moov at the end is the classic 'the video will not start' bug. Remux to move moov forward, or honor Range so the player can fetch the tail first. Changing the type does not move the box. A second bug is an HEVC file served as video/mp4 to a browser with no HEVC decoder. The type is honest and the picture still fails. Publish the codecs string and offer an H.264 alternate. A third is a fragmented file with no moov, only moof and mdat, handed to a plain video element. That is a segment, not a progressive file.
- audio-only MP4 should be audio/mp4. video/mp4 on a song opens the wrong UI in some clients.
- The codecs parameter is case-sensitive in practice. avc1 and AVC1 are not interchangeable in canPlayType.
- A file that starts with ftyp is not automatically playable. Encrypted CENC boxes need a CDM.
- Do not gzip the mdat and drop Content-Encoding. The samples are already compressed.
Frequently asked questions
What is the MP4 signature?
Byte 4 is the start of ftyp in a typical file. The first four bytes are the box size. Some files put a free or wide box later, but the beginning is a box header.
Why include codecs?
RFC 6381's codecs parameter lets the browser reject an HEVC or AV1 file it cannot decode before it fetches the body.
How do I make playback start fast?
Put the moov box before mdat, and support Range requests.
Is application/mp4 the movie type?
No. application/mp4 is the general box structure. A movie is video/mp4.