WebM

On this page 7

WebM is an open, royalty-free media container format designed for video on the web. Among video containers & formats, it is a deliberately restricted profile of Matroska (MKV) that allows only a small set of codecs: VP8, VP9 or AV1 for video and Vorbis or Opus for audio.

The format was introduced in 2010 to give browsers a common video format that could be implemented without patent licensing fees. Because WebM limits the choice of codecs, any compliant player knows in advance what it must decode, which makes playback in browsers predictable.

How the WebM container is structured

A WebM file uses the EBML structure inherited from Matroska. EBML, the Extensible Binary Meta Language, stores data as nested elements, each with an identifier, a size and a payload, much like a binary version of XML. Players can skip unknown elements, which keeps the format extensible and robust.

The main element is the Segment, which contains everything about one presentation. Inside it, a small number of top-level elements describe the tracks, hold the media data and enable seeking.

ElementContentPurpose
EBML headerDocType set to webm, versionIdentifies the file as WebM
Segment infoDuration, timecode scale, titleGlobal presentation metadata
TracksCodec IDs and codec settingsDeclares video and audio streams
ClusterBlocks of compressed frames with timestampsCarries the actual media data
CuesIndex of keyframe positionsFast seeking
TagsOptional descriptive metadataTitles, languages, custom fields
Main elements of a WebM file

Media frames are stored in SimpleBlock or BlockGroup elements inside clusters. A cluster normally starts at a keyframe, so a player that jumps into the middle of a file can begin decoding cleanly at the next cluster boundary.

Codecs allowed in WebM

WebM permits only royalty-free codecs, and this restriction is the main difference from general-purpose containers. A file that contains H.264 video or AAC audio is not a valid WebM file, even if it uses the same EBML structure.

CodecTypeIntroducedTypical role
VP8Video2010Legacy content, early WebRTC
VP9Video2013HD and 4K web video, HDR
AV1Video2018Most efficient royalty-free video
VorbisAudio2000sOriginal WebM audio
OpusAudio2012Speech and music, low latency
Codecs permitted by the WebM specification

In current practice, VP9 or AV1 with Opus is the usual combination. VP9 offers efficiency close to H.265, while AV1 typically compresses further at a higher encoding cost. Opus is flexible across bitrates from roughly 6 kbps for speech to 256 kbps or more for stereo music.

WebM can also carry WebVTT subtitles and supports an alpha channel with VP8 and VP9, which allows transparent video overlays in browsers, a feature that MP4 lacks in most browser implementations.

WebM compared with MP4, MKV and MOV

WebM is best understood as a narrow, web-focused subset of a broader family of containers. The comparison below shows where it fits.

ContainerBasisCodec flexibilityMain strength
WebMMatroska subsetRoyalty-free codecs onlyOpen web playback
MKVMatroskaAlmost any codecArchiving, many tracks
MP4ISO base media file formatWide, incl. H.264, H.265, AV1Universal device support
MOVQuickTime file formatWide, incl. ProResProfessional editing
Fragmented MP4ISO base media file formatWideAdaptive streaming segments
WebM and neighboring container formats

Every WebM file is structurally a valid Matroska file, so MKV players open it without trouble, but the reverse is not true. Converting between WebM and MKV with compatible codecs is a simple remuxing operation that rewrites the container without re-encoding the media. Moving from MP4 with H.264 to WebM, by contrast, requires transcoding because the codecs themselves change.

Browser support and streaming use

WebM is supported natively in Chrome, Firefox, Edge and Opera, and modern versions of Safari play WebM with VP9 and Opus on most platforms. Support for AV1 in WebM depends on hardware decoding or software decoders in the browser and operating system, so older devices may fall back to VP9 or MP4.

For adaptive streaming with MPEG-DASH, WebM files can be prepared as separate audio and video representations with cue indexes, so a player can request byte ranges at different quality levels. WebRTC also uses VP8, VP9 and Opus, which is why recordings of browser-based calls are often saved directly as WebM.

A common delivery pattern is to offer both WebM and MP4 sources in the HTML video element and let the browser select the first one it can play. This covers older Apple devices while still giving other browsers the smaller royalty-free file.

Practical choices and pitfalls

Choosing WebM is mainly a decision about licensing, browser reach and encoding time. The table summarizes typical cases.

ScenarioRecommended choiceReason
Website background or product videoWebM with VP9, MP4 fallbackSmall files, broad support
Transparent animated overlayWebM with VP9 and alphaAlpha channel in browsers
Browser call recordingWebM with VP8 or VP9 and OpusMatches WebRTC output
Broadcast or editing masterMOV or MXF insteadProfessional codecs needed
Smart TV and set-top deliveryMP4 or MPEG-TS insteadWider hardware support
When WebM is a good fit
  • Missing cues make seeking slow or impossible; live recordings often need a remux to add an index.
  • Unknown duration is common in files recorded by browsers, so players may show an incorrect length until the file is finalized.
  • Slow AV1 encoding can make AV1 impractical for quick turnarounds without hardware encoders.
  • Editing software support for WebM is weaker than for MP4 or MOV, so many editors convert WebM before cutting.

Stripped to the essentials

A video file is like a shipping box that holds the picture and the sound. WebM is one particular kind of box, designed for websites. It only accepts a few kinds of contents, all of which are free to use without paying license fees.

Because the rules are strict, web browsers know exactly what to expect when they open a WebM file. The result is small, free and widely playable video for the web, although some editing programs and older devices still prefer the more common MP4 box.

Where it is applied

An online retailer wants a looping 12-second background video on its home page. The original clip is a 1080p ProRes file of about 300 megabytes, far too large for a page that must load quickly on phones.

The web team encodes two versions: WebM with VP9 at about 1.5 Mbps and an MP4 fallback with H.264 at about 2.5 Mbps, both without audio. The WebM file is roughly 2.2 megabytes and the MP4 roughly 3.7 megabytes. The page lists the WebM source first, so most visitors receive the smaller file, while older devices fall back to MP4. Page weight drops noticeably and the loop looks the same on both versions.