What is webm and why should you use it?
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.
Two-pass CRF 25
This video file takes 4,98 MB.
Two-pass CRF 55
This video file takes 726 kb.