Converting to WebM, OGG/Theora and MP4.

UPDATE: Now that ffmpeg 0.6 is everywhere, and the preset are good enough, the easiest way to convert a video to WebM is:

$ ffmpeg -i foo.avi foo.webm

Of course, if you want to tweak the transcode options, RTFM ;)

If you want to use the <video> tag, you need to encode your video to 3 formats:

Here is a quick howto:

Building ffmpeg (version >= 0.6)

Create a directory, let's say "myvideos". All the comming commands will make sure that everything stays in this directory. Your system won't be altered.




mkdir ~/myvideos/dist

For these 5 dependencies:

Let's build ffmpeg:

$ LDFLAGS=-L$~/myvideos/dist/lib \
CFLAGS=-I~/myvideos/dist/include \
./configure --prefix=~/myvideos/dist --enable-gpl\
--enable-nonfree --enable-libvpx --enable-libvorbis\
--enable-pthreads --enable-libx264 --enable-libfaac\
$ make && make install


To call ffmpeg:


But first, you need to tell where to find libraries:

export LD_LIBRARY_PATH=~/myvideos/dist/lib/

Here are my 3 command lines to convert to WebM, OGG/Theora and mp4:

Video are resized to 640x360 with a bitrate of 345k.

Hope it helps.

23 Aug 2010 / tweet this / @paulrouget