YouTube thumbnail link doesn't work in all cases

后端 未结 3 753
暖寄归人
暖寄归人 2020-12-15 08:27

An application I\'m working on needs to get HQ YouTube thumbnails given a URL. Using this answer, I tried using the maxresdefault.jpg to get the maximum resolut

相关标签:
3条回答
  • 2020-12-15 09:01

    Update 2015 : None of your 'maxresdefault' link seems to be working

    Try these:

    http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
    http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
    http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
    http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
    
    0 讨论(0)
  • 2020-12-15 09:12

    Update 2019 ::

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

    Seems to return highest possible image....

    1.jpg, 2.jpg, 3.jpg return previews through the length of the clip which are handy also ;)

    0 讨论(0)
  • 2020-12-15 09:19

    As I understand it, YouTube only generates high-res stills for high-res videos. The first one you link was uploaded at a resolution of at least 1080p, while the second was less than 720p.

    Looks like the only thing you can do is pull the video feed, check that to see if a high-res still has been generated and up-scale the smaller one yourself if not.

    All¹ YouTube stills are presented in the 4:3 aspect ratio, so will always have black bars at the top and bottom if the video is 16:9. In HTML/CSS, this is easily combated by setting the image as the background of a div and sizing the div to the correct aspect.

    ¹ Except the mqdefault.jpg stills, which are all in 16:9 aspect (320x180)

    0 讨论(0)
提交回复
热议问题