获取 YouTube 视频尺寸(宽/高) [英] Get YouTube Video dimensions (width/height)

查看:41
本文介绍了获取 YouTube 视频尺寸(宽/高)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取 YouTube 视频的大小.我正在使用 Gdata API 调用来检索基本信息(标题、网址、缩略图和类别),但我找不到视频尺寸.

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.

我正在使用 YouTube 数据 API 服务器端调用在网站上嵌入一些视频,如下所示:http://gdata.youtube.com/feeds/api/videos/z_AbfPXTKms?0=v&1=2&alt=json.不幸的是,没有关于视频尺寸的可靠信息(即使是宽屏视频,所有预览图像也是 4/3 比率).

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.

有没有办法用 Youtube API 检索这种数据?

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

(我的后备计划是将播放器大小设置为 4/3 并且从不回头看,但感谢任何帮助!)

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

推荐答案

您也可以通过 YouTube 的 oEmbed 实现获得它.示例:

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 也被接受.

这篇关于获取 YouTube 视频尺寸(宽/高)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆