Blog

An eclectic collection of articles, case studies and opinion pieces ranging from the creative process to technical tips

  • IE9 does support H.264
    IE9 does support H.264

Anyone with a beedie eye will have noticed a conflict between the fmbip.com/litmus tests for Microsoft's new IE9 Beta and the results you get if you actually test the browser yourself. This is because one result has been doctored following a request from the IE9 team to correct, or so I thought, a bug in Modernizr.

After reading a listening to some experts in the field of HTML5 testing and doing a lot of digging and reading of the W3C specifications for HTML5 <video>, the RFC specification for codecs defenition and reading Microsoft's examples of testing I've come to the conclusion that this is a bug in the IE9-beta's parsing of the codec defenition.

For the moment I don't know, entirely, whether this assumption is correct?

HTML5 Video Testing

Because HTML5 supports lots of different audio and video compression systems and because these can be delivered in different 'wrappers' defined by different MIME Types you have to ask the browser or device your user is using whether or not it thinks it can support the format combinations you have available.

This can be done using the type attribute of the <video> tag or, in these examples, the canPlayType() method of the same video object the tag represents... like so.

 // The test for H.264 Video (including AAC audio) // Returns 'probably' document.createElement("video").canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"');                           ^                      ^                   ^           ^                           |                      |                   |           |                           /                      |                   |           | The <video> element                               The MIME Type, wrapping video & audio                                                  The specifier for baseline H.264 video                                                  The specifier for low-complexity AAC audio 

Bug? IE9 or Modernizr?

In this test we're asking the browser whether it can support H.264 video and AAC audio wrapped up in an MPEG-4 container, which IE9 correctly answers "probably" (as good an answer as HTML5 will give you).

The problem lies in testing for the H.264 component without the AAC audio track. If you ask simply whether it supports the H.264 without AAC audio the response is no.

 // The test for H.264 Video (without AAC audio) // Returns '' (false) document.createElement("video").canPlayType('video/mp4; codecs="avc1.42E01E"');                           ^                      ^                   ^     ^                           |                      |                   |     |                           /                      |                   |     | The <video> element                                The MIME Type, wrapping video & audio                                                    The specifier for baseline H.264 video                                                    NB; no audio codec specified...  

Because Modernizr is only interested in the video element (at the moment it runs this specific test) it only tests for the video codec... which gives a false negative result. But is this a problem with the way Modernizr asks the question or the way IE9 responds?

Getting a better response from IE9

It is possible to get IE9 to provide a better reponse ('maybe') to the question do you support H.264 video in isolation:

 // The test for H.264 Video (without AAC audio) // Returns 'maybe' document.createElement("video").canPlayType('video/mp4; codecs*="avc1.42E01E"');                           ^                      ^            ^                           |                      |            |                           /                      |            | The <video> element                                 The MIME Type, wrapping video & audio                                                              NB: The "*" (asterisk) 

Feature or Bug?

The question are:

  1. does IE9 support H.264 video without an audio component?
  2. what is this the right way to ask?

 

According to RFC4281 which defines how these MIME and codec blocks should be compiled the codec parameter must be

"A single value, or a comma-separated list of values identifying the codec(s) indicated to render the content in the body part."

So from reading this I think the problem lies in the way IE9 parses the codec and not the way Modernizr asks the question but I would be very interested to learn whether that rather wild assumption is right?

The * case

Yes, there is this test that works: codecs*="avc1.42E01E".

Reading the very small portion of text about this in the RFC4281 I'm not really left feeling like I fully understand why this works and the other test doesn't.

I read the clause to be suggesting that including the asterisk is a method for specifying that you're encoding your codec defenitions... I don't read it to be some sort of wild card as the 'maybe' result IE9 returns would suggest.

Wrapping Up - Questions to be answered.

The bottom line is I'm not sure whether the issue lies with Modernizr or IE9.

  • Are the Modernizr & html5test.com correct?
    In all the specification examples I can find H.264 is always defined as a pair of audio & video. So is it a legitimate to test for a video codec in isolation?... and is it legitimate to ask for this specific video codec in isolation?
  • Does IE9 treat the asterisk properly?
    Why does IE9 return 'maybe' for codecs*="avc1.42E01E" and '' (false) for codecs="avc1.42E01E"? Is this a bug in IE9 or have I misread the RFC?

 

Until we get a conclusive answer from someone who knows more about this than I do fmbip.com will, I'm afraid, continue to give what appears to be the wrong answer to the question; does IE9 support H.264 video.