Converting to WebM

WebM is the video codec Google is backing for in-browser video. Chrome and Opera have support and Firefox will soon.

YouTube is in the process of converting their videos to webm and if you join the HTML5 trial they’ll serve them in <video> tags.

I wanted to convert some videos of my own, but ran into a few problem. The number one Google hit for convert webm is Miro converter. I ran a video through it, but a few minutes in playback got jerky. I noticed that the converter is a front end for ffmpeg.

The binary they use is a subversion build from May 2010, so I downloaded a recent windows build and replaced C:Program Files (x86)Participatory Culture FoundationMiro Video Converterffmpeg-binffmpeg.exe with the download. Someone had fixed the problem in the last 10 months and the jitter diappeared.

The converter only allows processing one file at a time and I wanted to process a directory (and use variable bitrate audio), so ultimately I abandoned the GUI and went with the command:

ffmpeg.exe -i "${input}" -f webm -vcodec libvpx -acodec libvorbis -aq 100 -sameq "${input%.*}.webm"

To test quality and file sizes, I ran the following program against mine and Jenni’s Valentine’s flick:

#!/bin/bash

INPUT="Tangled.avi"
OPTS="-f webm -vcodec libvpx -threads 2 -acodec libfaac -aq 100 -sameq"

time ffmpeg -i $INPUT $OPTS -an -pass 1 ${INPUT%.*}.1.webm
time ffmpeg -i $INPUT $OPTS -pass 2 ${INPUT%.*}.2.webm
time ffmpeg -i $INPUT $OPTS $OUTPUT ${INPUT%.*}.webm

The conversion process wasn’t flawless, but it’s pretty good. There’s blurring of some small features in the webm version. I really need to run both against a DVD source to compare properly.

There was significant file size savings:

  • Original AVI: 1.4gb
  • One-Pass WebM: 571mb
  • Two-Pass WebM: 597mb

AVI Screenshot
Single-Pass WebM Screenshot
Two-Pass WebM Screenshot

The command for extracting screenshots using ffmpeg was:

ffmpeg -i ${INPUT} -ss 00:16:35 -t 00:00:02 -an ${OUT}%d.png

The more marked differences were between the single- and two-pass versions. In the single-pass version it’s possible to see luminance changes every couple seconds:

Those aren’t present in the two-pass version:

The command for extracting the clips was:

ffmpeg -i ${INPUT} -ss 1:03:50 -t 0:0:29 -acodec copy -vcodec copy ${OUTPUT}

Leave a Reply

Your email address will not be published. Required fields are marked *