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:
- WebM/VP8
- OGG/Theora
- MP4/h264
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.
Downloads:
- ffmpeg source code: here.
dependencies:
Build:
mkdir ~/myvideos/dist
For these 5 dependencies:
- un-compress;
- go to the source directory;
./configure --prefix=~/myvideos/dist && make && make install
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\
--enable-libtheora
$ make && make install
Convert
To call ffmpeg:
~/myvideos/dist/bin/ffmeg
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:
- OGG/Theora
ffmpeg -i input.mov \
-acodec libvorbis -ac 2 -ab 96k -ar 44100 \
-b 345k -s 640x360 output.ogv
- WebM/vp8
ffmpeg -i input.mov \
-acodec libvorbis -ac 2 -ab 96k -ar 44100 \
-b 345k -s 640x360 output.webm
- MP4/h264
ffmpeg -i input.mov \
-acodec libfaac -ab 96k \
-vcodec libx264 -vpre slower -vpre main \
-level 21 -refs 2 -b 345k -bt 345k \
-threads 0 -s 640x360 output.mp4
Video are resized to 640x360 with a bitrate of 345k.
Hope it helps.