Embed high-res Youtube videos


Here’s an example of a normal embedded Youtube video, borrowed from Patti Schiendelman’s Gakken Mechamo Inchworm post.

Back in march, it was discovered that when you view a video directly on Youtube, you could add a “&fmt=18” to the URL to enable a higher quality, higher resolution stream which is encoded with the H.264 codec.

To make this work in an embedded video, however, you need a slightly different hack. After pasting the embed code into a blog post, adjust the two video URLs (one in a param tag and one as the src parameter in the embed tag) by adding “&ap=%2526fmt%3D18″ to the end.

For example, the above video embed becomes:

<object width=”600″ height=”475″><param name=”movie” value=”http://www.youtube.com/v/iMQBKkDJY2c&hl=en&fs=1&rel=0&ap=%2526fmt%3D18″></param><param name=”allowFullScreen” value=”true”></param><param name=”allowscriptaccess” value=”always”></param><embed src=”http://www.youtube.com/v/iMQBKkDJY2c&hl=en&fs=1&rel=0&ap=%2526fmt%3D18″ type=”application/x-shockwave-flash” allowscriptaccess=”always” allowfullscreen=”true” width=”600″ height=”475″></embed></object>

And here’s the result:

The still frame before the video is played is the exact same over-compressed image, but when a user clicks play, they will get a nice surprise. Instead of 320×240 video encoded with the Sorenson codec, the video will come in at a resolution of 480×360, encoded with the superior H.264 codec.

Embedding High Quality Youtube Videos [via Kottke]
View YouTube in high-res

8 thoughts on “Embed high-res Youtube videos

  1. Patti Schiendelman says:

    Aha! Thanks for posting this, Jason; adding the high quality code to the url is easy, adding to the embed is trickier.

  2. Dolnor says:

    Add “&ap=%2526fmt%3D18#” to any direct link to switch to high-def version.

  3. Christian says:

    Has anybody noticed that the nice snippet of code &ap=%2526fmt%3D18 doesn’t work in Internet Explorer anymore?

    Any tips on a fix?

    You may test it yourself (on your own websites or on http://blog.makezine.com/archive/2008/11/embed_highres_youtube_vid.html)

  4. dave says:

    Yes, I noticed that &ap=%2526fmt%3D18 doesn’t work in Internet Explorer . More exactly, my customer notice and called me — pretty fookin irate they were.

    Why can’t Billy Gates get along with the other children?

Comments are closed.

Send this to a friend