ffmpeg -i input.webm -c:v libx264 -crf 20 -c:a aac output.mp4 turns VP9 and Opus into H.264 and AAC; -c copy only swaps the container. ReelSDK converts an 11-second clip for under three quarters of a cent ($0.02 per compute minute).

Convert WebM to MP4 with ffmpeg

A WebM holds VP9 video and Opus audio. Re-encoding both at CRF 20 takes about 2 seconds per second of video, and ReelSDK's API converted ours in about 16 seconds. Copying into an MP4 is instant, but the streams stay VP9 and Opus.

GuidesUpdated

convert
ffmpeg -i input.webm -c:v libx264 -crf 20 \
  -c:a aac -b:a 128k -movflags +faststart output.mp4

Both streams are re-encoded. -crf 20 keeps the quality high, so the MP4 comes out almost twice the size of the WebM; raise the CRF for a smaller one.

Variations

The other commands you will need

  1. Copy the streams without re-encoding

    MP4 can hold VP9 and Opus, so -c copy only changes the container, in a fraction of a second and at the same size. Use it when the player or site on the other end takes VP9.

    copy
    ffmpeg -i input.webm -c copy -movflags +faststart vp9.mp4
  2. Re-encode only the audio

    Copy the VP9 video and turn Opus into AAC. The audio is the fast part: under half a second for our clip.

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

The flags

The flags in these commands

The flags in these commands
FlagWhat it doesUsed here
-c:v libx264Re-encodes the video to H.264Convert
-crf 20Sets the quality: 0 to 51, 23 is the default, lower is better and biggerConvert
-c:a aac -b:a 128kRe-encodes the audio to AAC at 128 kbit/sConvert, audio
-c copyCopies every stream as it is, so only the container changesCopy
-c:v copyCopies the video and leaves the other streams to their own settingsAudio
-movflags +faststartMoves the MP4 index to the front so playback starts soonerAll

Sources: ffmpeg documentation, FFmpeg H.264 encoding guide, checked November 2026.

Copy or re-encode

A WebM to MP4 conversion is really two questions: which container, and which codecs. Changing the container is cheap: the copy took a fraction of a second. Changing VP9 to H.264 means decoding and encoding every frame, which is why the re-encode took about 22 seconds.

Re-encode when the file goes somewhere that expects H.264. YouTube's recommended upload settings ask for H.264 and AAC in MP4, and Meta's Reels ad specs ask for H.264 with AAC audio. Copy when you control the player and it plays VP9, or when you only need the .mp4 name.

Getting a smaller MP4

VP9 packs more quality into each byte than H.264, so a straight conversion at high quality grows the file. Raise -crf: by the x264 rule of thumb, each step of 6 roughly halves the bitrate, and the CRF guide measures it on our clip. For an MP4 that keeps the size down without leaving MP4, see H.265 with ffmpeg.

To go the other way and make a WebM, see encode VP9 WebM with ffmpeg.

Without installing ffmpeg

The same command as one API call

Send the same args to POST /v1/ffmpeg with the WebM's URL in inputs. Each job runs ffmpeg 8.1 on a fresh machine at $0.02 per compute minute, billed per second; this one finished in about 16 seconds, download and upload included, and cost under three quarters of a cent.

terminalTry it
curl "https://api.reelsdk.com/v1/ffmpeg?wait=60" \
  -H "Authorization: Bearer $REELSDK_KEY" \
  --json '{
    "inputs": {
      "input.webm": "https://api.reelsdk.com/f/lib/out/job_isii70q1qqw45g8no49b/clip.webm"
    },
    "args": [
      "-i", "input.webm", "-c:v", "libx264", "-crf", "20", "-c:a", "aac",
      "-b:a", "128k", "-movflags", "+faststart", "output.mp4"
    ],
    "outputs": ["output.mp4"]
  }'
output.mp4 from the API: H.264 and AAC, about 6.1 MB, converted from a 3.2 MB WebM.Input: clip.webm

FAQ

Questions, answered

How do I convert WebM to MP4 with ffmpeg?

ffmpeg -i input.webm -c:v libx264 -crf 20 -c:a aac -b:a 128k output.mp4 re-encodes VP9 and Opus to H.264 and AAC. Our 11-second clip took about 22 seconds.

Can I convert WebM to MP4 without re-encoding?

Yes: ffmpeg -i input.webm -c copy output.mp4 took a fraction of a second. The MP4 still holds VP9 and Opus, so it only plays where those codecs play.

Why is my MP4 bigger than the WebM?

VP9 compresses better than H.264, and a low CRF asks for high quality. At CRF 20 our MP4 came out almost twice the size of the WebM, about 6.1 MB against 3.2 MB. Raise the CRF for a smaller file.

Can I convert WebM to MP4 with an API?

Yes. Send the same args to POST https://api.reelsdk.com/v1/ffmpeg with the WebM's URL in inputs. It runs ffmpeg 8.1 on a fresh machine per job for $0.02 per compute minute, billed per second, and failed jobs are free.

Ready to build?

Ship video from your app today

Your first $0.50 is free, and one key covers every endpoint.

Moonlit lake with a lit cabin under the mountains