The basics
What is a WebM file?
WebM is the open video format of the web. Google launched it in 2010, with VP8, a codec it had acquired with On2 Technologies, so that browsers could play video without the patent licences that H.264 needs. Every current browser plays it, YouTube streams many videos in its VP9 and AV1 codecs, browsers record screen and camera captures into it, and many sites use short WebM clips where they used to use animated GIFs.
Technically, WebM is a restricted version of Matroska, the container behind .mkv files. It uses the same building blocks but allows only a few elements and a short list of codecs, all royalty-free: VP8, VP9 and AV1 for video, Vorbis and Opus for audio, and WebVTT for subtitles. That restriction is the point: if a browser supports WebM, it supports everything a valid WebM file can contain.
WebM vs MP4 in one line
MP4 holds H.264 or HEVC, which play on almost every device but carry patent licensing; WebM holds VP9, AV1 or VP8, which are free to use but less supported outside browsers.
Anatomy
What's inside a WebM file
WebM uses EBML, a binary cousin of XML: every element starts with an ID, then its size, then its data, and elements nest inside each other. IDs and sizes are variable-length numbers, so small values take one byte. Here is the element tree of sample-720p-vp9-opus.webm, our 10-second sample, as read from the file. Offsets are in bytes.
offset element ID bytes content
0 EBML header 1A 45 DF A3 31 bytes
21 DocType 42 82 "webm"
28 DocTypeVersion 42 87 4
36 Segment 18 53 80 67 1,225,645 bytes
size field: 01 00 00 00 00 12 B3 AD
48 SeekHead 11 4D 9B 74 where Info, Tracks, Tags, Cues are
113 Void EC 87 bytes kept free
209 Info 15 49 A9 66
214 TimestampScale 1,000,000 ns (1 ms)
300 Duration 10,008 ms
311 Tracks 16 54 AE 6B
317 TrackEntry 1 V_VP9, 1280×720
381 TrackEntry 2 A_OPUS, 48 kHz stereo
479 Tags 12 54 C3 67 title, artist, comment
839 Cluster 1F 43 B6 75 starts at 0 s
846 Timestamp E7 0
849 SimpleBlock A3 track 2: Opus, 20 ms of sound
1,269 SimpleBlock A3 track 1: VP9 keyframe, 28,925 bytes
… 158 more blocks, video and audio interleaved
237,607 Cluster starts at 2.001 s
488,689 Cluster starts at 4.001 s
731,884 Cluster starts at 6.001 s
985,649 Cluster starts at 8.001 s
1,225,590 Cues 1C 53 BB 6B 5 cue points, one per keyframe- 1
1A 45 DF A3The EBML header
Every WebM and Matroska file starts with these four bytes, the ID of the EBML header element. It says which EBML rules the file follows.
- 2
DocType "webm"The document type
The only thing that separates a WebM file from a Matroska file at first glance:
webmhere,matroskain an.mkv. A player that seeswebmcan expect only WebM's short list of codecs. - 3
18 53 80 67 · 01 00 00 00 00 12 B3 ADThe Segment
One big element that holds everything else. Its size is written as an 8-byte number (the leading
01says how long the number is), here 1,225,645 bytes. A recorder that doesn't know the size yet can write "unknown" instead, which is how live streams and browser recordings work. - 4
SeekHead, VoidThe table of contents
The SeekHead lists where the other top-level elements are, so a player can jump to the Cues at the end without reading the whole file. The Void element is empty space the writer kept free in case something needed to grow.
- 5
InfoSegment information
The timestamp scale (1 ms per tick here), the duration and the program that wrote the file. Recordings made in a browser often lack the Duration element, which is why they show no length.
- 6
TracksThe track list
One TrackEntry per stream, with its number, codec ID (
V_VP9,A_OPUS) and settings: picture size for video, sample rate and channels for audio. For transparent video, this is whereAlphaModeis set. - 7
Cluster / TimestampClusters: the media
The audio and video live in Clusters of a few seconds each. Each Cluster has its own starting timestamp, and each block inside stores a small offset from it.
- 8
SimpleBlockA frame
One compressed frame or audio packet, with the track number, its time offset and a flag that marks keyframes. This file has 800: 300 video frames and 500 Opus packets of 20 ms.
- 9
CuesThe seek index
A list of keyframes and where their Clusters start. With it, a player can jump straight to any point; without it, seeking means scanning the file.
Codecs
The codecs inside: VP8, VP9, AV1, Vorbis and Opus
| Codec | Track type | Codec ID | Notes |
|---|---|---|---|
| VP8 (2010) | Video | V_VP8 | The original WebM codec, roughly comparable to H.264. Still used in video calls. |
| VP9 (2013) | Video | V_VP9 | Smaller files than VP8 at the same quality, roughly comparable to HEVC. The usual choice today. |
| AV1 (2018) | Video | V_AV1 | From the Alliance for Open Media. The smallest files, slower to encode; some devices decode it only in software. |
| Vorbis | Audio | A_VORBIS | The original WebM audio codec, from Xiph.Org. |
| Opus | Audio | A_OPUS | Better than Vorbis at low bit rates, good for both speech and music. The usual choice today. |
| WebVTT | Subtitles | D_WEBVTT/SUBTITLES and others | The same subtitle format as <track> elements on web pages. |
A file with H.264, HEVC or AAC inside isn't valid WebM, even if it's called .webm. Some tools do produce such files, and some browsers play them anyway, but other players reject them. If you need those codecs, use MP4 or MKV.
On the web
Where WebM plays
| VP8 / VP9 + Opus | AV1 | Transparency (alpha) | |
|---|---|---|---|
| Chrome, Edge | Yes | Yes | Yes |
| Firefox | Yes | Yes | Yes |
| Safari | Yes, since Safari 14.1 (2021) on the Mac | Only on devices with an AV1 hardware decoder | No: Safari ignores the alpha channel |
| Apps outside the browser | VLC, mpv; many phone and TV apps can't | Newer players | Editing apps vary |
Support on iPhone and iPad is the weak spot. Safari plays WebM, but the iOS video framework that most other apps use doesn't, so a .webm that plays in Safari may not open in Photos, Files or a chat app. For a page that must work on iPhones, list an MP4 source as well:
<video controls playsinline>
<source src="clip.webm" type='video/webm; codecs="vp9, opus"'>
<source src="clip.mp4" type="video/mp4">
</video>The browser takes the first source it can play, so order matters. The codecs parameter lets it skip a file it can't decode without downloading it. Browsers also create WebM: Chrome and Firefox record camera and screen captures into it with the MediaRecorder API, and Safari can too since version 18.4.
Alpha channel
Transparent video with WebM
VP8 and VP9 can carry an alpha channel, so a WebM video can have a transparent background: an animated character over a page, a product shot without a box around it, a logo sting. The colour picture is encoded as usual and the transparency is encoded as a second, grey picture stored alongside each frame (in Matroska's BlockAdditions), with AlphaMode set to 1 in the track. A decoder that doesn't know about it simply shows the colour picture.
That fallback is what happens in Safari, which shows the video but not its transparency. Safari supports transparent HEVC in MOV or MP4 instead, so sites usually offer both: HEVC with alpha first for Safari, WebM with alpha for everyone else. To make a transparent WebM with FFmpeg from a PNG sequence or a ProRes 4444 file: ffmpeg -i in.mov -c:v libvpx-vp9 -pix_fmt yuva420p -crf 32 -b:v 0 out.webm.
Checking the alpha survived
FFmpeg's built-in VP9 decoder ignores the alpha channel. To see it, decode with libvpx: ffmpeg -c:v libvpx-vp9 -i out.webm frame%03d.png, and check the PNGs have transparent areas.
Troubleshooting
Common WebM problems and how to fix them
| Symptom | Usual cause | Fix |
|---|---|---|
| A recording made in the browser has no length and can't be seeked | It was written as a live stream (for example by the MediaRecorder API): no Duration and no Cues. | Remux it: ffmpeg -i in.webm -c copy out.webm. FFmpeg writes both. |
| Plays in Chrome, not on an iPhone or in a TV app | The device or app doesn't support WebM, or not this codec. | Offer an MP4 (H.264 + AAC) as well. |
| Transparent in Chrome, black background in Safari | Safari doesn't support VP9 alpha. | Add an HEVC-with-alpha MOV or MP4 source for Safari. |
| Video editor won't import it | Many editors don't read VP9 or AV1, or WebM at all. | Convert to an editing-friendly format, such as ProRes or H.264. |
| Very slow to encode | VP9 and AV1 encoders are slow at their best settings. | Use a faster preset (-deadline good -cpu-used 4 for libvpx, a higher -preset for SVT-AV1) and multithreading (-row-mt 1). |
How to
How to open, edit and convert a WebM file
- Any computer: drag it into a browser window. VLC and mpv also play it on Windows, macOS and Linux.
- macOS: QuickTime Player doesn't open WebM; use a browser, VLC or IINA.
- Windows: the Media Player app plays many WebM files with Microsoft's free web media and VP9 extensions; VLC plays all of them.
- Phones: Android plays WebM natively. On iPhone, use Safari or VLC.
- WebM to MP4:
ffmpeg -i in.webm -c:v libx264 -crf 20 -c:a aac -movflags +faststart out.mp4. The codecs have to change, so this re-encodes. - MP4 to WebM:
ffmpeg -i in.mp4 -c:v libvpx-vp9 -crf 32 -b:v 0 -row-mt 1 -c:a libopus out.webm, or the WebM presets in HandBrake. - Audio only: WebM with just an Opus track is a compact audio file;
ffmpeg -i in.webm -vn -c:a copy out.opusextracts it without re-encoding.
Security
Is a WebM file safe?
A WebM file is media, not a program: it can't run code. WebM deliberately leaves out Matroska features like attachments, so it can't carry fonts or other files either. The realistic risk is a crafted file that hits a bug in a decoder, as with any video format. Browsers decode video in a sandboxed process and patch their codec libraries quickly, so keep browsers and players updated.
Browser recordings may contain more than you think: a screen capture includes whatever was on screen, notifications included. Watch a recording through before sharing it.
Free downloads
Sample WebM files to download
Free sample WebM files for testing players, browsers, upload forms and transcoding pipelines. All are made from FFmpeg test patterns and generated tones, with the format written on screen. Each was checked with ffprobe and fully decoded without errors.
What's inside sample-720p-vp9-opus.webm
A 10-second, 1280×720 WebM at 30 fps, with VP9 video and Opus stereo audio. It plays in every current browser, so it's a quick check that a page or host serves WebM correctly.
The label
The bottom band names the resolution, frame rate and codecs, so you can see if a pipeline changed something.
Timecode and frame counter
Burned into the top of each frame. Skipped or repeated frames show up as jumps in the counter.
The flash and the beep
A white square flashes in the top right for 3 frames on every whole second, in step with a 1 kHz beep. If they drift apart, audio and video are out of sync.
Stereo test tones
440 Hz on the left channel and 660 Hz on the right, so swapped or mixed-down channels are easy to hear.
Five Clusters, five keyframes
A keyframe every 2 seconds, each starting a new Cluster, and a Cues index pointing at all five, so seeking is instant.
Metadata
The Info element holds the title; the Tags element holds the artist and a comment naming this page.
ffprobeshows them.
All sample WebM files
720p VP9 + Opus
sample-720p-vp9-opus.webm · 1.2 MB (1,225,693 bytes)
10 seconds at 1280×720, 30 fps. VP9 (profile 0) with Opus stereo at 96 kbps, with Duration and a Cues index.
- Checking a player, host or upload form handles WebM
- Audio/video sync and channel tests
VP8 + Vorbis
sample-vp8-vorbis.webm · 304.8 KB (312,123 bytes)
4 seconds at 640×360, in the original 2010 WebM combination: VP8 video and Vorbis audio.
- Testing older or minimal WebM decoders
- Checking a transcoder handles both generations of codecs
AV1 + Opus
sample-av1-opus.webm · 194.5 KB (199,130 bytes)
4 seconds at 640×360, AV1 Main profile encoded with SVT-AV1, with Opus audio.
- Testing AV1 support, especially in Safari
- Checking thumbnailers and transcoders handle AV1
Transparent video (VP9 with alpha)
sample-vp9-alpha.webm · 42.5 KB (43,524 bytes)
4 seconds at 640×360: a moving box and a 50% transparent label band on a fully transparent background. VP9 with
AlphaMode1; no audio.- Testing transparent video in Chrome, Edge and Firefox
- Seeing what Safari does with it
Audio only (Opus)
sample-audio-opus.webm · 178.6 KB (182,863 bytes)
10 seconds of the stereo test tones with the beep on every second, Opus at 96 kbps, no video track. Served as
audio/webm.- Testing `<audio>` playback and audio-only detection
- Checking upload forms that accept audio by MIME type
No duration, no Cues (like a browser recording)
sample-no-cues.webm · 329.7 KB (337,575 bytes)
4 seconds at 640×360, VP8 + Opus, written as a live stream: a Segment of unknown size, no Duration and no Cues index, as MediaRecorder produces.
- Reproducing "no duration" and "can't seek" bugs
- Testing a remux or repair step in an upload pipeline
Ways to test with them
- Codec support: open
sample-vp8-vorbis.webm, the featured VP9 file andsample-av1-opus.webmin each browser and app you care about. Whichever stays black or silent shows which codec is missing. - Transparency: put
sample-vp9-alpha.webmon a coloured page background. In Chrome, Edge and Firefox the background shows through; in Safari it doesn't. - Browser recordings:
sample-no-cues.webmbehaves like a MediaRecorder file. A player may show no duration or refuse to seek; afterffmpeg -i sample-no-cues.webm -c copy fixed.webmboth should work. - Audio vs video:
sample-audio-opus.webmhas no video track. A pipeline that assumes.webmis video should notice. - Sync: in the featured file, the white square and the beep should coincide on every second.
Free to use for testing, teaching and demos, commercially or not, with no attribution needed. A link back to this page is always appreciated.
Put it online
Have a WebM file? Give it a link.
Drop a WebM on 99helpers and it gets its own address that plays in the browser, without an app or a sign-in. Send the link instead of an attachment; for iPhone viewers, an MP4 is the safer companion.
Questions
WebM files, frequently asked
What is a WebM file?
A video or audio file in an open, royalty-free format made for the web. It's a restricted form of Matroska that holds VP8, VP9 or AV1 video and Vorbis or Opus audio.
Is WebM better than MP4?
For the web, WebM with VP9 or AV1 often gives smaller files at the same quality, with no patent licensing. MP4 with H.264 plays on more devices and apps, especially Apple ones. Many sites offer both.
How do I convert WebM to MP4?
Re-encode it, because MP4's usual codecs are different: ffmpeg -i in.webm -c:v libx264 -crf 20 -c:a aac out.mp4, or use HandBrake.
Why won't my WebM play on my iPhone?
Safari on iPhone plays WebM, but most other iPhone apps use Apple's video framework, which doesn't. Open it in Safari or VLC, or convert it to MP4.
Why does my recorded WebM have no duration?
Browsers write recordings as a stream and don't go back to fill in the duration or a seek index. Remux it with ffmpeg -i in.webm -c copy out.webm and both are added.
Can a WebM video have a transparent background?
Yes, with VP8 or VP9 and an alpha channel. Chrome, Edge and Firefox show the transparency; Safari doesn't, and needs HEVC with alpha instead.
Is WebM the same as MKV?
WebM is a subset of Matroska, the format behind MKV. A WebM file is valid Matroska, but an MKV can hold codecs, attachments and other features that WebM leaves out.
Can WebM files contain viruses?
A WebM file can't run code and can't carry attachments. A crafted file could exploit a decoder bug, so keep your browser and players updated.
Related formats
Other file types explained
Keep going
Related
Sources
- The WebM Project: container guidelines
- Library of Congress: WebM
- RFC 9559: Matroska Media Container Format Specification
- MDN: Media container formats
- MDN: Web video codec guide
- WebKit: features in Safari 18.4 (WebM recording)
Last reviewed 27 October 2026.