Here we are going to see how to generate thumbnail images from youtube and vimeo videos. This article will be useful when creating a video gallery.
Thank You!
Creating thumbnails of Youtube videos
Creating thumbnails for Youtube is an easy task to perform, actually PHP code is not necessary to perform this.
Each YouTube video has 4 generated images. They are predictably formatted as follows:
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
Example:
Say link "http://www.youtube.com/watch?v=QdoTdG_VNV4&feature=g-all",
In this youtube link video id is "QdoTdG_VNV4". So if you want to create thumbnail for this videos use this id with the above representation.
http://img.youtube.com/vi/QdoTdG_VNV/0.jpg
Creating thumbnails of Vimeo videos
For Vimeo thumbnails can be generated using simple PHP code.
<?php
$imgid = <video-id>;
$hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/$imgid.php"));
echo $hash[0]['thumbnail_medium'];
?>
If "http://vimeo.com/36519586" is the Vimeo link then <video-id> is "36519586".
Thank You!
No comments:
Post a Comment