video/mp4 MIME Type — MP4 Video Streaming, Range Requests & Headers
MPEG-4 Part 14. The dominant video container format for web delivery, typically containing H.264 or H.265 (HEVC) video with AAC audio. Universally supported across all browsers, mobile devices, and operating systems.
Used For
- Web video players (<video> element)
- Video streaming
- Video downloads
- Background videos
HTTP Header Example
HTTP/1.1 206 Partial Content
Content-Type: video/mp4
Content-Range: bytes 0-65535/10485760
Accept-Ranges: bytesCode Examples
// Express — stream MP4 with range request support
app.get('/video.mp4', (req, res) => {
const path = './videos/video.mp4'
const stat = fs.statSync(path)
const range = req.headers.range
if (range) {
const [start, end] = range.replace('bytes=', '').split('-')
.map(n => (n ? parseInt(n) : stat.size - 1))
const chunkSize = end - +start + 1
res.writeHead(206, {
'Content-Range': `bytes ${start}-${end}/${stat.size}`,
'Accept-Ranges': 'bytes',
'Content-Length': chunkSize,
'Content-Type': 'video/mp4',
})
fs.createReadStream(path, { start: +start, end }).pipe(res)
} else {
res.writeHead(200, { 'Content-Length': stat.size, 'Content-Type': 'video/mp4' })
fs.createReadStream(path).pipe(res)
}
})Related MIME Types
Frequently Asked Questions
What is the video/mp4 MIME type?
MPEG-4 Part 14. The dominant video container format for web delivery, typically containing H.264 or H.265 (HEVC) video with AAC audio. Universally supported across all browsers, mobile devices, and operating systems.
When should I set Content-Type: video/mp4?
Set Content-Type: video/mp4 on HTTP responses that contain MP4 Video data. Web video players (<video> element).
What file extensions use video/mp4?
Files with video/mp4 content typically use these extensions: .mp4, .m4v.
What happens if I serve this with the wrong Content-Type?
Browsers use the Content-Type header to decide how to handle the response. Serving video/mp4 content with an incorrect MIME type can cause browsers to display it incorrectly, refuse to execute it (scripts), or prompt an unintended download. Modern browsers respect X-Content-Type-Options: nosniff and will not attempt to auto-detect the type.
