Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have checked and read lot of post about one single issue that is far more complicated than it seems.

I have a website that uses a lot of videos taken from wwebsite as on the internet ^^ (services like youtube, vimeo, videobuzzy, etc) and we would like to generate on the fly a thumbnail of the embedded video.

Each service uses its own API so I should adapt code for each, which it far too much code and I could never manage every service.

A webserver propose something like that : http://embed.ly but I tried them and, as exemple, videos from videobuzzy doesn't work. So that's a partial solution.

Another solution would be to use a screenshot service that could request the video's URL, render it, take a snapshot and generate an image. Tempting, but results tends to add delays, and I have to find a snapshot service and generate the code (well, this could be the fun part).

The simpliest would be to take a screen capture and create an image ourselves, then upload it.

I would rather propose something more user-friendly but I have no more clue.

Is anyone has some advice on it and do I get the picture right ?

Thank you.

ADDENDUM **

If I could, instead of the thumbnails, just embed the video (usually an iframe) into a with specific size, that could do the trick...

share|improve this question
    
One way found was via a plugin: wordtube. Generally covering JW Player.. but maybe useful. –  majicmike Sep 18 '12 at 19:31
add comment

2 Answers

up vote 16 down vote accepted

You can use the oEmbed functionality baked into WordPress. Typically any video host on this list will return a thumbnail to you using oembed.

Here is a list of default providers that WordPress uses for auto embedding in the content area. I've included non-video sources as well for the convenience of others.

Select your provider then use the following to get your video information.

require_once(ABSPATH.'wp-includes/class-oembed.php');
$oembed= new WP_oEmbed;
$url = 'http://www.youtube.com/watch?v=oHg5SJYRHA0';
//As noted in the comments below, you can auto-detect the video provider with the following
$provider = $oembed->discover($url);
//$provider = 'http://www.youtube.com/oembed';
$video = $oembed->fetch($provider, $url, array('width' => 300, 'height' => 175));
$title = $video->title;
$html = $video->html;
$thumb = $video->thumbnail_url;

I realize VideoBuzzy is not on the list. It appears to be a YouTube knockoff site. You should ask them if they have oembed protocols. If they don't, you can register a non oembed handler by using wp_embed_register_handler().

Hope this helps!

share|improve this answer
    
Sounds real nice ! But is there a quick way to get the $url from the post instead of beign hardcoded ? –  Simon Feb 1 '12 at 16:47
1  
Right now, i'm just using custom field to place my video url. Working nice, keep testing... Many thanks, Brian ! I just adapted the code by adding $provider = $oembed->discover($vid_url); so I don't need to hardcode the video provider –  Simon Feb 1 '12 at 17:33
    
@Simon Can you share the final code that helped to implement this? And kindly give us some details on how to implement this? I have same requirements but not sure how to do this on WP, I'm still new to WP. Thanks –  Krunal Oct 28 '12 at 14:34
    
@Krunal Yes I could, it's pretty close to Brian's solution ! I just added a fallback image and update meta data if the oEmbed succeed, so I don't have to ask each time. But I don't how to send it to you, since i cannot add code in comments, and I don't feel it's worth an new answer ? –  Simon Oct 31 '12 at 18:30
1  
@Sisir Actually, there is. You can look here: codex.wordpress.org/Function_Reference/… Register a non-oEmbed handler first, then use the code above. :) –  Brian Fegter Dec 26 '12 at 14:33
show 4 more comments

You can use this plugin Wordpress Video Plugin and edit the code of this plugin and add the other sites in it.

OR

You have to integrate FFMPEG in wordpress.

share|improve this answer
    
Thank you, I'd rather avoid using plugins when I can avoid it ^^ –  Simon Feb 1 '12 at 17:05
    
@Simon It was meant as a reference: Go into the files "_and edit the code of this plugin". :) –  kaiser Feb 3 '12 at 6:57
    
@kaiser -yes, you're right, the plugin code should provide insight and working implementation ^^ –  Simon Feb 3 '12 at 11:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.