Encoding WebM using ffmpeg

Since a new batch of distributions got released like Ubuntu Maverick Meerkat, ffmpeg 0.6 has made it into the mainstream, allowing easy encoding of WebM.

If you’d like to encode your own high quality WebM movies, you can do it like so, first make sure you have a libvpx_720p ffmpeg preset, check if /usr/share/ffmpeg/libvpx-720p.ffpreset exists, if not create it and put the following content in it:

  vcodec=libvpx
  g=120
  rc_lookahead=16
  level=216
  profile=0
  qmax=42
  qmin=10
  vb=2M
  #ignored unless using -pass 2
  maxrate=24M
  minrate=100k

Then you can use the following commandlines to encode your movie (using two-pass mode):

# ffmpeg -i input.mp4 -s 1280x720 -vpre libvpx-720p -b 3900k -pass 1 \
         -an -f webm -y output.webm
# ffmpeg -i input.mp4 -s 1280x720 -vpre libvpx-720p -b 3900k -pass 2 \
         -acodec libvorbis -ab 100k -f webm -y output.webm

Using a video bitrate of 3900kbit produces very high quality for a resolution of 1280×720. When encoding a resolution of 960×540 a video bitrate of 2000kbit produces similar high quality.