If you are converting one file, a browser tool is faster than opening a terminal. If you are converting two hundred files, or working on a server, or need precise control over the encode, ffmpeg is the right tool. Here is what to run.
The command
ffmpeg -i input.webm -c:v libx264 -preset veryfast -crf 23 \
-c:a aac -b:a 192k -movflags +faststart output.mp4
What each flag does
| Flag | Purpose |
|---|---|
-i input.webm | The source file. |
-c:v libx264 | Encode video with the x264 encoder, producing H.264 — the codec with the widest playback support in existence. |
-preset veryfast | How much effort the encoder spends looking for savings. Slower presets give smaller files at the same quality. Options run from ultrafast to veryslow. |
-crf 23 | Constant Rate Factor: the quality target. Lower is better and larger. 18 is near-lossless, 23 is the default, 28 is visibly compressed. |
-c:a aac | Re-encode the Opus or Vorbis audio as AAC, which MP4 supports properly. |
-b:a 192k | Audio bitrate. 128k is fine for speech, 192k is a safe general default. |
-movflags +faststart | Moves the file index to the beginning so the video can start playing before it has fully downloaded. Essential for web playback. |
Variations worth knowing
Maximum compatibility, including older devices
ffmpeg -i input.webm -c:v libx264 -profile:v baseline -level 3.0 \
-pix_fmt yuv420p -c:a aac -b:a 128k -movflags +faststart output.mp4
The baseline profile drops features that older hardware decoders cannot handle. Files are larger, but they play on almost anything.
Higher quality for editing
ffmpeg -i input.webm -c:v libx264 -preset slow -crf 18 \
-c:a aac -b:a 256k output.mp4
Convert every WebM in a folder
On macOS or Linux:
for f in *.webm; do
ffmpeg -i "$f" -c:v libx264 -crf 23 -preset veryfast \
-c:a aac -b:a 192k -movflags +faststart "${f%.webm}.mp4"
done
On Windows PowerShell:
Get-ChildItem *.webm | ForEach-Object {
ffmpeg -i $_.Name -c:v libx264 -crf 23 -preset veryfast `
-c:a aac -b:a 192k -movflags +faststart "$($_.BaseName).mp4"
}
Audio only
This is what the WebM to MP3 converter runs:
ffmpeg -i input.webm -vn -c:a libmp3lame -b:a 192k output.mp3
Errors you are likely to hit
Unknown encoder 'libx264'
Your ffmpeg build was compiled without x264. The static builds from ffmpeg.org include it; the ones in some minimal package repositories do not. Install a full build.
height not divisible by 2
H.264 requires even dimensions. Add a scale filter that rounds down:
-vf "scale=trunc(iw/2)*2:trunc(ih/2)*2"
The video plays but there is no sound
The audio stream was probably copied rather than re-encoded. Make sure -c:a aac is present rather than -c:a copy, since MP4 cannot reliably carry Opus.
It is extremely slow
Use a faster preset. Moving from slow to veryfast can cut encoding time by more than half for a barely perceptible quality difference at the same CRF.
Why not just copy the stream?
You cannot. -c:v copy works when moving between containers that support the same codec — MKV to MP4, for instance, where both hold H.264. WebM holds VP9 or VP8, which MP4 has no meaningful support for, so the video genuinely has to be re-encoded. That is why WebM to MP4 always takes real time, while MKV to MP4 is often instant.