WebM or MP4 for Your Website? When and How to Use WebM Video

Compare VP8, VP9, AV1 and H.264 for web video, learn when WebM is worth it, how to serve WebM with an MP4 fallback, and how to encode it with ffmpeg.

Updated September 29, 2026 5 min read

Use the free MP4 to WebMConvert MP4 to royalty-free WebM (VP8 + Opus) for websites and HTML5

If you put video on a web page, sooner or later someone suggests WebM. It is open and royalty-free, browsers support it, and at the same quality a VP9 or AV1 file can be noticeably smaller than an H.264 MP4. Yet MP4 is still the default almost everywhere. So is WebM worth the extra step, and which flavour should you use?

This guide compares the codecs involved, shows the HTML pattern for serving WebM with an MP4 fallback, and walks through converting MP4 to WebM in the browser or with ffmpeg, including the honest limits of doing it in a browser tab.

The codecs behind WebM

WebM is a container based on Matroska that allows only open codecs:

Codec Released Compression vs H.264 Encoding speed Notes
VP8 2010 Similar Fast Widest WebM support, including older browsers
VP9 2013 Clearly better Slow Used heavily by large video platforms
AV1 2018 Better again Very slow in software Hardware decoding common on newer devices only
H.264 (MP4) 2003 Baseline Fast Hardware decoding practically everywhere

For audio, WebM uses Opus (modern, excellent at low bitrates) or the older Vorbis. Opus at 96 kbps is generally very good for stereo speech and music.

The exact efficiency gains depend on the content and encoder settings, so treat the "better" labels as direction rather than a fixed percentage.

When WebM makes sense

WebM is a good choice when:

  • you host video yourself and bandwidth costs or page weight matter, for example a looping background video or product demos on a landing page;
  • you need transparency. VP8 and VP9 support an alpha channel, which H.264 in MP4 does not, so WebM is the usual format for transparent animated overlays in browsers;
  • you want to avoid patent-encumbered codecs for policy reasons.

MP4 with H.264 remains the better choice when the file will be downloaded, emailed, edited, played on TVs or uploaded to social networks, because those destinations expect it. Platforms that accept uploads also re-encode everything themselves, so uploading WebM brings no size benefit.

Serve both formats

Browsers pick the first <source> they can play, so list WebM first and MP4 second:

<video controls width="1280" height="720" poster="poster.jpg" preload="metadata">
  <source src="demo.webm" type="video/webm">
  <source src="demo.mp4" type="video/mp4">
</video>

Setting width and height lets the browser reserve space and avoids layout shift; preload="metadata" stops the whole file downloading before the visitor presses play.

Convert MP4 to WebM in your browser

The MP4 to WebM converter encodes VP8 video with Opus audio locally in your browser. It also accepts MOV, MKV and AVI inputs.

  1. Open MP4 to WebM and drop your video on the box.
  2. Pick an Encoding speed. Fast uses VP8's realtime mode and gives a larger file; Better compression is about three to four times slower but smaller and sharper.
  3. Set Quality (CRF) with the slider, from 4 to 40. The default is 12; lower numbers mean better quality and a bigger file.
  4. Click Convert to WebM and wait. Opus audio is encoded at 96 kbps when the source has sound.
  5. Preview the WebM on the page and download it.

Two limitations are worth stating plainly. VP9 and AV1 output are not offered: the VP9 encoder crashes in the single-threaded WebAssembly build the tool uses, while VP8 is reliable. And WebM encoding is CPU-heavy: expect roughly real-time speed or slower for HD video, so a one-minute 1080p clip can take a few minutes. For a whole library, or when you want VP9's better compression, use desktop ffmpeg.

Encoding WebM with ffmpeg

VP9 with constant quality

ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 32 -b:v 0 -row-mt 1 -c:a libopus -b:a 96k output.webm

-b:v 0 is required for true constant-quality mode in libvpx-vp9. Typical CRF values sit between about 15 (very high quality) and 35 (small).

VP9 two-pass (better quality per byte)

On macOS or Linux:

ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 1500k -pass 1 -an -f null /dev/null
ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 1500k -pass 2 -c:a libopus -b:a 96k output.webm

On Windows, replace /dev/null with NUL.

VP8

ffmpeg -i input.mp4 -c:v libvpx -crf 10 -b:v 2M -c:a libopus -b:a 96k output.webm

With VP8, -b:v acts as a ceiling for the CRF mode, so set it generously.

AV1

ffmpeg -i input.mp4 -c:v libsvtav1 -crf 35 -preset 8 -c:a libopus -b:a 96k output.webm

SVT-AV1 is much faster than the reference libaom encoder; higher -preset numbers are faster.

Tips and pitfalls

Keep your masters in MP4 or better

WebM is a delivery format. Keep the original recording, edit from it, and encode WebM as the last step. Converting WebM back to MP4 later adds another lossy generation; the WebM to MP4 guide explains that direction.

Shrink before you encode

For background loops, cut the clip to the essential seconds with Trim Video and reduce the resolution with Resize Video. Removing the soundtrack with Mute Video also saves bytes, and autoplaying video must be muted in most browsers anyway.

Replacing GIFs

If your goal is replacing a heavy animated GIF, an MP4 is usually the simplest win; see GIF to MP4.

Test on real devices

Check playback in the browsers your visitors actually use, and keep the MP4 fallback in place.

Frequently asked questions

Is WebM smaller than MP4?

With VP9 or AV1, usually yes at the same visual quality. With VP8 the difference compared with H.264 is small, so VP8 mainly helps with openness and transparency rather than size.

Do all browsers support WebM?

Current versions of the major browsers play WebM, but support for specific codecs and for older operating system versions varies. That is why an MP4 fallback source is still recommended.

Why does this tool only produce VP8?

The VP9 encoder is unstable in the single-threaded WebAssembly build of ffmpeg used in the browser, so the tool offers VP8, which encodes reliably.

What CRF should I use for WebM?

In this tool, the default of 12 is a good start for high quality; raise it towards 20-30 for smaller files. VP9 in desktop ffmpeg uses a different useful range, typically around 25-35.

Should I upload WebM to social media?

There is no benefit. Platforms re-encode uploads, and MP4 with H.264 is the most widely accepted upload format.

Try it now: MP4 to WebM

Loading tool…