Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get YouTube video aspect ratio

I'd like to get the aspect ratio of a YouTube video, to resize the player accordingly. I'm programming the YT player using JavaScript.

like image 933
infojunkie Avatar asked Feb 15 '11 22:02

infojunkie


People also ask

Is YouTube 16x9 or 4x3?

Does YouTube use 16x9 or 4x3 video ratio? YouTube uses a 16:9 aspect ratio. This is a standard aspect ratio that most smartphones and DSLR cameras use.

Are YouTube videos 16:9?

The standard aspect ratio for YouTube on a computer is 16:9. If your video has a different aspect ratio, the player will automatically change to the ideal size to match your video and the viewer's device.


1 Answers

I would suggest hitting the oembed url:

https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v={videoID}&format=json

This gives you the exact video dimensions for videos that are public. I'm not sure about private videos though. It will also return thumbnail dimensions, which seem to be different im some cases, so just be sure to not mix them up.

like image 54
huesforalice Avatar answered Oct 26 '22 23:10

huesforalice