DevToolsmith

MP4 MIME Type

video/mp4 is the MIME type for MP4 video. Here is the Content-Type header to send, the file signature, and how to configure servers and code.

MIME type
video/mp4
Extensions
.mp4, .m4v
Content-Type header
video/mp4
Registered
Yes, with IANA
Compress with gzip
No, it is already compressed
Category
Video

About MP4 video files

The most widely supported video format, usually H.264 video with AAC audio. For playback to start before the whole file has downloaded, the index (the moov box) must be at the start of the file: encode with ffmpeg -movflags +faststart. The server must also answer range requests, or seeking won’t work and Safari may refuse to play.

Other types seen for these files: video/x-m4v . Accept them when reading uploads, but send video/mp4 yourself.

File signature

MP4 files start with "ftyp" at byte 4, followed by a brand such as isom, mp42 or avc1. The extension and the type a browser reports for an upload both come from the file name, so check these bytes on the server before trusting a file.

Serve .mp4 with the right Content-Type

Response header
Content-Type: video/mp4
nginx (a line in the types { } block of mime.types)
video/mp4 mp4 m4v;
Apache (.htaccess or server config)
AddType video/mp4 .mp4 .m4v
Caddy
@mp4 path *.mp4 *.m4v
header @mp4 Content-Type "video/mp4"
Check what a server sends
curl -sI https://example.com/file.mp4 | grep -i '^content-type'
# Content-Type: video/mp4

Set the type in code

Node.js (Express)
res.set('Content-Type', 'video/mp4');
// Or make the browser download it:
res.attachment('file.mp4');
Python
import mimetypes

mimetypes.add_type('video/mp4', '.mp4')  # if your system doesn't know it
mimetypes.guess_type('file.mp4')[0]  # 'video/mp4'
Go
mime.AddExtensionType(".mp4", "video/mp4")
w.Header().Set("Content-Type", "video/mp4")

Accept .mp4 uploads

HTML
<input type="file" accept=".mp4,.m4v,video/mp4">

The accept attribute only filters the file picker; users can still choose another file. Listing the extension as well as the type matters, because operating systems don’t always report the type you expect.

Related types

  • .webm (video/webm): WebM video
  • .mov (video/quicktime): QuickTime video
  • .m3u8 (application/vnd.apple.mpegurl): HLS playlist
  • .m4a (audio/mp4): M4A audio

More video

.avi , .mkv , .ts . Look up any extension or type with the MIME type lookup.

Sources

Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.

Frequently asked questions

What is the MIME type for .mp4 files?

video/mp4. You may also see video/x-m4v, which is older or unofficial; send video/mp4. The full header is "Content-Type: video/mp4".

Why does my server send the wrong Content-Type for .mp4?

Web servers pick the type from the file extension using a table (mime.types in nginx and Apache). If .mp4 is missing from that table, they send a default such as application/octet-stream or text/plain. Add the mapping as shown on this page, then check the response with "curl -sI".

How can I check that a file really is MP4?

Look at the first bytes rather than the extension or the type the browser reports, which both come from the file name. MP4 files start with "ftyp" at byte 4, followed by a brand such as isom, mp42 or avc1. The MIME type lookup on this site reads them for you when you drop a file on it.