Many browser screen recorders and WebRTC captures save WebM files. WebM works well on the web, but editing software, phones and older media players often fail on its VP8/VP9 video and Opus/Vorbis audio. Converting the file to MP4 fixes this. Most of the time that means re-encoding to H.264 video and AAC audio, which play almost everywhere.

1. Why WebM Usually Needs Re-encoding

MP4 is a container: the file format that holds the video and audio streams. Players expect only certain codecs inside it. What plays on iPhones, in Premiere Pro and on smart TVs is basically H.264 or HEVC video with AAC audio.

WebM files carry these instead:

Stream WebM codecs MP4-compatible?
Video VP8, VP9, AV1 VP9/AV1 technically yes, VP8 no
Audio Opus, Vorbis Opus yes (not every player), Vorbis rarely

Opus in MP4 plays in browsers but not in every player. Vorbis in MP4 rarely plays at all, and VP8 cannot go into MP4. So the safe default is to re-encode both streams to H.264 and AAC, which most players and devices can play.

2. The One Command for (Almost) Any WebM

This command re-encodes the video to H.264 and the audio to AAC:

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 … quality level; lower = better quality, larger file
  • -c:a aac -b:a 128k … re-encode audio to AAC at 128 kbps
  • -movflags +faststart … move the file’s index (the moov atom) to the start, so playback can begin before the file has fully downloaded

The same command works for VP8, VP9, Opus and Vorbis input. If the WebM is 10-bit VP9 (profile 2), add -pix_fmt yuv420p. Otherwise the MP4 gets 10-bit H.264 (High 10), which many devices cannot play.

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

CRF (Constant Rate Factor) is the main quality setting. It aims for a steady visual quality and lets the bitrate go up or down as the content needs.

CRF Visual quality Typical use File size
18 Visually lossless Archival, master copies Large
20 Excellent High-quality uploads Medium-large
23 Very good (default) General purpose Medium
26 Good Web previews, drafts Small
28 Acceptable Quick shares, tight storage Smallest

Changing CRF by about ±6 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 takes longer to encode but compresses more efficiently.

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

MP4 can hold VP9 video. If your player supports VP9 in MP4, you can copy the video stream as it is and skip the slow video re-encode:

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

The VP9 video is copied unchanged, so this is fast and lossless. Only the audio is re-encoded to AAC.

Two limits:

  • This works only for VP9 (and AV1). VP8 cannot go into MP4. If you try to copy it, FFmpeg stops with Could not find tag for codec vp8 (Error 2 below).
  • Many players cannot play VP9 in MP4, even though the format allows it. Older iPhones, some smart TVs and Premiere Pro are examples. If the file must play everywhere, re-encode to H.264 with the Section 2 command.

To see which codecs your WebM uses:

ffprobe -hide_banner input.webm

If the output shows Video: vp8, you must re-encode the video. If it shows Video: vp9 and your player supports VP9 in MP4, you can use -c:v copy.

5. Audio: Opus/Vorbis to AAC

WebM audio is almost always Opus (newer files) or Vorbis (older files). Not every player supports Opus in MP4, and Vorbis in MP4 rarely plays, so re-encode the audio 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 (128k is fine for speech)
  • -ar 48000 … resample to 48 kHz, the usual sample rate for video

If the source has no audio track, FFmpeg makes a video-only MP4 and ignores the -c:a option.

6. Speeding Up the Encode

-preset sets the H.264 encoding speed. Faster presets finish sooner but compress less efficiently. At the same CRF, quality and file size both change with the preset, so a slower preset does not always give a smaller file.

Preset Speed Compression efficiency
ultrafast Fastest Lowest
veryfast Fast Lower
medium Default Baseline
slow Slower Higher
veryslow Slowest Highest

For a quick conversion where top quality does not matter:

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

For an archive copy where quality 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 copied the VP9 video with -c:v copy, and the phone cannot play 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 used -c:v copy on a VP8 WebM. VP8 cannot go into MP4. Fix: Re-encode the video: use -c:v libx264 instead of -c:v copy.

Error 3: No sound after conversion

Cause: -c:a copy kept the Opus or Vorbis audio, and the player cannot play Opus or Vorbis in MP4. Fix: Re-encode the 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: On some recordings, the color metadata is not carried over. Fix: Tag the video as the standard HD color space (BT.709). setparams only writes the tags; it does not change the pixels:

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

You will often see the output options -colorspace bt709 -color_primaries bt709 -color_trc bt709 suggested instead. With FFmpeg 8.1 they tag only the color space, and FFmpeg also converts the pixels as if the source were BT.601, which shifts the colors.

FAQ

Q1. Does converting WebM to MP4 lose quality? A. Re-encoding to H.264 loses a little quality. At CRF 18–23 the loss is usually invisible. If you copy VP9 with -c:v copy, the video stays bit-for-bit identical and only the re-encoded audio changes.

Q2. Should I keep VP9 or switch to H.264? A. If the file has to play on phones, in editors and on TVs, use H.264. If it only needs to play in modern browsers, VP9 is more efficient, and then you can keep the WebM as it is.

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 sounds the same as the source for speech and most content. Use 192k for music. Going above 256k gains little for stereo AAC.

Q5. Can I convert a screen recording WebM to MP4 the same way? A. Yes. Browser screen recorders save ordinary VP8/VP9 + Opus WebM files, so the Section 2 command works unchanged.

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 and loses a little quality.