bug^君 2010-01-14 23:34 采纳率: 25%
浏览 710
已采纳

如何从 YouTube API 获得一个 YouTube 视频缩略图?

If I have a YouTube video URL, is there any way to use PHP and cURL to get the associated thumbnail from the YouTube API?

转载于:https://stackoverflow.com/questions/2068344/how-do-i-get-a-youtube-video-thumbnail-from-the-youtube-api

  • 写回答

30条回答 默认 最新

  • larry*wei 2010-01-14 23:40
    关注

    Each YouTube video has 4 generated images. They are predictably formatted as follows:

    https://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
    https://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
    https://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
    https://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
    

    The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:

    https://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg
    

    For the high quality version of the thumbnail use a url similar to this:

    https://img.youtube.com/vi/<insert-youtube-video-id-here>/hqdefault.jpg
    

    There is also a medium quality version of the thumbnail, using a url similar to the HQ:

    https://img.youtube.com/vi/<insert-youtube-video-id-here>/mqdefault.jpg
    

    For the standard definition version of the thumbnail, use a url similar to this:

    https://img.youtube.com/vi/<insert-youtube-video-id-here>/sddefault.jpg
    

    For the maximum resolution version of the thumbnail use a url similar to this:

    https://img.youtube.com/vi/<insert-youtube-video-id-here>/maxresdefault.jpg
    

    All of the above urls are available over http too. Additionally, the slightly shorter hostname i3.ytimg.com works in place of img.youtube.com in the example urls above.

    Alternatively, you can use the YouTube Data API (v3) to get thumbnail images.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(29条)

报告相同问题?

悬赏问题

  • ¥15 数据量少可以用MK趋势分析吗
  • ¥15 使用VH6501干扰RTR位,CANoe上显示的错误帧不足32个就进入bus off快慢恢复,为什么?
  • ¥15 大智慧怎么编写一个选股程序
  • ¥100 python 调用 cgps 命令获取 实时位置信息
  • ¥15 两台交换机分别是trunk接口和access接口为何无法通信,通信过程是如何?
  • ¥15 C语言使用vscode编码错误
  • ¥15 用KSV5转成本时,如何不生成那笔中间凭证
  • ¥20 ensp怎么配置让PC1和PC2通讯上
  • ¥50 有没有适合匹配类似图中的运动规律的图像处理算法
  • ¥15 dnat基础问题,本机发出,别人返回的包,不能命中