WEBM MIME Type – Free, Online, Private
video/webm is the type browsers require for a WebM movie. The file is a Matroska subset that starts with the EBML header.
What .webm is
WebM is a subset of Matroska. The file starts with the EBML header, byte 1A 45 DF A3, and the DocType element is the string webm. Video is VP8, VP9, or AV1. Audio is Vorbis or Opus. A WebM file that uses a codec outside that set is not WebM even if the extension says so. Browsers select a decoder from video/webm and from the codecs parameter, as in video/webm; codecs="vp9,opus". The IANA list's video/VP8 and video/VP9 registrations describe RTP codec media types. They are not what you put on a .webm file response. The container type the video element checks for is video/webm.
Browsers and the WebM container specification use video/webm. The current IANA media-type list registers video/VP8 and video/VP9 for the codecs and does not list a video/webm container type. The media type is video/webm. Extensions that use it on this page: .webm. 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/webm
What sends video/webm: Send video/webm for a .webm file in a video element. Send audio/webm if the file is audio-only, which is a common Opus recording. Mixing those two up makes the element look at the wrong tag. Support Range if you want seeking. The Cues element is the index. A file written by a live muxer may not have Cues until it is finalized, so seeking will not work until you remux. The type does not change when you add Cues. Do not add a charset. EBML is binary. The file on disk is still .webm. Once the response exists, a client trusts video/webm, not the filename. Offer an MP4 alternate for clients that cannot play the codec you chose. Do that with a second source element and a second URL, each with its own type. One URL that content-negotiates between video/webm and video/mp4 needs Vary: Accept and still confuses players that do not re-request when the decoder fails.
Content-Type for .webm
Send video/webm 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/webm
nginx, Apache, and Express
These snippets map .webm to video/webm. 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 .webm 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/webm webm;
ApacheAddType video/webm .webm
Expressimport express from "express";
const app = express();
app.use(express.static("public", {
setHeaders(res, filePath) {
if (filePath.endsWith(".webm")) {
res.setHeader("Content-Type", "video/webm");
}
},
}));
Pitfalls for video/webm
Pitfalls that show up for video/webm, and not for a neighboring type with a similar extension: Serving a full Matroska file, DocType matroska, as video/webm is the rejection you get from a strict browser. Check the DocType. Serving WebM as video/mp4 fails immediately. A second trap is an AV1 WebM file with codecs="vp9". canPlayType will lie and the decode will fail. Read the CodecID from the track. A third is a service worker that caches the opaque response and replays it without the type. Media elements need the type. Store it.
- video/x-matroska is the unofficial type for general MKV. Do not use it for a DocType of webm.
- Alpha-channel VP8 or VP9 is still video/webm. The alpha is a block additional, not a new top-level type.
- A missing Cluster element means the file has a header and no pictures. The type can still be correct.
- Content-Encoding: gzip is rarely worth it. The frames are compressed.
Frequently asked questions
Is video/webm the IANA container registration?
The current IANA media-type list does not show video/webm. It does register video/VP8 and video/VP9. Browsers still require video/webm on a WebM file.
What does the file start with?
The EBML magic 1A 45 DF A3, and a DocType of webm.
When do I use audio/webm?
When the file has audio and no video, typically Opus. A movie stays video/webm.
Which codecs are actually WebM?
VP8, VP9, or AV1 video, and Vorbis or Opus audio. Other codecs belong in a different container and a different type.