以正确的9:16格式显示YouTube视频和缩略图 [英] Show Youtube video and thumbnail in correct 9:16 format

查看:951
本文介绍了以正确的9:16格式显示YouTube视频和缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用此处描述的链接轻松获取YouTube图片缩略图:

I can easily get a Youtube image thumbnail with the links described here: How do I get a YouTube video thumbnail from the YouTube API?

但是所有这些缩略图都是3:4格式(或近似),即使视频本身是其他格式也是如此.然后,在图片的顶部和底部就可以看到一些黑色的水平条.

But all these thumbnails are in 3:4 format (or something close) even though the video itself is in some other format. Then some black horizontal bars are just visible at the top and bottom of the picture.

我需要一个9:16格式的图像(这是我的视频格式),并且没有黑条.可以撤退吗?

I need an image in 9:16 format (which is my video format) without black bars. Is that possible to retreive?

更新

即使Youtube页面上的视频中没有黑条,似乎YouTube视频本身的顶部和底部也有黑条.

It appears that also the Youtube video itself has black bars in top and bottom even though there are no black bars on the video on the Youtube page.

有什么方法可以简单地以正确的格式同时显示缩略图和视频?

Any ways to simply show both thumbnail as well as video in correct format?

更新

我发现了这一点:在youtube缩略图上以4:3的比例删除黑色边框

请求者想要删除黑色的顶部和底部条形图.最好的答案是通过手动校正来调整高度并隐藏"黑条.以下一些评论也暗示了这一点.
这是否意味着无法避免?

The asker wants to remove the black top and bottom bars. The best answers here are to adjust the height and "hide" the black bars by manual correction. Some of the comments here below also suggest that.
Does this mean that it's not possible to avoid?

推荐答案

按API文档:

yt:name属性值为mqdefault的标签可标识320x180(16:9)缩略图.该图像也没有时间戳,可能来自视频中的任何一点.

The tag that has a yt:name attribute value of mqdefault identifies a 320x180 (16:9) thumbnail image. This image does also does not have a timestamp and could be from any point in the video.

因此,有一种图像可用于16:9格式的每个视频分辨率(至少我已经测试过).当然,这不是地球上最大的形象...

So there's an image that's available for every video resolution (that I've tested, at least) that is in 16:9 format. Of course, it isn't the biggest image on the planet...

如果大小是一个问题,并且您需要更大的东西,那么最好的选择实际上不是选择始终以4:3比例 的可用选项之一,然后使用CSS. YouTube本身已经很长时间了 .他们现在在整个网站上使用多种缩略图大小,包括mqdefault.jpg.

If the size is an issue, and you require something bigger, than the best option really is to choose one of the available options that is always in 4:3 ratio, and hide the excess using CSS. YouTube itself has done this for a long time. They utilize multiple thumbnail sizes across their site now, including mqdefault.jpg.

在知道所有尺寸的情况下,很容易隐藏图像的多余宽度和/或高度. 此处是一个示例,该示例使用了YouTube上的4:3图像,其中隐藏了黑条,留下了16:9的结果. CSS被评论为您的乐趣.

It's really easy to hide excess width and/or height from an image when all the dimensions are known. Here is an example using a 4:3 image from YouTube with the black bars hidden, leaving a 16:9 result. The CSS is commented for your enjoyment.

这篇关于以正确的9:16格式显示YouTube视频和缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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