Skip to content

WebM

current

WebM is Matroska restricted to a small royalty-free set of codecs so that every browser can play it. It is what you use for video on the web that is not H.264 and AAC in MP4. Every WebM file is valid Matroska, but not every Matroska file is WebM.

TypeAllowed
VideoVP8, VP9, AV1
AudioVorbis, Opus
SubtitlesWebVTT

Nothing else is allowed: no H.264 or HEVC, no AAC or MP3, no SRT or ASS. FFmpeg’s muxer enforces this and refuses to write the file otherwise (“Only VP8 or VP9 or AV1 video and Vorbis or Opus audio and WebVTT subtitles are supported for WebM”). If you want those streams, use MKV or MP4.

Codecs documented for WebM on this wiki
RelationshipProject or formatEvidence and scopeStatus
Carried By byAV1AV1-in-WebM is implemented in common tools, but the current public WebM codec list does not document it.Scope: Container Mapping · Sources: WebM container guidelines, Matroska codec mappingsCommon Implementation
Carried By byOpusOpus is one of the audio codecs listed by the WebM Project.Scope: Container Mapping · Sources: WebM container guidelinesDocumented
Carried By byVP8WebM's documented codec subset includes VP8.Scope: Container Subset · Sources: WebM container guidelinesDocumented
Carried By byVP9WebM's documented codec subset includes VP9.Scope: Container Subset · Sources: WebM container guidelinesDocumented
Terminal window
ffmpeg -i input.mkv -c:v libvpx-vp9 -crf 32 -b:v 0 -row-mt 1 -c:a libopus -b:a 128k output.webm
ffmpeg -i input.mkv -c:v libsvtav1 -crf 32 -c:a libopus -b:a 128k output.webm

See VP9, AV1 and Opus for encoder settings. If the source is already VP9/AV1 and Opus, a remux is enough: ffmpeg -i input.mkv -c copy output.webm. mkvmerge -o output.webm input.mkv also writes a WebM when the content qualifies.

WebM only carries WebVTT. Convert SRT during muxing:

Terminal window
ffmpeg -i input.mkv -i subs.srt -map 0 -map 1 -c copy -c:s webvtt output.webm

WebVTT inside a WebM is mainly useful for desktop players such as mpv and VLC. For web pages, ship a separate .vtt file referenced with a <track> element, as described on the WebVTT page.

Chrome, Firefox and Edge play every WebM codec, AV1 included (they ship a software AV1 decoder). Safari’s WebM support depends on version and device, and it decodes AV1 only on hardware that has an AV1 decoder (A17 Pro, M3 and later). Check Can I use and AV1 for current status.

  • Do not rename MKV to WebM. A file with H.264 or AAC inside is not a valid WebM and browsers will refuse or mis-handle it.
  • Live or DASH output. FFmpeg’s WebM muxer has -live 1 for live streams and -dash 1 for WebM DASH segments; a normal file needs neither.