How to get thumbnail image from Youtube video

The information about getting such thumbnail image seems to be sparse and scattered. Actually, Google has posted its Youtube Data API, which indirectly hinted some information about image locations, but looks incomplete; while others seems to reckon different URLs for those thumbnail images. So here it is:

http://$host/vi/$vid/$choice

$host

$host can be one of the host names below:

  • i.ytimg.com
  • i1.ytimg.com
  • i2.ytimg.com
  • i3.ytimg.com
  • i4.ytimg.com
  • img.youtube.com

Actually all host names point to the same IP address.

$vid

$vid is the ID of video. The value can be found in youtube URLs. Take the video of Youtube Symphony Orchestra at Carnegie Hall as example. The full URL of video page is:

http://www.youtube.com/watch?v=ueJcRmfweSM

Then the video ID is the last part of URL, ueJcRmfweSM.

$choice

$choice indicates which thumbnail image shall be retrieved; it accepts certain limited values only.

0.jpg about 320 × 240, snapshot of about middle (?) of the whole video
1.jpg about 128 × 96, snapshot of about first 1/4 (?) of the whole video
2.jpg about 128 × 96, a smaller version of 0.jpg
3.jpg about 128 × 96, snapshot of about 3/4 (?) of the whole video
default.jpg same as 2.jpg

Getting the pieces together

Let’s use previous Youtube Symphony Orchestra video as example again. The following URLs are identical, corresponding to small version of default thumbnail image:

http://img.youtube.com/vi/ueJcRmfweSM/2.jpg
http://i2.ytimg.com/vi/ueJcRmfweSM/2.jpg
http://i4.ytimg.com/vi/ueJcRmfweSM/default.jpg

This one is the larger version:

http://i.ytimg.com/vi/ueJcRmfweSM/0.jpg

Tagged as , • Categorized as Web

Leave a Reply

E-mail is not disclosed nor shared. Required fields are marked *