Transcoding with Theora 1.1/1.2 using ffmpeg2theora 0.28 or better for your own collection in Linux and HTML 5 video

Introduction



Today, I am going to be showing you how to encode with Theora 1.1 library using ffmpeg2theora 0.28 tool in Linux. Briefly, Theora is an open source video codec, that was donated to the Xiph.org foundation by On2 video in 2004 (The same company Google recently bought that consists of VP8 codec portion in WebM!). Attempts where made to include it in the HTML 5 standard in 2007, by members of the W3C. Those attempts were met with heavy resistance. One of the main problem with the earlier builds of Theora, was the perceived lack "quality" with encoder and how it was not on "par" with H.264 standard put forth by the MPEG consortium. Proponents of the H.264 video, claimed it was "inferior", because it did not have the same level of glossy sophistication and there were too many macro-blocking artifacts, due to a older codebase with no bi-predictive frames, such as those of the newer more advanced H.264 codec.

The lead developer and engineer of many Xiph.org projects "Monty", attempted to alleviate those problems by optimizing Theora gradually over a number of years using a number of "hacks" to improve the overall PSNR (Perceptual Signal Noise Ratio), which are used to measure the "perceived" quality of video codecs. As of the 0.28 release, Theora might not have the same quality as the high profile mode in H.264 or WebM, but it most certainly can match the baseline profile of H.264, which is used by many low-end AVCHD higher definition camera's! Therefore, you can use it as an alternative to WebM and H.264, due to the fact that it still looks good on a lot of transcoded SD and HD film clips. This is especially true with the recent "hacks", which deal with motion compensation in "dark contrast" area's, much more efficiently.

Think of Theora as yet another "open" alternative that can be used in different situations, rather then a project that should be shunned forever! Now that we have got the a substantial portion of History out of the way, I can begin to show you how to encode with either Theora 1.1/1.2 depending on what libraries the ffmpeg2theora [1] tool was compiled with in your distro! I will not show you how to compile custom builds yourself in this post. I will leave that part up to you, if you so wish to do so using alpha 1.2 libraries (I don't think it will be necessary and you should proceed at your own risk if you decide to go that route, but you are welcome to do so). Now I can begin to show you a number of command-line samples, that you can "tweak" to encode different clips for different types of input:

Common Usage: Encoding a group of MPEG-2 files filmed in MPEG-2 480i standard definition using a regular camcorder.



Example one: Transcoding and upsampling a group of MPEG-2 SD 480i files with a 4:3 aspect ratio to HD 720p using bicubic interpolation single pass "good" quality with a 5.1 surround track.

$ffmpeg2theora -v 10 -x 1280 -y 720 --resize-method bicubic --a 2 --deinterlace /home/USER/Videos/*.vob

Common Usage: Encoding a group of H.264 files filmed in high definition using an AVCHD camcorder.



Example two: Transcoding a group of H.264 files filmed in 720p with a 16:9 aspect ratio in high definition using an AVCHD camcorder using single pass "good" quality with 5.1 audio track.

$ffmpeg2theora -v 8 -x 1280 -y 720 -a 2 /home/USER/Videos/*.mp4

Common Usage: Encoding a group of H.264 files filmed in high definition using an AVCHD camcorder.



Example three: Transcoding a group of H.264 files filmed in 1080p with a 16:9 aspect ratio in high definition using an AVCHD camcorder using single pass "good" quality with 5.1 audio track.

$ffmpeg2theora -v 8 -x 1920 -y 1080 -a 2 /home/USER/Videos/*.mp4

Common Usage: Encoding a group of H.264 files filmed in high definition using a high definition webcam



Example four: Transcoding a group of H.264 files filmed in high definition 720p with a 4:3 aspect ratio using a high definition webcam using two pass "good" quality with a stereo soundtrack.

$ffmpeg2theora -v 8 -x 1280 -y 720 --two-pass -a 5 /home/USER/Videos/*.mp4

Those are just a few example of what you can do with Theora to encode material and place them within a webpage using HTML 5. Theora maybe "shunned" by many, but with newer releases comes slightly newer improvements. It's still quite popular on websites like Wikipedia and Internet Archive, therefore is not "loosing" any ground. Hopefully, this tutorial has provided you with some insight and motivation to begin encoding with Theora including some presets you can use! Enjoy. If you have any comments or question, and you can think of ways in which we can improve this tutorial do not hesitate to leave any comments or contact me. I will more then likely, be back with one more entry, before the week is over or next week, with a completely new entry of a different I.T topic from the "old" blog or new entry all together. Thanks for reading! Have a nice weekend. Take care!

Reference:



1. Theora. "ffmpeg2theora". http://v2v.cc/~j/ffmpeg2theora/ accessed 29 Nov 2012. 2011


Comments

Popular posts from this blog

Encoding Opus files in Linux with opusenc for your own collection and HTML 5

Encoding Vorbis files in Linux using oggenc for your own music collection and HTML 5

Transcoding H.264 files to Google's WebM format (VP8/Vorbis) in FFMPEG 0.6 or better using Linux for your own collection and HTML 5