Search code examples
videoyoutube-api

Get YouTube Video dimensions (width/height)


I’m trying to get the size of a YouTube video. I’m using a Gdata API call to retrieve the basic informations (title, URLs, thumbnails and categories) but I can’t find the video dimensions.

I’m embedding some videos on a website using YouTube Data API server-side calls like this: http://gdata.youtube.com/feeds/api/videos/z_AbfPXTKms?0=v&1=2&alt=json. Unfortunately, there is no reliable information on video dimensions (all the preview images are in 4/3 rate even with widescreen videos).

What I am trying to accomplish is to fit the video exactly into the player; the player width is fixed, so I just need the original dimensions or at least the proportion.

Is there any way to retrieve this kind of data with the Youtube API?

(My fallback plan is to set the player size to 4/3 and never watch back, but any help is appreciated!)


Solution

  • You can also get it thanks to the oEmbed implementation of YouTube. Example:

    https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=hUvbb_eUP84&format=xml

    format=json is also accepted.