I would like to know with certainty if a YouTube video is widescreen or not using the v3 API. There are many old videos that have a 4:3 ratio, so I need to detect this.
This was possible with API v2, but it is officially retired now. Here are the API v3 docs.
An API call looks something like this:
https://www.googleapis.com/youtube/v3/videos?id=[VIDEOID]&part=snippet&key=[DEVELOPERKEY]
Also, the thumbnail data always returns dimensions of 4:3, so that doesn't help. Here is an example:
[thumbnails] => Array
(
[default] => Array
(
[url] => https://i.ytimg.com/vi/nnnnnnnnn/default.jpg
[width] => 120
[height] => 90
)
...
)
Any ideas?
(I'm currently hacking this by analyzing pixels in the thumbnails where tell-tale black bars on 4:3 videos will be.)
Here is a sample video in 4:3 ratio:
https://www.youtube.com/watch?v=zMJ-Dl4eJu8 (old martial arts video)
and one in 16:9:
https://www.youtube.com/watch?v=7O2Jqi-LhEI (a new workout video)
Update: One promising suggestion was to explore fileDetails.videoStreams[].aspectRatio
but it seems that this is only available to the video owner. Otherwise requesting fileDetails
results in
The request cannot access user rating information. This error may occur because the request is not properly authorized
fileDetails.videoStreams[].aspectRatio
gives the video content's display aspect ratio, which specifies the aspect ratio in which the video should be displayed. – Eberlevideos
-resource contains this info, and it doesn't state anywhere that it is only for logged in users. It only states A video resource represents a YouTube video. So I assume no authentication needed. – Eberlehttp://www.youtube.com/oembed?url={VIDEO_URL}&format=json
, but it appears it'll always return 480 x 270 for the examples I tried. Perhaps you could provide some video examples? – Obligate