Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force youtube to play HD videos [closed]

I have below video in youtube iframe and forcefully wants to run it on High Quality at first go

https://www.youtube.com/embed/3nmnMtbzzjE

I tried Parameters like hd=1 and vq=hd720 and vq=hd1080 But i think these are outdated or not in function.

Please suggest. Regards

like image 244
Pramod Avatar asked Sep 25 '14 06:09

Pramod


People also ask

Can you force YouTube to play highest quality?

Go to YouTube via your browser. Click the Auto Quality for YouTube icon on the browser extension menu. Select the drop-down menu adjacent to Default Quality and choose your preferred quality for YouTube videos.

Why does YouTube keep defaulting to 480p?

For instance, during the unprecedented times of Coronavirus, YouTube decided to reduce the default resolution of videos to 480p globally. This thoughtful step was taken in view of taking some load off of its servers due to the increase in users' watch time.


2 Answers

I just solved this problem for a website I was working on.

I have embedded iframes with youtube videos in them and they, annoyingly, auto-played at a low resolution despite my wanting them to auto-play at 720p. This issue is caused by the actual size of the video, on your page, being detected by YouTube which will trigger an auto-selection of a lower res.

Here's what I did to keep my video embed small, but have it auto play on 720p etc -

  1. You need to add ?vq=hd720 at the end of your video id, as you have done.
  2. Manually set the iframe width to width="1280" height="720" - which will make the video huge on your site.
  3. Wrap the iframe in a div and give it a class selector so you can style it with css.
  4. Use CSS to tell your div wrapper to be the size you actually want the video to be.
  5. Use CSS to set the iframe width:100% and height:100%.

This code will basically set the video size to be that of the resolution you want it to auto-play on, which will trick YouTube into setting this for you. Then the CSS dynamically resizes the video to be whatever actual size you need.

And that's all there is to it :)

CODE EXAMPLE:

HTML

<div class="youtube-embed">
    <iframe width="1280" height="720" src="https://www.youtube.com/embed/VIDEOID?vq=hd720" frameborder="0" allowfullscreen></iframe>
</div>

CSS

.youtube-embed {
    width  : 740px;
    height : 400px;
}

.youtube-embed iframe {
    width  : 100%;
    height : 100%;
}
like image 92
Zupecki Avatar answered Oct 10 '22 15:10

Zupecki


Pls see this article: http://www.reddit.com/r/youtube/comments/2fckq3/did_youtube_disable_hdlinking_adding_hd1_at_the/

it seems that you could use vq=1080 to suggest the use of hd video, but the HD will be used only when the video window is large enough

like image 25
John the Traveler Avatar answered Oct 10 '22 15:10

John the Traveler