# WebM

Canonical URL: https://encode.wiki/containers/webm/
Content version: ca42e61ede0a24f789d7287a0001244ad22f4abf
Status: current
License: CC BY-SA 4.0
Checksum (SHA-256): cbf32df80b36bb17b1945998f9d48c0a3247834f2ca18db6d1e2d9eea2393f55

WebM is [Matroska](/containers/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](/containers/mp4/). Every WebM file is valid Matroska, but not every Matroska file is WebM.

## 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.

**Codecs documented for WebM on this wiki**

| Relationship | Project or format | Evidence and scope | Status |
| --- | --- | --- | --- |
| Carried By by | [AV1](/codecs/video/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](https://www.webmproject.org/docs/container/), [Matroska codec mappings](https://www.matroska.org/technical/codec_specs.html). | Common Implementation |
| Carried By by | [Opus](/codecs/audio/opus/) | Opus is one of the audio codecs listed by the WebM Project. Scope: Container Mapping. Sources: [WebM container guidelines](https://www.webmproject.org/docs/container/). | Documented |
| Carried By by | [VP8](/codecs/video/vp8/) | WebM's documented codec subset includes VP8. Scope: Container Subset. Sources: [WebM container guidelines](https://www.webmproject.org/docs/container/). | Documented |
| Carried By by | [VP9](/codecs/video/vp9/) | WebM's documented codec subset includes VP9. Scope: Container Subset. Sources: [WebM container guidelines](https://www.webmproject.org/docs/container/). | Documented |

[Open the complete typed relationship catalog](/api/v1/catalog.json).

## Encode to WebM

```sh
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](/codecs/video/vp9/), [AV1](/codecs/video/av1/) and [Opus](/codecs/audio/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

WebM only carries WebVTT. Convert SRT during muxing:

```sh
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](/codecs/subtitles/webvtt/) page.

## 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](https://caniuse.com/webm) and [AV1](/codecs/video/av1/) for current status.

## 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 1` for live streams and `-dash 1` for WebM DASH segments; a normal file needs neither.
