WebM vs MP4: containers, codecs, and which one to send

A video file's extension tells you less than you'd think. ".mp4" and ".webm" name containers โ€” boxes that hold video and audio streams โ€” and what plays where depends on the codecs inside the box. This guide untangles the two, explains why your screen recording is WebM and your phone's is MP4, and why converting between them in a browser became possible only recently.

Container versus codec

A codec is the compression method for a stream: H.264 (AVC), H.265 (HEVC), VP8, VP9 and AV1 for video; AAC, MP3, Opus and Vorbis for audio. A container is the file that carries streams plus timing, metadata and subtitles: MP4, WebM, MKV, MOV. Players need to support both the container and every codec inside it โ€” which is why an MP4 can fail to play (an unusual codec inside) and why "MP4" in everyday speech really means "MP4 containing H.264 video and AAC audio", the combination every device decodes in hardware.

MP4: the format that opens everywhere

MP4 (ISO base media file format, from the MPEG group, 2001) with H.264 and AAC is the lingua franca: cameras, phones, PowerPoint, iMovie, WhatsApp, TVs, every editor. The reason is history and hardware โ€” H.264 arrived in 2003, was adopted by Blu-ray, broadcast and the iPhone, and every chip made since decodes it. The catch is licensing: H.264 and AAC are patented, and encoders must pay. That never affected users, but it shaped the next format.

WebM: the web's royalty-free answer

WebM (Google, 2010) is a Matroska-based container restricted to royalty-free codecs: VP8/VP9 (now also AV1) for video, Vorbis/Opus for audio. Browsers embraced it because they could ship encoders without licence fees, which is why the browser's own recording API (MediaRecorder, used by every web-based screen recorder including this site's) produces WebM. It plays in all modern browsers, on Android, in VLC and most players โ€” and not natively in older Windows Media Player, some iOS apps, PowerPoint, or most video editors' default import, which is the friction people hit.

Which one to use

  • Sending to people or apps: MP4. It is the safe default and the one platforms re-encode least.
  • Embedding on your own site: WebM (VP9 or AV1) is 20โ€“40% smaller at the same quality; serve MP4 as a fallback for Safari users on older devices.
  • Archiving originals: whatever the camera made, untouched. Re-encoding always loses a little.
  • Screen recordings for a colleague: WebM is fine if they use a browser; convert to MP4 for PowerPoint or a client.

Converting, and why browsers couldn't until recently

Conversion means decoding every frame and re-encoding it in the other codec, so quality is lost slightly each time and the process is compute-heavy โ€” historically a desktop job (FFmpeg, HandBrake) or an upload to a server. Browsers could decode MP4 but not write it. The WebCodecs API changed that: Chrome, Edge and recent Safari now expose the operating system's hardware H.264 and AAC encoders to web pages, so a page can decode a WebM, encode H.264 frames and mux an MP4 entirely on the device, typically faster than real time. Firefox lacks the encoder as of this writing. How video compression works: bitrate, keyframes and codecs explains what the encoder is doing with those frames, and the compressor the bitrate trade-offs.

Sources and further reading

The claims in this guide rest on these references, which were checked when the guide was last updated. Spotted an error? The contact page says how to report it.

  1. WebM โ€” Wikipedia
  2. MP4 file format โ€” Wikipedia
  3. Web video codec guide โ€” MDN Web Docs

Try the tool

Frequently asked questions

Why is my screen recording a WebM file?

Browser recording uses the MediaRecorder API, which encodes with royalty-free codecs in a WebM container. Convert to MP4 for apps that don't accept it.

Is MP4 better quality than WebM?

Neither container affects quality; the codec and bitrate do. VP9/AV1 in WebM are usually more efficient than H.264 in MP4 at the same size; H.264 wins on compatibility.

Can I just rename .webm to .mp4?

No โ€” the container structure and codecs are different. The file must be re-muxed or re-encoded.

Does converting lose quality?

A little, because frames are re-encoded. At a sensible bitrate the difference is invisible; avoid converting the same clip repeatedly.