March 29, 2014

How to publish self-hosted video

Video is just a file. It's similar to image file. It's just a little larger. With link capacity rising exponentially on the client and bandwidth prices dropping exponentially on the server, there's no longer any need to use specialized video hosting like YouTube or Vimeo. Except...

Except for the file format. What exactly is the standard video format on the Internet? It used to be Flash, which is fortunately falling out of fashion. Now there is a <video> tag, which is standard HTML, but the file formats it supports aren't standard at all.

There are three contenders: Ogg, WebM, and MP4 AVC. They all produce video of about the same quality. The only significant difference is in which platforms support which format and how much you have to pay for patent licenses to get your video to users of that platform.

MP4 AVC is the most widespread and the most expensive format. You have to use it to deliver video to users of Internet Explorer and Safari. Apparently Microsoft and Apple earn enough royalties from MP4 that it's worth crippling their browsers and annoying their users.

Interestingly, MPEG-1 and MPEG-2, which are the older versions of MP4 AVC, cannot be played in any browser. Last MPEG-2 patents are guaranteed to expire in 2017. Microsoft and Apple don't like the early patent expiration. Mozilla doesn't like the fact that patents for MPEG-2 are still valid. Thus no support. Perhaps something will change in 2017 as MPEG-2 becomes the only format guaranteed to be free of patents.

WebM is backed by Google and viewable by majority of web users out of the box. Downloadable plugins exist for IE and Safari, but I guess users of those browsers are more likely to switch to Firefox than to install a plugin.

Google has given up its patents covering WebM, but WebM is a fairly new format, which keeps getting upgraded to new versions. Google's patent policy could change with future versions of WebM. Not to mention the possibility of some 3rd party holding a recently granted patent that covers parts of WebM.

Ogg video uses the free Theora codec. Files usually end with .ogv extension. Theora is really just some older version of WebM. While WebM is VP8/VP9, Theora is basically a clone of VP3. VP3 was published around year 2000 while VP8 came out around 2010.

Theora as a standard isn't changing contrary to WebM and MP4. That's not only good because any leftover patents are going to expire between 2020 and 2025, it's also great because it improves compatibility and reduces bit rot of encoded video. These are exactly the properties I look for in a video standard.

I have made my choice. Ogg is free, stable, and compatible. Sorry IE and Safari users. You will get a link to the downloadable codec. Install it to join the party. Or just upgrade to Firefox and you are done. Wikipedia does it this way too. That confirms my good taste.

I tried lots of Ogg software for Windows. Many encoders cannot rescale video, which is essential when publishing on the web. Miro Converter is nice except that it uses inferior compression settings that screw up Ogg/Theora video quality. Many encoders are simply broken.

I will have to use the command line tool ffmpeg2theora or ffmpeg directly. I think the lack of good GUI tools is due to the fact that the less technically skilled people just use video hosting services that handle all this mess for them. I am not very keen on putting 3rd party ads on my video though. I prefer to endure the command line instead.

No comments:

Post a Comment