Henrik Carlsson's Blog

All things me.

YouTube, H.264, WebM and Flash

posted this on

(Or, how YouTube managed to turn my MacBook Pro into a vacuum cleaner.)

So apparently Safari without flash misses the old vacuum cleaner mode so much that it now randomly does it for mp3 and mp4 content. :( 1

That quote is from my, via twitter, a few weeks ago. I had started noticing that videos got my computer to spin up all its fans and peg the CPU. This kind of behavior was common before I uninstalled Flash2 but I thought those days where long gone. I even checked to see if Flash really was uninstalled, which it was.

This problem drove me nuts, but apart from whining about it on twitter, I didn’t do anything. Some time later I realized that it was not just any video content, it was specifically Youtube videos that made Safari go bananas. Hence, I started Googling and came up with an answer.

Turns out, when Perian is installed, YouTube prefers WEBM codec over H.264. It seems that WEBM video plays without any hardware acceleration — Activity Monitor shows CPU usage of ’QTKitServer-(1836) Safari Web Content’ exceeding 100%.3

So Perian, the wonderful ”swiss-army knife of QuickTime components”, was causing the problem. Using Perian, Safari suddenly had the ability to playback WebM video, but without hardware acceleration. It turns out that Youtube does a feature test to see what video formats your device can playback and then choses from the available options. And since Google has previously stated its intentions to stop supporting H.264 video, naturally they prefer to deliver WebM video.

If that is the problem, then what is the solution? The simplest one would be to uninstall Perian, but then I would lose the ability to decode a lot of audio and video formats. However, I found a more complex but better working one.

Solution

  1. Go to http://youtube.com/html5. At the bottom of the page you see whether you are using the ”HTML5” video player or not. (If you don’t, you will defiantly not have this problem.) Disable the HTML5 video player.
  2. Head over to Vertical Forest and download the Safari extension Youtube5. This will replace the default Youtube video player with a lean, simple, HTML5 <video>-tag based one that uses the H.264 versions of the videos. That means you get video without Flash, without stuttering.

This way Youtube will try to deliver videos to you as Flash applications and Youtube5 will replace them with H.264 video.

I implemented this solution about two weeks ago on both my and my girlfriends computers and so far it has worked great. No stuttering and no unavailable videos due to missing Flash. ”It just works.”4


  1. http://twitter.com/synvila/status/189746957336580097 
  2. I still use Chrome to ”cheat”. Read more about going flash-free on Daring Fireball 
  3. YouTube HTML5 videos play poorly after installing Perian 
  4. This problem, and its solution, certainly makes you ask the question about what is best; an open standard, or an actual working one?