Roland's homepage

My random knot in the Web

Open source video encoding with Ogg Theora and Vorbis

The open source software Theora video codec, can together with the Vorbis audio codec and the Ogg container format produce very small files with good quality.

Theora logo

Most high-performance video codecs are encumbered with patents. Not so long ago, a new version of the Theora video codec was released with improved performance. I tested it with version 0.25 of ffmpeg2theora, which creates files with Vorbis sound and Theora video.

The mpg file was produced with

mplayer dvd://1 -dumpstream -dumpfile movie.mpg

Converting to avi format was done with:

mencoder -profile hqmovie -o movie.avi movie.mpg

This profile is covered further down on this page. The ogv file was created with the command:

ffmpeg2theora --sync --aspect 16:9 --croptop 8, --cropbottom 8 -v 7 -c2 movie.mpg

The difference in size between the avi and the ogv file is impressive, especially since I cannot see much difference in quality. The only snag is that mencoder seems to do a better job of creating a better sounding stereo sound from e.g. a AC3 stream. Therefore I tend to do a quick resample of only the sound with:

mencoder -ovc copy -oac mp3lame -idx -o movie-int.avi movie.mpg
Filename Format Remarks Size
movie.mpg MPEG2+AC3 as ripped 6478 MiB
movie-int.avi MPEG2+MP3 sound resampled to MP3 5806 MiB
movie.avi H.264 +MP3 by mencoder (from original MPG) 4481 MiB
movie.ogv Theora/Vorbis by ffmpeg2theora (from original MPG) 1999 MiB
movie2.ogv Theora/Vorbis by ffmpeg2theora (from resampled AVI) 1750 MiB

I cannot see or hear much of a difference between the H.264+MP3 encoded movie and the one encoded with Theora+Vorbis. The H.264 avi file made by mencoder is 70% of the size of the original mpg file. The ogv files are 30% of the size of their original mpg files, and are in my eyes of equal quality to the H.264 encodd AVI files. And since Ogg/Theora is not encumbered with patents like H.264, it makes me think that theora+vorbis is a better choice for encoding video now. I've encoded other movies as well, and constantly find that the size of the theora+vorbis encoded film is around 30-40% of the size of a H.264+MP3 encoding.

For feature films, file size in this OGV format range from 1051 MiB for a 97 minute standard format movie, via 1750 MiB for a 147 minute widescreen movie to 2988 MiB for a 207 minute black/white movie.