Back to Glossary
Video

WebM vs MP4

What Is the Difference Between WebM and MP4?

Both are containers, so what sets WebM and MP4 apart is the list of codecs each may hold and the places the finished file plays. WebM, launched in 2010 with Google behind it, narrows Matroska down for web playback, and its spec allows only a short list of codecs, so any player that supports WebM can open any valid file.

MP4, which is MPEG-4 Part 14, comes from the ISO base media file format and holds a wider set, VP8, VP9, AV1 and Opus included. File size and picture quality come from the codec inside, so a WebM is not smaller than an MP4 just for being a WebM.

WebM keeps to a short codec list

  • VP8 or VP9 video

    The two video codecs the WebM spec names

  • AV1 video

    Common in WebM files, though the WebM Project still lists only VP8 and VP9

  • Vorbis or Opus audio

    The two audio codecs the spec allows

  • H.264, H.265 or AAC

    Outside the spec, though they are the usual codecs in an MP4

MP4 holds the common codecs and the open ones

  • H.264 or H.265 video

    The usual video in an MP4 file

  • AV1, VP9 or VP8 video

    Each through a binding its makers publish, registered with the MP4 Registration Authority

  • AAC or Opus audio

    AAC is the usual pairing, and Opus has a mapping of its own

Which File Does Your Browser Pick?

A page that serves both usually lists them in one video element, WebM first and MP4 as the fallback. The browser plays the first source it can, and a source whose type it can’t play is skipped before any download. WebKit describes one exception: Safari plays the file it can decode in hardware, even when another comes first.

One video, two files

Both sources are the same two-second clip, and the picture names the file that plays. Swap the order to see which one your browser takes.

Each source carries a type attribute, so the browser can skip a file it can't play before downloading any of it.

WebM or MP4: Which Should You Use?

Often both. A landing page’s six-second product loop can ship as a VP9 WebM with an H.264 MP4 behind it, while a clip you send to a client goes out as a single H.264 MP4, the format MDN suggests when you can offer only one.

  Use Why
A muted loop on a landing page Both, WebM first Each browser plays the first file it can, and the MP4 covers any browser that skips the WebM
One file that has to play anywhere MP4 with H.264 and AAC H.264 MP4 plays in every major browser
A transparent overlay on a web page VP9 WebM with alpha, plus another file for Safari Safari plays WebM but doesn't show its transparency
Recordings your web app receives Accept both Browsers record to WebM or MP4, depending on the browser
A VP9 WebM for an MP4-only workflow Re-encode to an H.264 MP4 MP4 can hold VP9, but many MP4 tools expect H.264 or H.265

How Do You Convert WebM to MP4?

Copy the streams when the MP4 only has to hold them, and re-encode to H.264 when it has to play everywhere. The MKV to MP4 steps work the same way for WebM, and the file inspector on that page shows which codecs your file holds.

Copy the streams to keep every frame

A stream copy puts the WebM’s tracks in an MP4 as they are, with nothing decoded, so nothing is lost. The catch is reach: many MP4 players and editing apps expect H.264 or H.265 and may not open VP9 or AV1 in an MP4. A copy also suits the rare .webm that holds H.264, outside WebM’s own codec list.

Re-encode to H.264 for the widest reach

Encoding the video to H.264 and the audio to AAC gives a file every major browser plays, at the cost of one more round of lossy compression. Write the MP4 with its index at the front, so a web page can start playing it before the whole file has downloaded.

How WebM and MP4 Work in CE.SDK

Your users open and save both files wherever CE.SDK’s video editing runs: in desktop browsers, on iOS, macOS and Android, and with @cesdk/node-native. The editor keeps the file type your app asks for and never moves an export to the other container.

Opening WebM and MP4 files

WebM files holding VP8, VP9 or AV1 open in the editor, and so do MP4 files holding H.264, or H.265 where the platform decodes it. An MP4 with VP9 or AV1 inside doesn’t open: re-encode it to H.264 first, or import the WebM it came from.

Saving to the file your app picks

MP4 exports default to H.264 with AAC, or Opus in a browser without an AAC encoder, and WebM exports to VP9 with Opus. Pairing a codec with a file that can’t hold it ends in an error, never a quiet switch to the other container. In a web app, run checkCapabilities() and read getCapabilityState('vp9Encode') before offering WebM. On Linux browser builds with no H.264 encoder, WebM can still work where MP4 export can’t.

Transparent video saves as WebM

Transparency needs a VP8 or VP9 WebM with exportAlpha turned on, written on iOS, macOS, Android or with @cesdk/node-native. The browser has no encoder for the alpha stream. The transparent VP9 export steps walk through the setup.

FAQs

Not because of the container. File size depends on the codec and how it was set, and a WebM often holds VP9 or AV1, newer codecs than the H.264 in most MP4 files. A comparison between a typical WebM and a typical MP4 is really a comparison between codecs.

Yes. Safari plays VP8 and VP9 WebM files on the Mac, and WebKit has since added it on iPhone and iPad, so every major browser now plays the format. Safari doesn't show the transparency in a WebM with an alpha channel, though, and when a page offers both files it may pick the MP4.

Yes. The WebM Project has a published binding for VP8 and VP9 in MP4, AOMedia has one for AV1, and the MP4 Registration Authority lists all three. Many MP4 players and editing apps still expect H.264 or H.265, CE.SDK's MP4 import among them, so re-encode to H.264 for a file that must open everywhere.

The container is neither, since the codec decides. The video codecs in WebM and MP4 files are lossy as browsers use them: some have lossless modes, but no browser implements those, so the file keeps an approximation of each frame rather than an exact copy.

Check its Cues element, the index WebM uses to find a point in the video. Without Cues a player can't seek at all, and Cues written at the end of the file have to be fetched before seeking works. Remuxing with a tool that writes the Cues at the start fixes it without re-encoding, much as moving the moov index to the front does for an MP4.