WebM
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.
What can go in a WebM
Section titled “What can go in a WebM”| Type | Allowed |
|---|---|
| Video | VP8, VP9, AV1 |
| Audio | Vorbis, Opus |
| Subtitles | WebVTT |
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.
| Relationship | Project or format | Evidence and scope | Status |
|---|---|---|---|
| Carried By by | AV1 | AV1-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 mappings | Common Implementation |
| Carried By by | Opus | Opus is one of the audio codecs listed by the WebM Project.Scope: Container Mapping · Sources: WebM container guidelines | Documented |
| Carried By by | VP8 | WebM's documented codec subset includes VP8.Scope: Container Subset · Sources: WebM container guidelines | Documented |
| Carried By by | VP9 | WebM's documented codec subset includes VP9.Scope: Container Subset · Sources: WebM container guidelines | Documented |
Encode to WebM
Section titled “Encode to WebM”ffmpeg -i input.mkv -c:v libvpx-vp9 -crf 32 -b:v 0 -row-mt 1 -c:a libopus -b:a 128k output.webmffmpeg -i input.mkv -c:v libsvtav1 -crf 32 -c:a libopus -b:a 128k output.webmSee 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.
Subtitles
Section titled “Subtitles”WebM only carries WebVTT. Convert SRT during muxing:
ffmpeg -i input.mkv -i subs.srt -map 0 -map 1 -c copy -c:s webvtt output.webmWebVTT 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.
Browser support
Section titled “Browser support”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.
Pitfalls
Section titled “Pitfalls”- 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 1for live streams and-dash 1for WebM DASH segments; a normal file needs neither.