What is webm and why should you use it?
To better understand what webm is you can watch this short video explanation: What is WebM?. Good news is that as of 2018, most browsers support VP9. See more here https://caniuse.com/#feat=webm. So what is the advantage with Webm (vp9) over MP4 h.264? Basically libvpx-vp9 can save about 20–50% bitrate compared to libx264.
Easy: ffmpeg simple encoding
It is really easy to encode video to webm with ffmpeg. The short form here is:
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 45 -b:v 0 output.webm
-crf 45 is the video quality. Lower is better. 0 is lossless. 63 is the worst possible quality. The file size will depend on this. For better quality we set the
0 which enables “constant quality” (CQ) mode that will ensure that every frame gets the number of bits it deserves to achieve a certain (perceptual) quality level, rather than forcing the stream to have an average bit rate.
Recommended: ffmpeg two-pass encoding
Two-pass encoding means that ffmpeg will run the encoding process twice. The first time it will analyze the input file and make a log file. In the second pass ffmpeg will use the log file to encode the video. This method takes longer, but will create more efficient encodes when a particular target bitrate should be reached.
ffmpeg -y -i original.mkv -c:v libvpx-vp9 -crf 40 -b:v 0 -pass 1 -an -f webm NUL && ^ ffmpeg -y -i original.mkv -c:v libvpx-vp9 -crf 40 -b:v 0 -pass 2 crf40.webm
Note that the
NUL && ^ is for Windows only. On linux you can use
/dev/null && \
Here are some image and video comparisons in case you are wondering which
CRF to use.
This video file takes 37,2 MB. \[/video]
Two-pass CRF 25
This video file takes 4,98 MB. \[/video]
Two-pass CRF 55
This video file takes 726 kb. \[/video]
Any good WEBM software alternatives?
I really like webm for retards which can be downloaded from: https://gitgud.io/nixx/WebMConverter#webm-for-retards-. It’s a lightweight software that, in addition to do the same as above, allows you to set a target file size for the output file. Although I prefer CLI it is really nice to avoid the calculation of the bitrate to achieve a specific size. Also WebMCam is super great for just simple screen capturing to WEBM.