笑故挽风 2010-01-14 23:34 采纳率: 100%
浏览 833
已采纳

如何从 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

  • 写回答

27条回答 默认 最新

  • Memor.の 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.

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

报告相同问题?

悬赏问题

  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)