Using jQuery, and only having the value of a video embed, how would you then parse it for YouTube/Vimeo to grab the thumbnail for the respective video?
Asked
Active
Viewed 1,622 times
0
-
To create thumbnails of video files, you need a library named FFMPEG. But, you cannot use it alongwith JQuery or Javascript :( and infact you cannot create video thumbnail using javascript as far as I know. But if you find some way to do that, then notify me too. Thanks. – Acn Jan 16 '12 at 11:25
1 Answers
0
At least youtube provides an API providing thumbnails for videos. All you need is the Video-id which you can easily extract from the embed code using regular expressions in javascript. You'll find a description of the simple API here: http://www.reelseo.com/youtube-thumbnail-image/
Edit: The problem of performing the same task on vimeo-videso has been discussed here: Get img thumbnails from Vimeo?
-
I'm pretty horrible at RegExp. Could you help me out with some RegExp code? I can probably take it from there. How would I pull something from src="http://www.youtube.com/embed/5PqqPzEGWL4"? how to say target the quotes after src? Then grab the id after embed? – Daniel Fischer Jan 16 '12 at 12:08
-
nvm figured one out: (youtube.com|vimeo.com)\/(video|embed)\/(\w+)\/? now to go from here.. :) – Daniel Fischer Jan 16 '12 at 12:36
-
Thats pretty simple: str.match(/embed\/([0-9a-z]*)/i). The id is the second item of the resulting array – Simon Jan 16 '12 at 12:37