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
ffmpeg -i input.webm -c:v libx264 -crf 20 \
-c:a aac -b:a 128k -movflags +faststart output.mp4Both 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
Copy the streams without re-encoding
MP4 can hold VP9 and Opus, so
-c copyonly 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.mp4Re-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
| Flag | What it does | Used here |
|---|---|---|
-c:v libx264 | Re-encodes the video to H.264 | Convert |
-crf 20 | Sets the quality: 0 to 51, 23 is the default, lower is better and bigger | Convert |
-c:a aac -b:a 128k | Re-encodes the audio to AAC at 128 kbit/s | Convert, audio |
-c copy | Copies every stream as it is, so only the container changes | Copy |
-c:v copy | Copies the video and leaves the other streams to their own settings | Audio |
-movflags +faststart | Moves the MP4 index to the front so playback starts sooner | All |
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.
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"]
}'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.
- Convert MOV to MP4 with ffmpegRemux an H.264 MOV to MP4 with -c copy in a fraction of a second, and transcode ProRes, which MP4 can't hold, to H.264.
- Convert MKV to MP4 with ffmpegRemux MKV to MP4 without re-encoding, keep the subtitles as mov_text, and avoid the -c copy that drops them without a word.
- Encode VP9 WebM with ffmpegMake a VP9 WebM with libvpx-vp9 and Opus: constant quality with -crf, the -b:v 0 rule, -row-mt, -cpu-used and two passes, measured.
- Choose a CRF value in ffmpegWhat CRF does in libx264, the file size and VMAF score for CRF 18, 23, 28 and 33 on one clip, and how x265's scale differs.
- Encode H.265 (HEVC) with ffmpegEncode HEVC with libx265: CRF 28 against x264 CRF 23 on one clip, the hvc1 tag Apple players need, and 10-bit output.
- Add faststart to an MP4 with ffmpegMove the moov atom to the front of an MP4 with -movflags +faststart so it plays before the download ends, and check where it sits.
- Video conversionConvert WebM, MKV or MOV to MP4 and back in one ffmpeg call, about a third of a cent for a 30 s clip.
Ready to build?
Ship video from your app today
Your first $0.50 is free, and one key covers every endpoint.
