mediacodec.dev

Convert MP4 to WebM

WebM is the open, royalty-free container for the web. This command re-encodes your video with a quality target (CRF) instead of a fixed bitrate, so the encoder spends bits where the picture actually needs them.

Video codec

-c:v

libvpx-vp9: plays effectively everywhere (Chrome, Firefox, Edge, and Safari 16.4+). The safe default for the open web in 2026.

WebM carries VP9 or AV1 video. Both are royalty-free; the trade-off is compression efficiency versus encode time and playback reach.

Quality (CRF)

-crf
bettersmaller32

CRF 32: the sweet spot for 1080p web delivery. Minor artifacts in complex motion, big savings.

Constant Rate Factor: a quality target rather than a bitrate. Lower numbers mean better quality and bigger files. VP9 and AV1 use a 0–63 scale; the numbers are not comparable to x264’s 0–51 scale.

Encode speed

-deadline · -cpu-used

VP9 -cpu-used 2 / SVT-AV1 -preset 6. The sensible default: most of the quality at a reasonable speed.

Every encoder trades time for compression. Slower settings search harder for savings: the file gets smaller at the same CRF, but the encode takes longer.

Audio bitrate (Opus)

-b:a

Transparent for most music and mixed content. The default.

WebM pairs with Opus audio, the best lossy audio codec in general use. 128 kbps stereo is transparent for most content and listeners.

Strip metadata · off

-map_metadata -1

Removes global tags from the output: titles, encoder stamps, GPS and camera metadata. Sensible for anything you publish.

Your command

ffmpeg -i input.mp4 \
  -c:v libvpx-vp9 -crf 32 -b:v 0 \
  -row-mt 1 -deadline good \
  -cpu-used 2 -c:a libopus \
  -b:a 128k \
  output.webm

Worth knowing

-b:v 0 is required for true CRF mode with libvpx-vp9: without it, VP9 treats CRF as a ceiling on a default bitrate target and quality suffers.

-row-mt 1 turns on row-based multithreading in VP9: a large speedup with no quality cost. It is off by default.

SVT-AV1 is the AV1 encoder FFmpeg recommends for distribution encodes; libaom-av1 is slower for similar quality at these settings.

Run this on your own file

no FFmpeg · runs in this tab

The command above needs FFmpeg on a machine. The settings it encodes do not: your browser can perform the same operation on a real file, right here, through WebCodecs.

Drop a video or audio file here, or

Files are processed in this tab and never uploaded.

WebCodecs has no CRF, so -crf 32 becomes a bitrate target for the output resolution, using the rule that every 6 CRF steps halve or double the size.

Encode speed presets are not exposed through WebCodecs; your encoder picks its own trade-off.

Waiting on a file.