Jan
09
2009

Embed High Def Video from YouTube


If you have a video blog or post videos on your blog, you have most likely embedded something off of YouTube. Last year, YouTube bumped up the quality of the videos but when you embed a video on your site, it still references the low quality version instead of the available higher quality video. Now, you need to realize that most of the videos on YouTube are still of the lower quality persuasion but newer videos will always have a higher quality version available.

Tricking the embed code to search out the high def version of each video is pretty simple.

Here are two examples.

Low quality:

High quality:

The difference is one little bit of code that is added to the embed code.

Here is the original embed code:

<object width="560" height="345" data="http://www.youtube.com/v/zrSWBvNXTuM&hl=en&fs=1" type="application/x-shockwave-flash">
<param name="allowFullScreen" value="true" />
<param name="allowscriptaccess" value="always" />
<param name="src" value="http://www.youtube.com/v/zrSWBvNXTuM&hl=en&fs=1" /><param name="allowfullscreen" value="true" />
</object>

And here is the new code:

<object width="560" height="345" data="http://www.youtube.com/v/zrSWBvNXTuM&ap=%2526fmt%3D22&rel=0" type="application/x-shockwave-flash">
<param name="allowFullScreen" value="true" />
<param name="allowscriptaccess" value="always" />
<param name="src" value="http://www.youtube.com/v/zrSWBvNXTuM&ap=%2526fmt%3D22&rel=0" />
<param name="allowfullscreen" value="true" />
</object>

I have replaced the &hl=en&fs=1 with &ap=%2526fmt%3D22&rel=0. You don’t need to add the &rel=0 part. That only removes the related videos that usually appear at the end.

There is one issue with this hack. The D22 of the code searched for the highest quality version, aka 720p HD. If there is no 720p HD version you will get a “This Video has Been Deleted” message. The only option is to change D22 to D18 so that is searches for the middle quality version, aka 480p SD.

If you liked this, please share it.

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Short URL: http://bit.ly/cf6LKo

Discussion 14 Comments

  1. mike on January 15, 2009 at 11:13 am

    Are you aware if this is a violation of youtube’s terms of service in any way? I noticed that a portion of the videos on sites that embed this way display a message that it has been deleted because of breaking youtube’s tos. I would love to do this, but I am hesitant.

    • c.bavota on January 15, 2009 at 11:30 am

      The message that the video has been deleted will only appears if the video you are embedding does not have a high def version. As far as I know, there is no violation of the terms of service by using this code.

  2. Buy acai berry on May 22, 2009 at 2:22 pm

    Your blog is very interresting for me, i will come back here..

  3. Anya on November 11, 2009 at 11:30 pm

    i am so addicted to Youtube. I watch mostly music videos and funny videos on Youtube sometimes i also upload my own funny videos in youtube. `

  4. youtube on December 6, 2009 at 3:53 pm

    Thanx for this small code, very usefull. I will use it on my website

    • Elli21486 on January 29, 2010 at 5:38 pm

      Youtube has made it simpler to embed an HD video to a website. Instead of replacing the &hl=en&fs=1 with &ap=%2526fmt%3D22&rel=0 like stated in this article, just add the &hd=1 at the end of it. It would make it “http://www.youtube.com/v/zrSWBvNXTuM&hl=en&fs=1&hd=1″.

  5. Annn on January 30, 2010 at 11:38 am

    HI,I wanna ask a question:
    If I want to embed a HQ youtube video,is there any methods?

    (Because I tried the methods mentioned in this article and also
    tried changing &hl=en&fs=1 to &ap=%2526fmt%3D18 or just adding &hq=1 behind the url,they didn’t work anyway…)

    • c.bavota on January 30, 2010 at 4:01 pm

      You need to add hd=1 not hq=1.

  6. Annn on January 30, 2010 at 9:55 pm

    I’m sorry but it seems doen’t work
    You may try this:http://www.youtube.com/watch?v=Omd72UQo9H0
    And its embeded code is

    It’s already included &hd=1 ,but the movie seems show the 320p not
    480p effect,you may try this then you’ll find it.

  7. Annn on January 30, 2010 at 9:58 pm

    The embeded code is

     
  8. YouTube Jumpstart on February 8, 2010 at 7:32 am

    Thanks for that – I am such a newbie when it comes to the internet and it never ceases to amaze me how helpful everyone is. Wish I’d gotten into this sooner now!

  9. luv2golf on February 9, 2010 at 4:25 pm

    It won’t be long before all videos are HD.

  10. Tevya on June 1, 2010 at 10:45 am

    Hi, I’ve tried this and it doesn’t appear to work anymore. Whether I use the D22 or D18 it still plays at 360p. I have several videos I want to embed that are available in 360p, 480p, and 720p. I want to embed them at 480p. Can anyone tell me how? Doesn’t the hd=1 option default to the highest quality (720p in this case)?

    Thanks in advance for any help.

    • c.bavota on June 1, 2010 at 11:22 am

      I don’t know if this still works. YouTube has changed some things since I posted this tutorial.

Leave a Reply

Your email address will not be published. Required fields are marked *

*


To enter code in the comment box, please place it between <pre lang="php"> </pre> tags. You don't have to convert any characters to their hex/HTML code. Just add your code the way you would to any code editor.