When a user shares a video from youtube or google video, it would be nice if there was a way for automatic thumbnailing since yt and gv already have thumbnails created. I am not a programmer by any means but thought there could be useful code found in http://helmetcameracentral.com/2006/01/11/videobloggerplugin/ , video blog plugin for wordpress that might have some useful code that can implement this feature for the video module. Cheers, Ivan

Comments

Veggieryan’s picture

+1 on this
this is crucial. Its a pain in the @$$ to add these manually. most users never do.. and you end up with an ugly video gallery.

i'd put cash towards this.. contact me.
thanks
ryan.

mudanoman’s picture

Hey Ryan,

I am currently working to find someone to do this. I will email you, but we should collaborate our efforts.

Cheers,

Ivan

fax8’s picture

guys, this is definitely a good feature to have...
What is the status of this? Do you finally had it to work?

If so please roll out a patch.

Thanks,

Fabio

mudanoman’s picture

Fabio,

Did you get my email with the attached version. Email me if otherwise.

Peace,

Ivan

fax8’s picture

Oh.. yes I got it... I didn't understood you were the same person.

Thanks,

Fabio

Veggieryan’s picture

any update on this?
the module is basically unusable for youtube videos.
it makes more sense to create a CCK type and just use the embed code.
its more functional and easier than manually taking screenshots to make thumbnails!

911’s picture

Is there a automatic Thumbnail Patch for version 5.x-1.x-dev? Would be nice to attache here.

teamrob’s picture

Any update on this? Auto thumbnails for teasers from absolute urls maybe using ffmpegg?

I will donate 20$ for this

teamrob’s picture

I looked into this further. Currently it doesnt look like you can get google video thumbs unless you want to hack some wierd parser that would probably only work temporarily.

For youtube you just need an api and then parse the data
http://www.youtube.com/dev_api_ref?m=youtube.videos.get_details

There is a video cck module http://drupal.org/project/video_cck that is supposed to do this but it does not work for thumbsnails and its unknown if this is even being developed anymore.

How hard would it be to include some of that snazzy api data into the video.module, it would be great for teasers and such.
Still 20$ bounty on including the youtube api

cheers

teamrob’s picture

Just a follow up this currently does work with the newest video cck version

jyamada1’s picture

subscribe

jyamada1’s picture

Version: master » 5.x-1.x-dev
StatusFileSize
new8.35 KB

Here's a working prototype, rolled against current 5.x-1.x-dev.

Basically this patch plugs the useful thumbnail grabbing functions from video_cck.module into video_image.module. The thumbnail is pulled from the url into temp, and then plugged through the normal video_image_nodeapi call.

Known bugs: video_upload throws a "file not stored" error every time.

reviewers could pay particular attention to security in the file handling code, since i am completely new to these sorts of manipulations.

i'm hoping that with work on breaking up video.module into a more pluggable system that this code will get cleaner.

jyamada1’s picture

Todo:

  • add check so duplicate thumbnails are not created
  • make sure that the temp file is deleted (only in the auto thumb cases?)
teamrob’s picture

Are you able to resize with the temp storage or any option to keep it stored permanently?

I was trying to get the video cck writer to try that since the actual thumbnails from the various services are all a diff size.Having them resized to all be the same would look very consistent but would require some storage and prob use of image_cache module or another image module, I posted some links and rough code about this in video cck features.

thanks

jyamada1’s picture

ah, the images are stored permanently as image nodes.

what i meant by passing through video_image_nodeapi($op='submit') is that these thumbnails are handled the same way that ffmpeg created thumbnails and manually added thumbnails are currently handled in video_image. That is, the image (which is, in this case, a temp file downloaded from the provider) is passed through image node creation functions, and an image node is created that is linked to the video through an 'iid'.

right now, my set up is that acidfree displays resized thumbnails (created through image.module) in a video gallery. this makes use of the default functionality of image.module and acidfree.module and so should happen automatically with the patch above. one could use either image.module's resizing functions or imagecache to handle this in a more direct way.

from what i saw in video_cck, the thumbnails are displayed directly from the url. in fact, the only thing this patch really does is rework the API code from video_cck to take the urls and make them into permanent images.

btw, anyone know any copyright issues about storing these images?

preetinder’s picture

I was able to display youtube generated thumbnails easily by making some modifications in video.module

I found out that Youtube creates 3 thumbnails for each uploaded video. I have not put much time into it and have done 5 mins of research on youtube, so the thumbnail storage path may change in near future... but it is working for now.

so for http://www.youtube.com/watch?v=gwZD59Ic9T8 video, it generates following thumbnails.

http://img.youtube.com/vi/gwZD59Ic9T8/1.jpg
http://img.youtube.com/vi/gwZD59Ic9T8/2.jpg
http://img.youtube.com/vi/gwZD59Ic9T8/3.jpg

gwZD59Ic9T8 is the video file.. which is accessible by $node->vidfile in video.module for each uploaded video

I modified video.module file and added a function for displaying thumbnail.

function theme_video_display_youtube_thumb($node) {
  $width = '110';
  $height = '90';

  // output img tag with thumbnail
  $output = '<img src="http://img.youtube.com/vi/'. check_plain($node->vidfile) .'/2.jpg"  width="'. $width .'" height="'. $height .'" />';

  return $output;
}

Do let me know if you have any difficulties integrating it. I am currently working on way to find thumbnails for Google videos Or any other video sharing sites and then will integrate them in video module.

I will post the URL of website once its complete :)

Jboo’s picture

Component: Miscellaneous » Code

Tony - I added the code you posted (without the opening and closing PHP tags) to the end of my video.module. Is this correct?

I can't seem to see any thumbnails though :-(

Is there something I've done wrong?

Jboo’s picture

As a followup to my last post - i've added a PHP statement to page.tpl and the thumbnail now shows. Is there anyway I could create a block with these thumbnails and make them clickable?

anarcat’s picture

Status: Active » Needs work
StatusFileSize
new1.24 KB

So there's two approaches here: one which is the old approach of keeping a local copy of the thumbnail (patch #12 here from jyamada1, taken from video_cck), and a new idea of just referencing the url straight from Youtube (comment #16, from tony31).

The attached patch does the latter simply and cleanly. There's a if that is not removed completely but just commented out for clarity. It does depend on youtube's internal API and does not work with other providers like Google.

anarcat’s picture

Status: Needs work » Needs review

With two patches, I guess it's more a review we need...

fax8’s picture

Status: Needs review » Fixed

on my rewrite I finally implemented the local copy way.
Automatic thumbnails works pretty well.

I'm pretty sure that doing hotlinking is really not a good thing.

The new version will be published soon.

Fabio

p.s.: setting this as fixed. feel free to reopen if you want to discuss more.

Anonymous’s picture

Status: Fixed » Closed (fixed)
rubenk’s picture

Status: Closed (fixed) » Active

excellent. i can't wait for this to come out.

is it too hard to implement this with google as well and/or can this be opened up to other sites possibly by allowing the admin to enter thumbnail URL variables to be used with uploads....admittedly I am just interested in google but seriosuly

This was a great step.
if only the new release was out ;-)

feel free to close if its a separate issue

fax8’s picture

Status: Active » Fixed

the rewrite support youtube and google automatic thumbnailing.
the user can override the auto thumbnail uploading an image.

does it works?

rubenk’s picture

very good

Anonymous’s picture

Status: Fixed » Closed (fixed)
scottrigby’s picture

Category: feature » support

Can you clarify what you were able to get to work in the final call? I've been using embed media, which includes video_cck. It's not clear to me how to access the options for adding thumbnails. The Read Me file in the video_cck folder (in emfield folder) says to look "on the Display Fields settings page" for the options. Thanks

scottrigby’s picture

Status: Closed (fixed) » Postponed (maintainer needs more info)
rubenk’s picture

are you sure you are in the right place? the video module is not the same as video cck or really in any way related.

boytaichi’s picture

hi,
i have tried to insert the code,

function theme_video_display_youtube_thumb($node) {
  $width = '110';
  $height = '90';

  // output img tag with thumbnail
  $output = '<img src="http://img.youtube.com/vi/'. check_plain($node->vidfile) .'/2.jpg"  width="'. $width .'" height="'. $height .'" />';

  return $output;
}

but now not only i don't have the auto-thumbnail, but i lost the path for video, i.e., mysite.com/video. can you help?

Anonymous’s picture

If you are allowing your sites users to embed youtube video files using the embedded code from youtube, here is an alternate method you might want to try:

	elseif (preg_match("/youtube/i", $field['field_embedded_link'][0]['value'])) {
	preg_match('/(http:\/\/www.youtube.com\/v\/)(.+)(\"><\/param><param)/', $field['field_embedded_link'][0]['value'], $matches);
	//print_r($matches);
	$match = trim($matches['2']);
	$fieldthumb = 'files/youtube/t' . strtolower($match) . '.jpg';
		if (file_exists($fieldthumb)) { //if the file was already downloaded just output.
			$output = '<table><tr><td rowspan=2 class="firstcol">' . theme('imagecache','recentposts',$fieldthumb) . '</td>';
			} else {
			$youtube_thumb = "http://img.youtube.com/vi/".$match."/default.jpg";
			copy($youtube_thumb, $fieldthumb);
			if (!file_exists($fieldthumb)) {
				copy($youtube_thumb, $fieldthumb); //retry only once if fails to be safe due to http transfer errors
			 
				if (file_exists($fieldthumb)) {
				chmod($fieldthumb, 0775);
				$output = '<table><tr><td rowspan=2 class="firstcol">' . theme('imagecache','recentposts',$fieldthumb) . '</td>';
				} else { //do not show the placeholder if the file does not exist
				$output = '<table><tr>';
				}
			}
		}
	
	}
Anonymous’s picture

I forgot to mention... As it is obvious, it needs a little cleanup.
You put this code in a module wherever you like the thumbnail to be shown. You also need the $node object as an array in the beginning of the code as:

$field = get_object_vars($node);

Here is a little cleanup and explanation:

    if (preg_match("/youtube/i", $field['field_embedded_link'][0]['value'])) {
    preg_match('/(http:\/\/www.youtube.com\/v\/)(.+)(\"><\/param><param)/', $field['field_embedded_link'][0]['value'], $matches);
    //print_r($matches);
    $match = trim($matches['2']);
    $fieldthumb = 'files/youtube/t' . strtolower($match) . '.jpg';
        if (file_exists($fieldthumb)) { //if the file was already downloaded just output.
            $output = theme('imagecache','recentposts',$fieldthumb);
            } else {
            $youtube_thumb = "http://img.youtube.com/vi/".$match."/default.jpg";
            copy($youtube_thumb, $fieldthumb);
            if (!file_exists($fieldthumb)) { // you can omit this if and the duplicate copy below (it is just an ugly hack for the system which could not able to connect at once)
                copy($youtube_thumb, $fieldthumb); //retry only once if fails to be safe due to http transfer errors
            
                if (file_exists($fieldthumb)) {
                chmod($fieldthumb, 0775); // can be a more secure one up to your choice
                $output = 'theme('imagecache','recentposts',$fieldthumb);
                } else { //do not show the placeholder if the file does not exist
                $output = 'something else';
                }
            }
        }
    
    }

Then return your output in the end of your code.

Please let me know if you need more help on this code.

Thanks.

Anonymous’s picture

Additional to above this code needs to have imagecache.module installed, as I needed it for creating the thumbnail smaller.

You can remove that part if you like it in the default Youtube size.

Anonymous’s picture

Correction for the latest code:

$output = 'theme('imagecache','recentposts',$fieldthumb)

is a typo and should be:

$output = theme('imagecache','recentposts',$fieldthumb)
theorichel’s picture

I do not quite understand: is the current development version supposed to work with thumbnails? I do not get automatic thumbnails from Google or You Tube and I am not able to get hyperlinked thumbnails in a block (either the latest videos block or a Vierws based block.
In my Views based block I do manage to get a non-hyperlinked thumnbail (through attached image), but that is all.
Switching the options at Video Image make no difference.

It is unclear how important FFMPEG is, one apparently does need it to get the thumbnails that come with Google an You Tube, or is it indispensable for the whole functioning of the module?
Anyway, when I try to link to a YT video and just give in the code (as you suggest) then I get the message that the ' File type is not supported'. Afterwards I can play it however.

Someone here offered 20 dollars, may I join that offer? Will you let us know a reaction?

ChatFriendz’s picture

Title: Automatic Thumbnailing for Youtube and Google Video » I have already installed Youtube video mod in mysite
StatusFileSize
new418 bytes

Hi! Friends nice to meet all of you guys, I hope, get answer, I installed the following mod in my website, How can program with the Abow thumbnail picker for youtube video, please suggestion how to do this, My code Attach

drupalfriend’s picture

Hi Tony,

Pls contact me - stso009@yahoo.com. I need some help from you.

iLLin’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)