HTML5 multimedia - where we are, where we're going

64
HTML5 multimedia Where we are, where we're going Bruce Lawson

description

Bruce Lawson's talk at Frontrow Conference,

Transcript of HTML5 multimedia - where we are, where we're going

Page 1: HTML5 multimedia - where we are, where we're going

HTML5 multimediaWhere we are, where we're goingBruce Lawson

Page 2: HTML5 multimedia - where we are, where we're going

Anne van Kesteren annevk at opera.comWed Feb 28 05:47:56 PST 2007

Hi,Opera has some internal expiremental builds with an implementation of a <video> element. The element exposes a simple API (for the moment) much like the Audio() object: play() pause() Stop()

The idea is that it works like <object> except that it has special <video> semantics much like <img> has image semantics. In markup you could prolly use it as follows:

<figure> <video src=news-snippet.ogg> ... </video> <legend>HTML5 in BBC News</legend> </figure>

I attached a proposal for the element and as you can see there are still some open issues. The element and its API are of course open for debate. We're not enforcing this upon the world ;-)

Cheers,http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2007-February/009702.html

Page 3: HTML5 multimedia - where we are, where we're going

<object width="425" height="344"><param name="movie"

value="http://www.example.com/v/9sEI1AUFJKw&hl=en&fs=1&"></param>

<param name="allowFullScreen" value="true"></param>

<param name="allowscriptaccess" value="always"></param>

<embed src="http://www.example.com/v/9sEI1AUFJKw&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>

Page 4: HTML5 multimedia - where we are, where we're going

<video src=pudding.webm controls autoplay poster=poster.jpg width=320 height=240> <a href=video.webm>Download movie</a></video>

Page 5: HTML5 multimedia - where we are, where we're going

<audio src=bieber.ogg controls autoplay> <a href=bieber.ogg>Download horrid pap</a></audio>

Page 6: HTML5 multimedia - where we are, where we're going

<video src=pudding.webm loop>

Page 7: HTML5 multimedia - where we are, where we're going

<audio src=bieber.ogg preload><audio src=bieber.ogg preload=auto><audio src=bieber.ogg preload=none><audio src=bieber.ogg preload=metadata>

Page 8: HTML5 multimedia - where we are, where we're going

powerful (simple) API

Page 9: HTML5 multimedia - where we are, where we're going

www.w3.org/TR/html5/video.html#media-elements

Page 10: HTML5 multimedia - where we are, where we're going

controlling <video> with JavaScript

var v = document.getElementByTagName('video')[0];

v.play();v.pause();v.volume = … ;v.currentTime = … ;…

Page 11: HTML5 multimedia - where we are, where we're going

events fired by <video>var v = document.getElementById('player');v.addEventListener('loadeddata', function() { … }, true)v.addEventListener('play', function() { … }, true)v.addEventListener('pause', function() { … }, true)v.addEventListener('timeupdate', function() { … }, true)v.addEventListener('ended', function() { … }, true)…

Page 12: HTML5 multimedia - where we are, where we're going

video as native object...why is it important?

● keyboard accessibility built-in● “play nice” with rest of the page● Simple API for controls

Page 13: HTML5 multimedia - where we are, where we're going
Page 14: HTML5 multimedia - where we are, where we're going

"In addition to giving video an HTML element, we must also agree on a baseline video format that will be universally supported, just like the GIF, JPEG and PNG image format are universally supported. It's important that the video format we choose can be supported by a wide range of devices and that it's royalty-free (RF). RF is a well-established principle for W3C standards."

http://people.opera.com/howcome/2007/video/

Page 15: HTML5 multimedia - where we are, where we're going

Ogg Theora

“free and open”, no licensing/royaltiesnot many tools for it, not web optimised

Page 16: HTML5 multimedia - where we are, where we're going

MP4 / H.264

ubiquitous, patent encumbered, licensing/royalties, hardware accelerated

Page 17: HTML5 multimedia - where we are, where we're going

WebM

"open and royalty-free", web optimised, hardware acceleration on its way

Page 18: HTML5 multimedia - where we are, where we're going

video formats

webM Ogg/ Theora mp4/ h264

Opera yes yes

Chrome yes yes Nope (Chrome.soon)

Firefox Yes (FF4) yes

Safari yes

IE9 Yes (if installed) yes

Page 19: HTML5 multimedia - where we are, where we're going

The politics of codecs

Page 20: HTML5 multimedia - where we are, where we're going

audio formats

mp3 Ogg/ Vobis wav

Opera yes yes

Chrome yes yes yes

Firefox yes yes

Safari yes yes

IE9 yes

Page 21: HTML5 multimedia - where we are, where we're going

Giving everybody video

<video controls autoplay poster=… width=… height=…><source src=pudding.mp4 type=video/mp4><source src=pudding.webm type=video/webm><source src=pudding.ogv type=video/ogg><!-- fallback content -->

</video>

Page 22: HTML5 multimedia - where we are, where we're going

<video controls poster="…" width="…" height="…"><source src="movie.mp4" type="video/mp4" /><source src="movie.webm" type="video/webm" /><source src="movie.ogv" type="video/ogg" /><object width="…" height="…" type="application/x-

shockwave-flash" data="player.swf"><param name="movie" value="player.swf" /><param name="flashvars" value=" … file=movie.mp4" /><!-- fallback content -->

</object></video>

still include fallback for old browsershttp://camendesign.com/code/video_for_everybody

Page 23: HTML5 multimedia - where we are, where we're going

Help

● archive.org converts and hosts creative-commons licensed media

● vid.ly has a free conversion/ hosting service (max 1GB source file) see vid.ly/5u4h3e

● Miro video converter is a drag and drop GUI skin on FFMPEG

Page 24: HTML5 multimedia - where we are, where we're going

video media queries

<video controls><source src=hi-res.ogv media="(min-device-width:800px)"><source src=lo-res.ogv></video>

http://dev.w3.org/html5/spec/video.html#the-source-element

Page 25: HTML5 multimedia - where we are, where we're going

Full-screen video● Currently, WebkitEnterFullscreen();● May 11, WebKit announced it's implementing Gecko API https://wiki.mozilla.org/Gecko:FullScreenAPI

● Opera likes this approach, too

Page 26: HTML5 multimedia - where we are, where we're going

<video> accessibility

Page 27: HTML5 multimedia - where we are, where we're going
Page 28: HTML5 multimedia - where we are, where we're going

WebM release does not support subtitles

http://code.google.com/p/webm/issues/detail?id=11Egg image Kacper "Kangel" Aniołek http://commons.wikimedia.org/wiki/File:Egg.jpg

WHATWG / W3C RFC will release guidance on subtitles and other overlays in HTML5 <video> in the near future. WebM intends to follow that guidance.

Page 29: HTML5 multimedia - where we are, where we're going

<track> element

<video controls poster=… width=… height=…><source src=movie.webm type=video/webm><track src=subtitles-en.vtt kind=subtitles srclang=en><track src=subtitles-de.vtt kind=subtitles srclang=de><!-- fallback content -->

</video>

http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#the-track-element

Page 30: HTML5 multimedia - where we are, where we're going

WebVTT or TTML ?

Page 31: HTML5 multimedia - where we are, where we're going

webVTT

WEBVTT FILE

101:23:45,678 --> 01:23:46,789Hello world!

201:23:48,910 --> 01:23:49,101Mój poduszkowiec jest pełen węgorzy

Page 32: HTML5 multimedia - where we are, where we're going

WebVTT formatting

Supports positioning of text

Supports <b> and <i>

Colouring individual speakers

Support vertical text

Supports RTL

Supports ruby annotations

Validator: http://quuz.org/webvtt/

Page 33: HTML5 multimedia - where we are, where we're going

subtitling polyfills

Page 34: HTML5 multimedia - where we are, where we're going

playrhttp://www.delphiki.com/html5/playr/

Page 35: HTML5 multimedia - where we are, where we're going

LeanBack Playerhttp://leanbackplayer.com/

Page 36: HTML5 multimedia - where we are, where we're going

MediaElement.jshttp://mediaelementjs.com/

Page 37: HTML5 multimedia - where we are, where we're going

Synchronising media elements

Page 38: HTML5 multimedia - where we are, where we're going
Page 39: HTML5 multimedia - where we are, where we're going

Synchronising media elementsEach media element can have a MediaController. A MediaController is an object that coordinates the playback of multiple media elements, for instance so that a sign-language interpreter track can be overlaid on a video track, with the two being kept in sync....

Media elements with a MediaController are said to be slaved to their controller. The MediaController modifies the playback rate and the playback volume of each of the media elements slaved to it, and ensures that when any of its slaved media elements unexpectedly stall, the others are stopped at the same time.

When a media element is slaved to a MediaController, its playback rate is fixed to that of the other tracks in the same MediaController, and any looping is disabled.

http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#synchronising-multiple-media-elements

http://www.w3.org/WAI/PF/HTML/wiki/Media_Multitrack_Media_API

Page 40: HTML5 multimedia - where we are, where we're going

How mature is all this?Looping latency

people.opera.com/patrickl/experiments/audio/hacky-looper/

HTML5 video issues on the iPad and how to solve themblog.millermedeiros.com/2011/03/html5-video-issues-on-the-ipad-and-how-to-solve-them/

Unsolved HTML5 video issues on iOShttp://blog.millermedeiros.com/2011/04/unsolved-html5-video-issues-on-ios/

Audio Sprites (and fixes for iOS) remysharp.com/2010/12/23/audio-sprites/

Page 41: HTML5 multimedia - where we are, where we're going

“...extending the language to better support Web applications … This puts HTML in direct competition with other technologies intended for applications deployed over the Web, in particular Flash and Silverlight.”

Ian Hickson, Editor of HTML5http://lists.w3.org/Archives/Public/public-html/2009Jan/0215.html

Page 42: HTML5 multimedia - where we are, where we're going

Image © Jackdrawsanything.com "I will draw anything you like to raise funds for the Sick Kids"

Page 43: HTML5 multimedia - where we are, where we're going

DISCLAIMER:

This is my personal perspective and does not reflect the opinion of Opera.

Or my wife, children or hamster. Or anyone else who might be embarrassed by association with me (which is mostly everyone, to be honest).

As this is a conference, in the land of Żubrówka, I'll probably get drunk and try to chat you up, so let's make this disclaimer run until Saturday, OK?

Page 44: HTML5 multimedia - where we are, where we're going
Page 45: HTML5 multimedia - where we are, where we're going

DRM on HTML5 without changes

Henri Sivonen

lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2010-July/027051.html

Page 46: HTML5 multimedia - where we are, where we're going

getUserMedia API(previously known as "HTML5 <device>")

Page 47: HTML5 multimedia - where we are, where we're going

<video autoplay></video><script>var video = document.querySelector(video);

If (navigator.getUserMedia) {navigator.getUserMedia('video',successCallback, errorCallback);

function successCallback(stream) { video.src = stream; }</script>

Tutorial:

http://dev.opera.com/articles/view/playing-with-html5-video-and-getusermedia-support/

Page 48: HTML5 multimedia - where we are, where we're going

my.opera.com/core/blog/2011/03/23/webcam-orientation-preview

Page 49: HTML5 multimedia - where we are, where we're going

WebRTC is a free, open project that enables web browsers with Real-Time Communications (RTC) capabilities via

simple Javascript APIs. The WebRTC components have been optimized to best serve this purpose.

The WebRTC initiative is a project supported by Google, Mozilla and Opera.

http://sites.google.com/site/webrtc/http://www.whatwg.org/specs/web-apps/current-work/complete/video-conferencing-

and-peer-to-peer-communication.html

Page 50: HTML5 multimedia - where we are, where we're going

"We expect to see WebRTC support in Firefox, Opera, and Chrome soon!"

http://www.webrtc.org/

Page 51: HTML5 multimedia - where we are, where we're going
Page 52: HTML5 multimedia - where we are, where we're going

Case studyhttp://www.rathergood.com/buffy

Page 53: HTML5 multimedia - where we are, where we're going
Page 54: HTML5 multimedia - where we are, where we're going

<div><button>Q</button><button>W</button>...</div>

<div><button>A</button><button>S</button>...</div>

Page 55: HTML5 multimedia - where we are, where we're going

<video loop><source src=hixie.mp4 type=video/mp4><source src=hixie.webm type=video/webm></video>

Page 56: HTML5 multimedia - where we are, where we're going

//grab all the buttons buttons = document.querySelectorAll('button'), //loop through all the <button> elements, and create corresponding //audio elements

buildAudio = (function(){ for (var i = 0, l = buttons.length; i < l; i++) { var key = buttons[i].textContent.toLowerCase();

//using the fancy new Audio() constructor here

document.body.appendChild(new Audio(key + '.ogg')); }; })()

Page 57: HTML5 multimedia - where we are, where we're going

document.addEventListener('ended', function(e){ if (e.target.nodeName == "AUDIO") { // pause the video since the audio //has stopped

vid.pause(); } }, true)

Page 58: HTML5 multimedia - where we are, where we're going

<button data-text="<q> element">Q</button><button data-text="Web Workers">W</button>

Page 59: HTML5 multimedia - where we are, where we're going

text = document.getElementById('thinger')

text.textContent = el.dataset ? el.dataset.text : el.getAttribute('data-text');

Page 60: HTML5 multimedia - where we are, where we're going

#thinger {position:absolute; left:40px; top:200px;

text-align: center;

font-family: 'hixie', cursive, monospace; font-size:3em; color:red;

transform: matrix(0.98,-0.17,-0.17,0.98,0,0);}

AEZ Segar font, made into fontface kit with http://www.fontsquirrel.com/fontface/generator

Page 61: HTML5 multimedia - where we are, where we're going
Page 62: HTML5 multimedia - where we are, where we're going

Thanks

Mike Taylor @miketaylr for JS help, and Patrick Lauke @patrick_h_lauke for the Hixie voice. (What does that "H"

stand for?) to me slowly and patiently

Page 63: HTML5 multimedia - where we are, where we're going

All rights reserved corner

Thanks Takara Tomy for permission to use Gigapudding video. Buy the pudding.

Thanks Jack Henderson for permission to his scary DRM picture. Buy his book.

HTML5 nazi-killing Bruce on unicorn picture by Marina Lawson. Buy her Dad's book.

All others by me or (I believe) public domain.