Categories
Tools

Get youtube video screenshot using Javascript

Last updated on May 25th, 2016 at 01:14 pm

Click to rate this tutorial!
[Total: 25 Average: 3.7]

Get youtube video screenshot using Javascript

Simple script to get the screenshot of a particular URL from youtube,

You can modify the url variable below according to your convenience.
We are parsing the URL you supply and get the video ID from the query string. Pass that video ID to the above image URL to get the screenshots / thumbnails.

You might also be interested in this tutorial Get Youtube Video Screenshot Using Jquery

<script type="text/javascript">
function getScreen( url, size ) {
if(url === null){
return ""; 
} 
size = (size === null) ? "big" : size; 
var vid; 
var results;
results = url.match("[\\?&]v=([^&#]*)");
vid = ( results === null ) ? url : results[1];
if(size == "small"){
return "http://img.youtube.com/vi/"+vid+"/2.jpg"; }
else {
return "http://img.youtube.com/vi/"+vid+"/0.jpg"; }
}
</script>
<script type="text/javascript">
var url = "http://www.youtube.com/watch?v=hQVTIJBZook";
var imgUrlbig = getScreen(url);
var imgUrlsmall = getScreen(url, 'small');
document.write('<img src="' + imgUrlbig + '" />');
document.write('<img src="' + imgUrlsmall + '" />');
</script>

Disclaimer: We are not responsible for usage of this script. This script is widely available in the Internet. All we are doing here is helping our users to understand how best we can use Javascript.

Click to rate this tutorial!
[Total: 25 Average: 3.7]

3 replies on “Get youtube video screenshot using Javascript”

But how do get screenshot from video? Let say at 1min of video

Leave a Reply

Your email address will not be published.