In this article we will show you how to convert any video into webm format using libvpx with vp8 codec for video.
This is one of the best methods to convert video into webm format in Linux systems (almost any distribution), and it is also an excellent method in Windows and Mac environments.

In this article we are going to convert videos into webm format. As the mp4 format, webm is a container format itself so it can contains streams processed with different encoders. We will be using libvpx to produce video streams in vp8 codec, and libvorbis for the audio streams. This format is with the mp4 format a widely adopted and supported format. These two formats together are commonly used on video sites over the Internet to serve video using HTML5 video tags.

We will be using the program ffmpeg to do the conversions between different formats.

To convert a video file example.mp4 into webm format we can do with the following command:

ffmpeg -i example.mp4 -f webm -c:v libvpx -b:v 1M -acodec libvorbis example.webm -hide_banner

We are using the parameters:

  • -f webm this makes ffmpeg to produce an output file in webm format.
  • -c:v libvpx with this parameter we are specifying to use the libvpx encoder for video. This encoder will produce a stream in vp8 codec format which is the codec we want.
  • -acodec libvorbis with this parameter we are specifying to use libvorbis encoder for audio streams.
  • -b:v 1M with this parameter we are telling ffmpeg to attempt to achieve a bitrate of 1Mb for the output file. This is a big difference with mp4 encoding. We should specify the variable bitrate that we want to achieve. We can aviod this parameter, but the results will be really bad (by default the encoder lowers the quality too much). There is a crf option in the documentation of the encoder that should work like in mp4-h264 encoding but in my personal experience that parameter just doesn't work, so we must use the bitrate option.
  • -hide_banner as usual with this parameter we hide certain information about compilation of ffmpeg.

The need to use a variable bitrate is a big downsize, as there is any good starting option for any video. We should consider video resolution, frame rate, and also the type of video.

Conclusion and recomendations

With the instructions we have seen in this article, we can convert any video to webm format. But when we do this process we should consider:

  • Webm is another excellent video format just as MP4 format. These two formats together are used in lots of Internet sites to serve HTML5 video, because both together offer maximum compatibility (while mp4 formats can be played in devices with iOS, and modern versions of Internet Explorer, webm videos can be played in chrome and firefox browsers). See how to convert videos into mp4 format.
  • Webm encoding process is much slower than mp4 encoding process with libx264.
  • Webm is better in quality-compression ratio than mp4 with libx264. You can have a high quality video in less space, so if you want to store videos and video size is an issue you should consider this format.
    Did you find this article helpful?