微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php – 确定YouTube视频是否为宽屏?

我想肯定地知道YouTube视频是否是宽屏或不使用v3 API.有许多旧视频的比例为4:3,所以我需要检测到这一点.

这可能是API v2,但现在正式退役.这是API v3 docs.

API调用看起来像这样:

https://www.googleapis.com/youtube/v3/videos?id=[VIDEOID]&part=snippet&key=[DEVELOPERKEY]

此外,缩略图数据始终返回4:3的尺寸,因此这没有帮助.这是一个例子:

[thumbnails] => Array
(
    [default] => Array
    (
        [url] => https://i.ytimg.com/vi/nnnnnnnnn/default.jpg
        [width] => 120
        [height] => 90
    )
    ...
)

有任何想法吗?

(我目前正在通过分析缩略图中的像素来解决这个问题,在4:3视频中会出现黑色条形图.)

以下是4:3比例的视频示例:

https://www.youtube.com/watch?v=zMJ-Dl4eJu8(老武侠视频)

和16:9中的一个

https://www.youtube.com/watch?v=7O2Jqi-LhEI(一个新的锻炼视频)

更新:一个有希望的建议是探索fileDetails.videoStreams [].aspectRatio,但似乎这只适用于视频所有者.否则请求fileDetails结果

The request cannot access user rating information. This error may occur because the request is not properly authorized

如果您愿意使用API​​以外的其他方法,那么我相信可以通过oEmbed API实现.
http://www.youtube.com/oembed?url={VIDEO_URL}&format=json

像这样:

http://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=zMJ-Dl4eJu8&format=json

会产生:

{  
    "provider_url":"https:\/\/www.youtube.com\/","thumbnail_url":"https:\/\/i.ytimg.com\/vi\/zMJ-Dl4eJu8\/hqdefault.jpg","thumbnail_height":360,"height":344,"type":"video","version":"1.0","html":"

原文地址:https://www.jb51.cc/php/137361.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐