In today’s tutorial, we will understand how to convert WebM to MP4 using FFmpeg. WebM and MP4 are video container formats and the underlying audio, video, and metadata can be transferred from one container format to the other (also known as transmuting).
If you want to learn more, go here to read about video codecs and containers.
For now, let’s learn about converting webm to mp4 using a simple FFmpeg command.
Table of Contents
The FFmpeg Convert WebM to MP4 Command
To convert WebM to MP4 using FFmpeg, use the command:
ffmpeg -i input.webm -c:v libx264 -c:a aac output.mp4
- The
-i
flag denotes the input file, followed by the name of the output file. In this case,input.webm
is the WebM file you want to convert, andoutput.mp4
is the name you want for the converted MP4 file. - The
-c:v libx264
and-c:a aac
options are used to set the codecs for video and audio respectively. Here,libx264
is a popular choice for video due to its efficiency, whileaac
is a widely supported audio codec.
Quality and Bitrate Control for WebM to MP4 Conversion
ffmpeg -i input.webm -c:v libx264 -b:v 1M -c:a aac -b:a 128k output.mp4
Here, -b:v 1M
sets the video bitrate to 1 Mbit/s, while -b:a 128k
sets the audio bitrate to 128 Kbit/s. These parameters dictate the quality and size of the output file. Higher values result in better quality but larger files, and vice versa.
Frame Rate Adjustment
ffmpeg -i input.webm -c:v libx264 -r 24 -c:a aac output.mp4
The -r
option lets you set the frame rate. Here, -r 24
sets the frame rate to 24 frames per second. This setting can help synchronize video and audio streams, especially in files where the frame rate differs.

FFmpeg Preset Usage for Efficiency
ffmpeg -i input.webm -c:v libx264 -preset veryfast -c:a aac output.mp4
The -preset
option relates to the speed of the conversion process. Presets range from ‘ultrafast’ to ‘veryslow’. The faster the preset, the quicker the conversion but at the expense of file size. Go here to learn more about FFmpeg’s presets.
Conversion with Stream Mapping
In cases where a WebM file has multiple audio or subtitle streams, FFmpeg allows you to map these streams to your MP4 file. Here’s how to convert a WebM file to MP4 while mapping streams:
ffmpeg -i input.webm -map 0:v -map 0:a -c:v libx264 -c:a aac output.mp4
The -map
option selects which streams to include in the output file. -map 0:v
maps all video streams, and -map 0:a
maps all audio streams from the first input file (specified by 0
before :
).
Batch Conversion with FFmpeg
If you need to convert multiple files, you can use a simple loop. For instance, in a Unix-like system, the following command can be used:
for i in *.webm; do ffmpeg -i "$i" "${i%.*}.mp4"; done
In this loop, ${i%.*}.mp4
generates the output filename by stripping the input file’s extension and appending .mp4
.
Conclusion
I hope this tutorial helped you in converting WebM files to MP4 files. By the way, we have a lot of conversion-style posts on OTTVerse. Go here to learn how to convert FLAC To MP3, or MKV to MP4.

Krishna Rao Vijayanagar
Krishna Rao Vijayanagar, Ph.D., is the Editor-in-Chief of OTTVerse, a news portal covering tech and business news in the OTT industry.
With extensive experience in video encoding, streaming, analytics, monetization, end-to-end streaming, and more, Krishna has held multiple leadership roles in R&D, Engineering, and Product at companies such as Harmonic Inc., MediaMelon, and Airtel Digital. Krishna has published numerous articles and research papers and speaks at industry events to share his insights and perspectives on the fundamentals and the future of OTT streaming.