I understand that HTML5 video is way more complicated than its proponents would like us to believe. Safari uses the proprietary H.264 codec, whereas Firefox, Chrome and Opera all support the open-source Theora. Internet Explorer doesn't support either, so needs a fallback, such as .mov or Flash.
I found a superb guide somewhere that put together a step-by-step guide for HTML5 on all these browsers, but I can't find it anywhere. Very annoying :(
What's the best way to implement HTML5 video so that all these browsers are covered? (Unfortunately, Flash is not an option.)
Edit: Ok, from what I've read, here is my own answer: This is the best way to implement HTML 5 video...
<video id="video" width="450" height="170" preload="auto" autoplay="autoplay">
<source src="../static/video/video.mp4" />
<source src="../static/video/video.webm" type='video/webm; codecs="vp8, vorbis"' />
<source src="../static/video/video.ogv" type='video/ogg; codecs="theora, vorbis"' />
<!-- Fallback (either Flash, an image, or a "Video not supported" message, etc.) -->
</video>
It's the only way that's worked as expected on every browser so far. Unfortunately autoplay doesn't seem to be working in Chrome? :(
Update: Chrome doesn't support Autoplay.
In order to ensure that a video is accessible by all of the target browsers, you'll need to provide, at minimum, two different source elements for your video element. Example 1-5 shows an HTML5 web page with a video element containing two different video sources: one in H.
The HTML <video> element is used to embed video in web documents. It may contain one or more video sources, represented using the src attribute or the source element. The <video> element is supported by all modern browsers.
The HTML5 video format capabilities include three options to play: MP4, WebM, and Ogg.
To embed a video in an HTML page, use the <iframe> element. The source attribute included the video URL. For the dimensions of the video player, set the width and height of the video appropriately. The Video URL is the video embed link.
I suspect this guide from Kroc Camen is the one you want http://camendesign.com/code/video_for_everybody.
It's not quite as hard as he outlines there if you are happy to use Flash to support older IEs.
Two versions of each video, one Theora and one H.264 will cover everything possible. One H.264 is enough if you don't mind browsers using Flash instead of Theora.
Worth reading up on WebM as well, it's set to replace theora.
<video id="movie" width="320" height="320" preload controls>
<source src="pr6.mp4" type='video/mp4; codecs=avc1.42E01E, mp4a.40.2"' />
<source src="pr6.webm" type='video/webm; codecs="vp8, vorbis"' />
<source src="pr6.ogv" type='video/ogg; codecs="theora, vorbis"' />
<object width="320" height="240" type="application/x-shockwave-flash" data="flowplayer-3.2.1.swf">
<param ... />
</object>
</video>
This example is taken from the book HTML5 Up and Running. You list each supported video encoding separately within a single <video>
tag. The browser will try each one, starting with the first. This example shows three encodings. You will need do the actual video encoding yourself. To support multiple browsers, you'll need multiple encodings.
The final entry is a fallback for browsers that don't support the new HTML5 video tag. In the example, I used flash, but you can use whatever old-school format you prefer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With