HTML5 video codec support
What codecs will be supported with the HTML5 video tag?
开发者_如何转开发Will it vary by browser, or is there a spec of specific codec that will be supported?
According to wikipedia:
The current HTML5 draft specification does not specify which video formats browsers should support in the video tag. User agents are free to support any video formats they feel are appropriate.
HTML5 is in draft format though and this may change.
There is an ongoing debate about the suitability of various algorithms and it seems that currently not everyone involved is able to agree on an answer. The three major contenders are Ogg/Theora, H.264 and VP8/WebM. The present state of the various implementations varies between the browsers.
The current HTML5 draft spec states:
It would be helpful for interoperability if all browsers could support the same codecs. However, there are no known codecs that satisfy all the current players: we need a codec that is known to not require per-unit or per-distributor licensing, that is compatible with the open source development model, that is of sufficient quality as to be usable, and that is not an additional submarine patent risk for large companies. This is an ongoing issue and this section will be updated once more information is available.
The most detailed description of the HTML5 video situation I've read is in the Dive Into HTML5 book.
The spec does not mandate specific codecs.
For a long time, there was a strong divide between browser vendors. Firefox would not implement H.264 due to patent issues. Apple would not implement Ogg Theora due to concerns about lack of hardware implementation and bandwidth issues, as well as some vague concerns about submarine patents. Google said that they wouldn't encode YouTube video in Ogg Theora, due to quality and bandwidth concerns, though they implemented both H.264 and Ogg Theora in Chrome. I believe that Opera also was concerned about H.264 patents, and Microsoft was in favor of H.264 and against Theora.
Then Google bought On2, and created WebM, a specification including VP8 video and Ogg Vorbis audio in a Matroska container. Firefox, Chrome, and Opera all committed to supporting WebM. Microsoft and Apple have not yet embraced it, though Microsoft has said they will support VP8 video "when the user has installed a VP8 codec." This sounds like a situation similar to that of Safari; you can install QuickTime plugins to support other codecs, like Ogg Theora or VP8/WebM, but it doesn't support it out of the box.
The real question here is what people will support on mobile hardware. Because there is special purpose hardware to accelerate decoding, patents become much more of an issue, and due to limited resources, just supporting a long list of codecs becomes a lot less feasible. Google has promised to support WebM in Android 3, which is due by the end of this year, but I wouldn't bet on Apple or Microsoft implementing it any time soon.
The likely answer is that there won'e be one standard codec for a while. The best approach to get video that will play everywhere would be to encode in Ogg Theora and H.264, and use two <source>
elements to refer to them. As browsers increasingly support WebM (Firefox 4, Chrome 6), you will likely want to transition to encoding in both H.264 and WebM. You could start encoding in all 3 now, but that's a bit redundant as most browsers which support WebM also support Ogg Theora.
Originally, Ogg Theora video was the expected lowest common denominator. However, companies such as Nokia and Apple expressed concern over that format and the specification was changed to avoid listing a specific codec. This leaves us with three formats, none of which are fully supported in all major browsers.
Currently, the situation looks like this:
- Internet Explorer 8 and below do not support the video tag at all. IE 9 will support H.264.
- Firefox 3.5+ supports Ogg Theora. Firefox 4+ supports VP8 (WebM).
- Chrome 3+ supports Ogg Theora. Chrome 6+ supports VP8. H.264 support is about to be dropped.
- Safari 3.1+ supports H.264.
- Opera 10.50+ supports Ogg Theora. Opera 10.60+ supports VP8.
If you consider the current market share of each browser, the most common support is Ogg Theora and the least common is H.264, largely due to Ogg Theora not being encumbered by any known patents whereas H.264 is. Due to the costs behind H.264 support, Firefox will most likely never support H.264 and Opera has taken a similar stand. With Chrome now in the same boat, the only current browser that supports it is Safari. However, Ogg Theora is widely considered a mediocre format (its advantage being openness rather than the encoding itself), so VP8 support is growing as an alternative open/free format. So, for the time being at least, codec support varies. The most likely format to gain universal native support is VP8, but it's not going to happen in the near future.
Note that this covers only native support. For instance, it's possible to add H.264 support to Firefox 3.6+ with a plugin.
Other platforms of note:
- iOS supports H.264.
- Android supports H.264. Android 2.3 adds WebM support.
It looks like IE9 supports WebM as Well as H.264
http://www.eweek.com/c/a/Application-Development/Microsoft-Updates-IE9-HTML5-Video-with-WebM-Support-213252/
And it looks like Microsoft is also providing a plugin for Chrome to support H.264
精彩评论