Filed under: youtube

Velocity 2011 (#velocityconf): HTML5 vs. Flash for video

The last really interesting talk I attended was about YouTube's use of Flash and HTML5. They had some really interesting issues that they have had to deal with. Plus, there are some really odd side effects that they both observed and intentionally caused.

First, they are at the point where the two versions are functionally similar. The HTML5 version of the player does not have quite as many features, but you can try it out by going here. The biggest feature gap is in rights management. Currently, Flash has a proprietary rights management system to protect the content. HTML5 lacks that sort of protection now. Otherwise, there is no reason why the two versions should be different for very long.

The most interesting part of the talk was around the performance differences. HTML5 generally outperforms the Flash version of the player in actually getting loaded and up on the screen. They were saying that the difference was about 200ms. However, once the play button was pushed or there was a seek, the Flash player usually started playing about 2 seconds faster. This isn't really because Flash is better, though. It's because the edge cache doesn't have as many of the HTML5 versions of the videos because it is nowhere near as popular.

The problem remains, though, that Flash was slower on the uptake. They dealt with this by doing some strange hacks here and there. The most clever (and scary) of which was creating an image in a script block in the head tag that points to the CDN that holds the video. That way, the connection was already open by the time the page got to rendering the Flash widget. It's really clever, but I'd hate to see this be necessary for long.

There were a couple other cool things out there. HTML5 can actually do more exact seeking since it does not need to seek to a key frame. There was some tweaking on the API for controlling an embedded player since the HTML5 player has to be in an iframe. This tweak uses the postMessage method on the window, which I have never heard about. I want to look into that and its support. That could solve some of the issues we've had previously with communicating between a parent and an iframe on different domains.

All said, there was some interesting, funny, and scary stuff here.

web
stats