Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Youtube oembed: How does it calculate the 'width' and 'height' values?

When I use the oembed URL in my PHP code and extract the $video->width and $video->height from my uploaded video, I get values back that don't match anything I've seen associated with my Youtube video.

  • http://youtu.be/p7ftPYU2_0w

  • Original video dimensions, as uploaded to Youtube: 640 x 336

  • oembed returns: 480 x 270

  • Smallest embed option when sharing from Youtube page UI: 560 x 316

Does anyone know where oembed gets these values? Why does it default to 480? Is there a way to get the true video dimensions, or least bump the default up to 640 x [proportional_height]?

My goal is to preserve the native dimensions of the video (no scaling) when embedding on my website, without users actually needing to key-in the video dimensions again.

like image 311
atwixtor Avatar asked Nov 25 '22 00:11

atwixtor


1 Answers

Youtube might generate a content which it could provide for embed content instead of the original video. The width and height of the generated content could be 480 x 270. So, the oEmbed api could return this value always. AFIK there is no way to get the original dimension of a video value from the api side unless or until the provider provides one.

You could try adjusting the width and size of the video with the help of jquery and css.

oEmbed spec says maxwidth and maxheight params could be given while requesting the api. So we could restrict the maximum width and height of the video.

Hope it helps !

like image 184
Tom Taylor Avatar answered Dec 18 '22 23:12

Tom Taylor