Posted on July 29, 2020
This post will be about how to make WebM's using the free and open source encoder, FFmpeg
"WebM is an open, royalty-free, media file format designed for the web. WebM defines the file container structure, video and audio formats. WebM files consist of video streams compressed with the VP8 or VP9 video codecs and audio streams compressed with the Vorbis or Opus audio codecs."
The only thing that is needed is FFmpeg, which can be downloaded in a few different ways, choose the right version for your operating system:
sudo apt install ffmpeg
sudo pacman -S ffmpeg
Now that you have the right tools it is time to make your first WebM, go to the directory where is located the video you want to convert and type in:
ffmpeg -i input.mp4 output.webm
ffmpeg: Starts the ffmpeg program.
-i input.mp4: "-i" stands for input, next to it should be the filename of the video you want to convert.
output.webm: Output's filename, can be whatever you want, avoid spaces.
And now you are probably wondering, is it that easy ? The short answer is : No, you might have noticed that your webm is very pixelated, that's because we need to give more parameters to ffmpeg
So here's a more detailed command:
ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 1M -c:a libvorbis output.webm
This may look scary but it's really not,
-c:v Specifies the video codec to use.
-b: Sets the target bitrate. -b:v sets video bitrate
-c:a: Specifies the audio codec to use.
And now you have a high quality WebM
Some WebM's tend to be bigger compared to the original file after being converted, and some website got size limitation (like 4chan & Reddit).
In order to get a lighter WebM the only parameter that needs to be changed is the bitrate, and here's how to calculate it (I'm taking a 4mb limit for this exemple) :
(4MB ÷ seconds) × 8 = bitrate.
*Lenght of the video in seconds
And that's basically all of the basics on making WebM's, even though FFmpeg offers other options such as screen recording, video editing and more...