WebM is the default download format for many browser screen recorders, OBS exports, and WebRTC captures. It is excellent for the open web, but editing software, phones, and older media players frequently choke on its VP8/VP9 video and Opus/Vorbis audio. The fix is to convert WebM to MP4 — most of the time that means re-encoding to H.264 + AAC, which plays virtually everywhere. This guide covers the one-line command, when you can skip re-encoding, and how to balance quality against file size.

Tested with: FFmpeg 8.1


What You’ll Learn

  1. Why WebM usually needs a full re-encode (and when it doesn’t)
  2. The single command that converts almost any WebM to MP4
  3. Choosing a CRF value: quality vs. file size
  4. When VP9 can be stream-copied and VP8 cannot
  5. Audio: Opus/Vorbis to AAC
  6. Speeding up the encode with presets
  7. Troubleshooting
  8. FAQ

1. Why WebM Usually Needs Re-encoding

MP4 (the ISO base media file format) is a container with a fixed list of “blessed” codecs. The combinations that play on iPhones, in Premiere Pro, and on smart TVs are essentially H.264/HEVC video + AAC audio.

WebM, by contrast, carries:

StreamWebM codecsMP4-compatible?
VideoVP8, VP9, AV1VP9/AV1 technically yes, VP8 no
AudioOpus, VorbisNot in mainstream players

Because the audio (Opus/Vorbis) is almost never accepted in MP4 by consumer players, and VP8 is never valid in MP4, the safe default is a full re-encode to H.264 + AAC. That gives high compatibility across most players and devices (profile, level, pixel format, and device limits can still apply, so it’s not an absolute guarantee).


2. The One Command for (Almost) Any WebM

This is the workhorse. It re-encodes video to H.264 and audio to AAC, and prepares the file for instant web playback.

ffmpeg -i input.webm -c:v libx264 -crf 23 -c:a aac -b:a 128k -movflags +faststart output.mp4
  • -c:v libx264 … encode video as H.264 (the most compatible codec)
  • -crf 23 … constant-quality target; lower = better quality, larger file
  • -c:a aac -b:a 128k … re-encode audio to AAC at 128 kbps
  • -movflags +faststart … move the moov atom to the front so the file starts playing before it fully downloads

That single line handles VP8, VP9, Opus, and Vorbis inputs alike.


3. Choosing a CRF Value (Quality vs. Size)

CRF (Constant Rate Factor) is the most important knob. It targets a perceptual quality level and lets the bitrate float.

CRFVisual qualityTypical useFile size
18Visually losslessArchival, master copiesLarge
20ExcellentHigh-quality uploadsMedium-large
23Very good (default)General purposeMedium
26GoodWeb previews, draftsSmall
28AcceptableQuick shares, tight storageSmallest

A change of about ±6 in CRF roughly halves or doubles the file size. Start at 23 and adjust:

ffmpeg -i input.webm -c:v libx264 -crf 20 -preset slow -c:a aac -b:a 192k -movflags +faststart output.mp4

-preset slow spends more CPU time to pack the same quality into a smaller file. The encode is slower, but the output is leaner.


4. When VP9 Can Be Stream-Copied (and VP8 Cannot)

MP4 can technically hold VP9 video. If you only need to change the container and your target player supports VP9-in-MP4, you can copy the video stream and avoid the slow video re-encode:

ffmpeg -i input.webm -c:v copy -c:a aac -b:a 128k -movflags +faststart output.mp4

This keeps the VP9 video untouched (instant, lossless) and only re-encodes the audio to AAC.

Important caveats:

  • This works only for VP9 (and AV1). VP8 is not a valid MP4 video codec — copying it produces a file most players reject.
  • Many consumer players (older iPhones, some smart TVs, Premiere Pro) do not support VP9 inside MP4 even though the container allows it. If compatibility is the goal, re-encode to H.264 with the command in Section 2.

To check what codec your WebM actually uses before deciding:

ffprobe -hide_banner input.webm

If you see Video: vp8, you must re-encode the video. If you see Video: vp9 and your player supports it, -c:v copy is an option.


5. Audio: Opus/Vorbis to AAC

WebM audio is almost always Opus (newer) or Vorbis (older). Neither is accepted by mainstream MP4 players, so it gets re-encoded to AAC:

ffmpeg -i input.webm -c:v libx264 -crf 23 -c:a aac -b:a 192k -ar 48000 -movflags +faststart output.mp4
  • -b:a 192k … a higher audio bitrate for music-heavy content (128k is fine for speech)
  • -ar 48000 … resample to 48 kHz, a common, safe sample rate for video

If the source has no audio track at all, FFmpeg simply produces a video-only MP4 — the -c:a option is harmlessly ignored.


6. Speeding Up the Encode

H.264 encoding speed is controlled by -preset. Faster presets finish sooner but produce slightly larger files at the same CRF.

PresetSpeedRelative size at same CRF
ultrafastFastestLargest
veryfastFastLarger
mediumDefaultBaseline
slowSlowerSmaller
veryslowSlowestSmallest

For a quick, “good enough” conversion:

ffmpeg -i input.webm -c:v libx264 -crf 23 -preset veryfast -c:a aac -b:a 128k -movflags +faststart output.mp4

For an archival master where size matters more than time, use -preset slow or -preset veryslow with a lower CRF.


7. Troubleshooting

Error 1: Output plays in VLC but not on a phone

Cause: You stream-copied VP9 (-c:v copy), and the phone doesn’t support VP9-in-MP4. Fix: Re-encode to H.264 with the Section 2 command.

Error 2: Could not find tag for codec vp8 in stream

Cause: You tried -c:v copy on a VP8 WebM. VP8 cannot live in an MP4 container. Fix: Re-encode the video: use -c:v libx264 instead of -c:v copy.

Error 3: No sound after conversion

Cause: The audio was left as Opus/Vorbis via -c:a copy, which most MP4 players cannot decode. Fix: Re-encode audio with -c:a aac -b:a 128k.

Error 4: File takes a long time to start playing online

Cause: The moov atom is at the end of the file. Fix: Add -movflags +faststart (already in every command above).

Error 5: Colors look slightly washed out

Cause: Color metadata isn’t carried through on some captures. Fix: Tag the standard HD color space explicitly:

ffmpeg -i input.webm -c:v libx264 -crf 20 -colorspace bt709 -color_primaries bt709 -color_trc bt709 -c:a aac -b:a 128k -movflags +faststart output.mp4

FAQ

Q1. Does converting WebM to MP4 lose quality? A. Re-encoding (H.264) is lossy, so there is a small, usually invisible quality loss at CRF 18–23. If you stream-copy VP9 with -c:v copy, the video is bit-for-bit identical — only the re-encoded audio changes.

Q2. Should I keep VP9 or switch to H.264? A. For maximum compatibility (phones, editors, TVs), use H.264. If your audience is modern browsers only, VP9 is more efficient — but then you might as well keep the WebM.

Q3. My WebM has no audio. Will the command fail? A. No. FFmpeg produces a video-only MP4 and ignores the unused audio options.

Q4. What bitrate should I use for the AAC audio? A. 128k is transparent for speech and typical content; use 192k for music-heavy material. There is little benefit above 256k for stereo AAC.

Q5. Can I convert a screen recording WebM to MP4 the same way? A. Yes — OBS and browser screen recorders output standard VP8/VP9 + Opus WebM, so the Section 2 command works as-is.

Q6. Is there a faster way if I just need a rough preview? A. Use -preset veryfast and a higher CRF such as 26. It finishes much sooner at a modest quality cost.



Tested with FFmpeg 8.1 — verified with our command-check script Primary sources: ffmpeg.org/ffmpeg.html / ffmpeg.org/ffmpeg-codecs.html