Format comparison

MP4 vs WebM: which one to use, with tested file sizes

Updated Tested November 4, 2026Five clips testedffmpeg 6.1.1

Two file wrapper boxes holding video, audio and metadata strips, above three bars of different lengths on a dark background

Short answer

Use MP4 with H.264 and AAC when the file will be uploaded, sent to someone or edited later. Use WebM with VP9 or AV1 and Opus when you control the web page that plays it and want smaller files. MP4 and WebM are containers, so the codec inside decides the size: at the same SSIM, our AV1 files were smaller than H.264 on all five test clips: about 23% on two ordinary clips and 59.5% to 90.7% on three demanding ones. VP9 ranged from 13.1% larger to 70.5% smaller. YouTube recommends MP4 and also lists WebM as accepted.

MP4 to WebM converter (free, in your browser, VP8 and Opus, low default bit rate)

Key takeaways

  • MP4 and WebM are wrappers, not codecs. In ffmpeg 6.1.1, H.264 and AAC went into MP4, MKV and MOV, but ffmpeg refused to put them into WebM: "Only VP8 or VP9 or AV1 video and Vorbis or Opus audio and WebVTT subtitles are supported for WebM."
  • The reverse is allowed: VP9 and AV1 with Opus copied into an MP4 without re-encoding, and the files played in the Playwright Chromium 153 and Firefox 155 test builds (our test, two builds on Linux).
  • At matched SSIM, AV1 was 22.7% smaller than H.264 on a busy 1080p clip and 23.2% smaller on a calm 720p clip. VP9 was 9.8% smaller on the first and 13.1% larger on the second (our measurement, one encoder setting each).
  • On three demanding clips AV1 saved far more at the same SSIM: 83.1% on 4x fast motion, 90.7% on a fractal with fine detail and at least 59.5% on small scrolling text (that clip hit our CRF ceiling, so its saving is a lower bound). VP9 saved 70.1%, 70.5% and 54.6% on the same three (our measurement, new on November 4, 2026).
  • Encoding took longer: on our 6-core server VP9 needed 2.4x and 4.4x the H.264 time on the two clips, and AV1 7.0x and 6.3x (one run each).
  • The Koldflux MP4 to WebM converter wrote VP8 and Opus at about 692 kbps: a 4 second test clip shrank to 13.6% of its size and scored SSIM 0.8593 against the original. Our VP9 command on the same clip kept 96.2% of the size and scored 0.9421.
  • YouTube recommends MP4 and lists WebM among accepted formats (official, read October 30, 2026). We did not read other platforms' format pages for this update.

What is the difference between MP4 and WebM?

Both are containers: a file wrapper that holds a video stream, an audio stream and metadata. The codec inside, such as H.264 or VP9, decides how well the video is compressed. MP4 usually holds H.264 video with AAC audio. The WebM Project describes its format this way: "WebM is an open, royalty-free, media file format designed for the web", and it holds VP8, VP9 or AV1 video with Vorbis or Opus audio (official, read October 30, 2026).

MP4 and WebM side by side
MP4WebM
Usual video codecsH.264, also H.265, VP9, AV1VP8, VP9, AV1
Usual audio codecsAAC, also Opus and othersOpus, Vorbis
Licensing, per MDNAVC (H.264) is "a proprietary format" with patents held by multiple partiesThe container and its required codecs are available under open licenses
MDN on support"industry standard for video content, widely supported across devices and browsers""native support in most browsers"
YouTubeRecommended upload containerListed as an accepted upload format

Source: WebM Project, About WebM; MDN, Media container formats and Web video codec guide; YouTube Help, Recommended upload encoding settings and Accepted upload file formats (all official, read October 30, 2026; every quoted phrase matched against the page text by script, see quotes-check.txt). The codec lists are what each container commonly carries, not everything it can hold; the next section tests the overlap.

Can WebM hold H.264, and can MP4 hold VP9 or AV1?

We took one 10 second clip with sound (Wood Lake, Wikimedia Commons, CC0) and copied the streams between containers with ffmpeg 6.1.1, without re-encoding. WebM refused H.264 and AAC. MP4 accepted VP9 and AV1 with Opus.

Stream copy between containers
CopyResult
MP4 (H.264, AAC) to MKVWorked
MP4 (H.264, AAC) to MOVWorked
MP4 (H.264, AAC) to WebMRefused, exit code 234
WebM (VP9, Opus) to MP4Worked, still VP9 and Opus
WebM (VP9, Opus) to MKVWorked
WebM (AV1, Opus) to MP4Worked, still AV1 and Opus

Source: our test on October 30, 2026, ffmpeg 6.1.1 (test T2 in the log). The WebM refusal is ffmpeg's rule for its own muxer; it matches the WebM Project's list of codecs. A .webm extension suggests VP8, VP9 or AV1 video with Vorbis or Opus audio, but the name does not prove what is inside, and an MP4 can hold VP9 as well (our vp9-in-mp4 file did); only probing the file with ffprobe shows the codecs, so check before you assume it will play or upload.

We then played the MP4 with H.264, the WebM with VP9, the WebM with AV1 and the MP4 with VP9 in two browser builds. All four played in Playwright's Chromium 153 and Firefox 155 on Linux (test T4). Those are open-source test builds, not branded Chrome, Edge or Safari, so this shows the files are valid and playable in those builds and says nothing about other browsers, phones or TVs.

Is WebM smaller than MP4 at the same quality?

It depends on the codec in the WebM and on the footage, and we measured it. We encoded two real clips three ways and matched the quality by SSIM, a 0 to 1 score that compares every frame with the original (1 is identical; it is not a viewer rating). The reference was H.264 at CRF 23. For VP9 and AV1 we swept the CRF setting and kept the largest value whose SSIM was at least the H.264 score, which gives the smallest file that is not worse by this measure.

File size at matched SSIM
Clip and codecCRFSizeSSIMSize vs H.264Encode time
A busy water 1080p25, H.264236,329,317 bytes0.9883reference4.3 s
A busy water 1080p25, VP9325,710,947 bytes0.9883-9.8%10.5 s
A busy water 1080p25, AV1304,891,230 bytes0.9886-22.7%29.9 s
B calm landscape 720p30, H.264236,326,977 bytes0.9778reference3.9 s
B calm landscape 720p30, VP9327,153,368 bytes0.9785+13.1%17.2 s
B calm landscape 720p30, AV1344,861,323 bytes0.9795-23.2%24.7 s

SSIM measures pixel similarity, not viewer-perceived quality.

Source: our measurement on October 30, 2026 with ffmpeg 6.1.1 (libx264 preset medium, libvpx-vp9 with -cpu-used 2, SVT-AV1 preset 6, video only) on 6.4 seconds of Ocean surface waves 06 (1080p, 25 fps) and 10 seconds of the Wood Lake clip (720p, 30 fps), both CC0 on Wikimedia Commons. Controls: each clip compared with itself scored SSIM 1.000000, and H.264 at CRF 51 scored lower than at CRF 23 on both. Encode times are single runs on one 6-core server, so read them as an order of magnitude.

Limits: two clips, one encoder setting per codec, one metric. Both sources were already lossy files (Theora and VP8), so these are re-encodes. SSIM scores how similar two sets of pixels are; it is not a model of what a viewer notices, and two files with the same SSIM can still differ in sharpness, texture or visible blocking, especially between codecs built on different compression methods. Treat "matched SSIM" as "matched by this one measurement", not as "looks the same". A different quality target, a slower preset or a different metric such as VMAF can move the percentages, and the VP9 result on clip B shows the sign can change. MDN says AV1 achieves "as much as 50% higher rates than AVC" (official, read October 30, 2026); our AV1 files on these two clips were about 23% smaller, which is inside that claim and well below its upper end (the hard clips below went past it). The old figure on this page of 30 to 50% less data for VP9 had no source and our test did not reproduce it, so we removed it.

Bar chart of file size at equal SSIM with H.264 as 100 percent: clip A VP9 90 and AV1 77 percent, clip B VP9 113 and AV1 77 percent
Similar SSIM, different file sizes: file size against H.264.

Does the gap change on fast motion, small text and fine detail?

Yes, a lot. The first two clips were ordinary footage, so we added three that are hard for an encoder and ran the same matched-SSIM test on 6 second, 720p, 30 fps excerpts: Wood Lake played at 4x speed (fast motion), made-up text lines in 15 px type scrolling up (small text, synthetic), and ffmpeg's mandelbrot pattern (fine detail, synthetic). The reference was again H.264 at CRF 23, and VP9 and AV1 kept the largest CRF whose SSIM was at least the H.264 score.

Size at equal SSIM on hard clips
Clip and codecCRFSizeSSIMSize vs H.264Encode time
C fast motion, H.264234,386,417 bytes0.9269reference3.6 s
C fast motion, VP9521,309,942 bytes0.9270-70.1%9.4 s
C fast motion, AV156740,603 bytes0.9275-83.1%11.8 s
D small text, H.26423151,527 bytes0.9715reference1.0 s
D small text, VP9 (CRF ceiling)6368,817 bytes0.9876-54.6% or more2.8 s
D small text, AV1 (CRF ceiling)6261,353 bytes0.9979-59.5% or more4.3 s
E fine detail, H.264233,872,775 bytes0.9686reference2.6 s
E fine detail, VP9501,141,842 bytes0.9706-70.5%7.1 s
E fine detail, AV158359,044 bytes0.9701-90.7%11.7 s

Source: our measurement on November 4, 2026 with the same ffmpeg 6.1.1 settings as above (script hard-clips.py, log hard-results.txt). Controls: every clip compared with itself scored SSIM 1.000000, H.264 at CRF 51 scored below CRF 23 on all three, and clip C had a higher mean frame difference than the same footage at normal speed (7.677 against 4.650), so it really is faster motion.

Limits: on the small-text clip, VP9 and AV1 still scored above the H.264 SSIM at the highest CRF we tried (63 for VP9, 62 for AV1). That means our encoder and CRF range did not reach the point where SSIM drops to the H.264 level, so we do not have a matched-SSIM size for that clip; the "-54.6% or more" and "-59.5% or more" figures are the saving already banked at a quality still above the target, a lower bound, not the saving at exactly matched SSIM. A build that accepts a higher CRF, or a different encoder setting, could show a different, probably larger, saving at the true match point. The H.264 SSIM on clip C is only 0.9269, so these are comparisons at a modest quality level, and a higher target can change the percentages. Clips D and E are synthetic, one clip each, and we did not look at the results by eye or measure VMAF. The pattern is clear in our data, though: the codec gap grew when the footage was hard, and on all five clips AV1 was smaller than H.264 at equal or higher SSIM.

Bar chart of file size at equal SSIM with H.264 as 100 percent: fast motion VP9 30 and AV1 17 percent, small text VP9 45 and AV1 40 percent (CRF ceiling reached), fine detail VP9 30 and AV1 9 percent
Hard clips: VP9 and AV1 files are a fraction of the H.264 size.

What does the Koldflux MP4 to WebM converter produce?

We ran the free converter in headless Chromium on a 4 second excerpt of the H.264 and AAC test file. It runs in the browser and returned a WebM with VP8 video and Opus audio in 35.8 seconds.

The result is much smaller and scores much lower on SSIM: 360,469 bytes, 13.6% of the 2,656,960 byte input, about 692 kbps, with SSIM 0.8593 against the input. For comparison, our VP9 command (-crf 33) on the same excerpt gave 2,556,884 bytes, 96.2% of the input, with SSIM 0.9421. That is not a like-for-like comparison, because the two files are very different in size (13.6% and 96.2% of the input); it shows what the converter's defaults do. If you need quality, use the ffmpeg command below. If you need a small WebM for a quick share, the converter does that.

Source: our run on October 30, 2026 (test T5 in the log). One 4 second 720p excerpt; the converter's own page says its defaults are VP8 and a low bit rate, files up to 100 MB, and a one-time download of a ~30 MB converter engine (read October 31, 2026).

ffmpeg -i in.mp4 -c:v libx264 -preset medium -crf 23 -pix_fmt yuv420p -c:a aac -b:a 128k -movflags +faststart out.mp4
ffmpeg -i in.mp4 -c:v libvpx-vp9 -b:v 0 -crf 32 -row-mt 1 -cpu-used 2 -pix_fmt yuv420p -c:a libopus -b:a 128k out-vp9.webm
ffmpeg -i in.mp4 -c:v libsvtav1 -crf 34 -preset 6 -pix_fmt yuv420p -c:a libopus -b:a 128k out-av1.webm
The three encodes we compared. The CRF values were the matched ones for clip B; yours will differ.

How do you offer both formats on a web page?

Put several source elements inside one video element and the browser uses the first one it can play. We tested this markup in Playwright's Chromium 153 and Firefox 155 builds on Linux (test T7): with the WebM first, both loaded the WebM; with the MP4 first, both loaded the MP4; when the first source had a type neither could play (video/x-unknown), both skipped it and loaded the MP4; and a lone source with that type loaded nothing, which was the control.

One result to know about: when we labeled the MP4 file type="video/webm" and listed it first, both browsers still loaded it, so the type attribute is a hint for skipping sources, not a check of the file. Put the real MIME type and codecs there. We tested these two builds only, not Safari, Chrome or Edge, and we did not test how a phone or TV picks a source.

Source: our test on October 31, 2026 (test T7, public/hub-media/mp4-vs-webm/source-fallback-results.txt and source-fallback-run.cjs). The avc1.64001f string is High profile level 3.1, read with ffprobe from our 720p test file.

<video controls width="640" muted>
  <source src="clip.webm" type='video/webm; codecs="vp9, opus"'>
  <source src="clip.mp4" type='video/mp4; codecs="avc1.64001f, mp4a.40.2"'>
  Your browser cannot play this video. <a href="clip.mp4">Download the MP4</a>.
</video>
Two sources: WebM (VP9, Opus) first, MP4 (H.264, AAC) as the fallback.

Which should you use: MP4 or WebM?

Pick by where the file is going, then by the codec inside it.

Which format for which job
SituationUseWhy and how we know
Uploading to YouTubeMP4, H.264, AACYouTube recommends MP4; WebM is also accepted (official)
Uploading to another platformCheck its own format pageWe did not read other platforms' pages for this update
Sending to a person or keeping an archive copyMP4, H.264MDN calls MP4 the industry standard; H.264 was the fastest to encode in our test
Video on your own web page, smallest fileAV1 in WebM or MP4, VP9 secondAV1 was smaller at equal SSIM on all five clips (about 23% on ordinary footage, up to 90.7% on hard clips); VP9 varied. Check AV1 support for your visitors and budget 3 to 7 times the H.264 encode time (our single runs)
A quick small WebM from an MP4Koldflux converterVP8 at a low bit rate, SSIM 0.8593 on our clip; use ffmpeg VP9 when quality matters
Editing later in a video editorMP4 with H.264Convention, not tested: we did not open these files in editors

Source: the tests above and the official pages cited in the sources. Rows marked "not tested" or "did not read" are stated as such on purpose.

What we did not test

We read the YouTube, WebM Project and MDN pages named above and ran every test on this page. We did not upload anything to YouTube or any other platform, so we cannot say how a platform re-encodes a WebM or an MP4. We did not test Safari, Chrome, Edge, phones or TVs, hardware decoding, battery use, streaming or page load speed, HDR, or editing software. We did not measure quality with VMAF (our ffmpeg build has no VMAF filter) or by eye. Results are for five clips and one setting per codec, and two of the five are synthetic.

Do it in your browser

Free Koldflux tool, no account needed.

MP4 to WebM converter (free, in your browser, VP8 and Opus, low default bit rate)

Questions people ask

Is WebM better than MP4?

Neither wins everywhere. On our five test clips AV1 in WebM was smaller than H.264 in MP4 at equal SSIM every time (about 23% on two ordinary clips, up to 90.7% on a fine-detail clip), but VP9 in WebM ranged from 13.1% larger to 70.5% smaller. MP4 with H.264 is the safer choice for uploads and sharing; YouTube recommends MP4.

Can an MP4 file contain VP9 or AV1?

Yes. In our test ffmpeg 6.1.1 copied VP9 with Opus and AV1 with Opus from WebM into MP4 without re-encoding, and the VP9 file played in the Chromium 153 and Firefox 155 test builds.

Can WebM contain H.264?

ffmpeg 6.1.1 refused: "Only VP8 or VP9 or AV1 video and Vorbis or Opus audio and WebVTT subtitles are supported for WebM." That matches the WebM Project's description of the format.

Does YouTube accept WebM?

Yes. YouTube's list of accepted upload formats includes WebM, and its encoding page recommends MP4 (official, read October 30, 2026).

How do I convert MP4 to WebM without losing quality?

No lossy conversion is free of loss. Re-encode once from your original with a quality setting rather than a low bit rate, for example the VP9 command on this page, and check the result. The free Koldflux converter defaults to VP8 at about 692 kbps on our test clip, which scored SSIM 0.8593 against the input.

Is VP9 or AV1 better for WebM?

In our five clips AV1 gave the smaller file at equal SSIM every time and took about 3 to 7 times the H.264 encode time, while VP9 ranged from 13.1% more to 70.5% less. AV1 playback support varies, so check it for your audience.

Related

More guides on this topic

Sources and how we checked

  1. Koldflux test log: containers, matched-SSIM sweeps, playback, converter run (our measurement, October 30, 2026) (checked 2026-11-04)
  2. Koldflux quote check: every quoted phrase matched against the official page text (October 30, 2026) (checked 2026-11-04)
  3. Koldflux hard-clip test log: fast motion, small text, fine detail, matched SSIM sweeps (our measurement, November 4, 2026) (checked 2026-11-04)
  4. WebM Project: About WebM (official, read October 30, 2026) (checked 2026-11-04)
  5. MDN: Media container formats (official docs, read October 30, 2026) (checked 2026-11-04)
  6. MDN: Web video codec guide (official docs, read October 30, 2026) (checked 2026-11-04)
  7. YouTube Help: Recommended upload encoding settings (official, read October 30, 2026) (checked 2026-11-04)
  8. YouTube Help: Accepted upload file formats (official, read October 30, 2026) (checked 2026-11-04)
  9. Wikimedia Commons: File:Ocean surface waves 06.ogv, CC0 (clip A, read October 30, 2026) (checked 2026-11-04)
  10. Wikimedia Commons: Looking Northward along the West Shoreline of Wood Lake BC in Summer.webm, CC0 (clip B, read October 30, 2026) (checked 2026-11-04)

We read the YouTube, WebM Project and MDN pages on October 30, 2026 and matched every quoted phrase against the page text with a script. We ran every test on this page with ffmpeg 6.1.1 and ffprobe on a Linux server: two real CC0 clips from Wikimedia Commons (Ocean surface waves 06, 1080p, 6.4 s; Wood Lake, 720p, first 10 s), H.264, VP9 and AV1 encodes swept over CRF values and matched on SSIM against the decoded source with a control (source against itself scores 1.000000), stream copies between containers, playback of four files in Playwright Chromium 153 and Firefox 155, and the live Koldflux MP4 to WebM converter in headless Chromium. Derived percentages are computed by post.py from the log. On November 4, 2026 we added three demanding 6 second clips (Wood Lake at 4x speed, scrolling small text and a mandelbrot pattern, the last two generated by ffmpeg) with the same matched-SSIM method, with the CRF sweep widened to 63 after a first run hit the old ceiling; the numbers come from hard-results.txt and make-hard-chart.py. The earlier version of this page had no sources and unmeasured numbers; those were removed. MP4, WebM, H.264, VP9, AV1 and YouTube are names of formats, codecs or products of their owners; Koldflux is not affiliated with or endorsed by them.