Today, Google, in co-operation witt Opera, Mozilla, CoreCodec (Matroska developers) and a range of other companies, have announced at Google I/O 2010 that WebM is the new royalty free video codec for the web.
Earlier this year, Google purchased On2, the company that developed of a range of video codecs including VP3, VP6, VP7 and VP8. VP3 is a well known codec that formed the basis of Theora. VP6 is a codec supported by Adobe Flash, VP7 is used by Skype for video conferencing. Their latest offering, VP8, now forms the basis of the new WebM video format. The code for the VP8 codec has been released royalty free under the BSD licence.
WebM, which stands for Web Media, is a format based on 3 technologies:
- Container: A variation of Matroska called WebM.
- Video codec: VP8.
- Audio codec: Vorbis.
The Container Format
Matroska is a widely supported container format, which is able to contain a wide range of codecs, including, among others, h.264, VC-1, Theora, AAC, AC3 and Vorbis. This is due to the high degree of flexibility inherent in the design of Matroska.
Matroska itself if based on a binary markup language called EBML, the design of which was inspired by XML. In short, EBML files contain a header that declares the DocType and version information, followed by a tree of elements and data, marked up using a special binary notation. The Matroska specification defines a range of elements, and their binary notation, that can be used for marking up the data in Matroska files.
The WebM format is a subset of Matroska, which has been optimised for streaming over HTTP.
WebM, which uses the DocType “webm”, can be distinguished from Matroska, which uses the DocType “matroska”. Technically speaking, a valid WebM version 1 file supports a subset of elements from Matroska version 1, and WebM version 2 supports those in addition to some of the additional elements from Matroska version 2.
To further optimise WebM for use on the WebM, some additional formatting guidelines are imposed upon WebM files, over and above the Matroska counterpart. These guidelines include plaicing the indexing information at the beginning of the file, and keyframes stored at the beginning of clusters.
The WebM container is only permitted to contain the codecs VP8 and Vorbis, and browsers will not support any other codecs within WebM – not even Theora or h.264. Although there are no technical limitations with WebM that inherently prevent such codecs from being used, this was an intentional decision to improve the usability of WebM.
The idea being that if you have a player that supports WebM, you can be more confiden that the file will play without having to install additional codecs. This is a problem that has plagued container formats like AVI for years. You can’t easily determine what it contains until you start playing it. Some AVI files may contain DivX, Xvid, h.264 or a wide range of other codecs.
Benefits of Matroska
Matroska presented some nice benefits over competing container formats, sucha s MP4, commonly used with h.264, or even Ogg, which is supported by Opera, Firefox and Chrome for Theora and Vorbis. Like Ogg, Matroska is publicly specified and available to use freely, unlike, for example, MP4.
The main benefit of Matroska over Ogg is that the seeking information can be placed at the beginning, making it significantly easier to seek in a WebM file being transferred over HTTP. When the user tries to seek, if that part of the video hasn’t yet downloaded, then the browser needs to request that section from the server.
For Ogg, browsers have to do at least 2 separate requests when a video loads â€” one to get the beginning of the file and a range request to get the end â€” before the length of the video can be determined, and before seeking can occur, which then potentially results in additional requests.
For WebM, all the information is presented up front, meaning that if a user seeks the video, the browser knows exactly where in the video to go, or which part of the file to request from the server.
This is not to say that Ogg itself is a bad format. Quite the contrary, it’s just optimised for different use cases. Ogg is very good to use as a streaming container format where seeking is not required, or for storing your Vorbis encoded music collection locally, where the player isn’t subject to the overhead of HTTP requests.
WebM, on the otherhand, had to be specifically designed for use with the HTML video element served over HTTP, and as such, benefited from the design decisions of Matroska.
Audio and Video Codecs
The VP8 codec provides significant quality enhancements over its predecessors; most notably Theora. Comparisons between Theora and h.264 have shown that the quality of Theora is not up to scratch. Thanks to Google, VP8 has now been released freely.
There haven’t yet been any serious, independent comparisons between h.264 and VP8, so it’s difficult to say which is better. Although h.264 is certainly more mature than VP8, and has a lot more hardware support in existing devices, VP8 is likely to continually improve over the coming years.
The main limitation with VP8 at the moment is the lack of hardware acceleration. Firefox, Opera and Chrome all currently use software decoding of VP8, which means that it can increase CPU usage, particularly for high definition videos, and watching a lot of video will drain your battery more than hardware decoded h.264.
However, Google have announced that they are working with hardware partners, and its possible that we’ll see devices shipping with support within a year or two.
Vorbis, of course, has been supported by Firefox, Opera and Chrome for a while already, and so it was a natural choice to use in combination with VP8 in WebM.
Over the past few weeks, YouTube has been working to convert many existing videos into WebM. To try this out using a browser that supports WebM, follow the instructions provided by the WebM Project. While not all videos have been re-encoded yet, thousands of videos are already available in WebM format, and will work in Opera, Firefox and Chrome.
Just so you can see for yourself what VP8 looks like, get yourself a copy of the preview releases of Opera, Firefox and Chrome, sit back, relax and watch Elephant’s Dream from the Orange Open Movie Project (website). I encoded this myself from the lossless source files using a special build of ffmpeg with libvpx_vp8 (the VP8 codec library).
Creating Your Own Videos
The absolute easiest way to create your own WebM video is to upload your source video to YouTube and wait for it to be encoded. Other services, including encoding.com and HD Could also offer transcoding services for a small fee.
If you want to encode the videos yourself, you need to get your hands dirty with a tool like ffmpeg with libvpx_vp8, or a commercial alternative. Google have released the source code for libvpx_vp8, and builds of ffmpeg with it should be available shortly. More information is available on the The WebM Project tools page
The Matroska developers have also been working on on updating their Matroska muxing software to support the WebM profile. New tools called mkvalidator and mkclean will help you to validate your WebM files, and to clean and remux files that aren’t valid. mkclean will also remux MKV files containing VP8/Vorbis to WebM.
More details are available on WebMProject.org.