views:

322

answers:

4

Hi,

i was wondering, how can i extract thumbnail from a flash-video file, then display it in a listbox.

the listbox is suppose to have many videos which i need to extract thumbnails from programatically with actionscript.

the flash-player is going to be on the web, and the extraction must happen when the swf file is loading, therefore, the method must not be too time-taking.

how do i go on about doing so? is this even possible?

tnx in advance

A: 

The best solution is to generate the thumbnail server side and send along the url to this image. If you want to do the thumbnails "on the fly" you will need to load the video first, at least up until the point where you'd like your screenshot to be taken, this will not be particularly fast.

grapefrukt
i see. I am going to use php on this site, so any idea how to do it with php?
mana
+1  A: 

You could use ffmpeg. Maybe calling a script would be the best approach.

thelost
hmm. are there any easy guide which explain how to do this with ffmpeg?
mana
You simply have to run a command (if you need something complex a command batch). As you stated above, you could use PHP's exec command and store the image paths in a database, for instance. Load them afterwards by using their URL.
thelost
A: 

You should take a look at FFMpeg - with it you can extract thumbnails from video (among other ton of cool stuff). Once you have it installed on your server, you just pass the command through PHP's exec() function and that's it.

For example:

$cmd = "ffmpeg -i you_video.flv -f image2 -vframes 1 -ss 00:00:01 -y -s 100x100 my_video_thumb.png";

exec($cmd, $output, $return);

Where:

-i is your specify the input file
-f is to force the output format, this case "image2" since we are generating an image
-vframes video frames we want to record in the snapshot, only one
-ss starting time of the snapshot
-y overwrite any existing file with the same name
-s size/dimensions of the output image

There are a some good tutorials on how to install FFMpeg on your server, if you google it you'll find tons of info. Here is a starting point though http://vexxhost.com/blog/2007/03/03/installing-ffmpeg-ffmpeg-php-mplayer-mencoder-flv2tool-lame-mp3-encoder-libogg-%E2%80%93-the-easy-way/

Cheers, M.

falomir
Does it mean that i can't simple put ffmpeg.exe on my server and then call it? Is it necessary to install it?
Laserson
If you are on a windows box just put the exe along some other DLLs and you are good to go, you can download the win32 binaries from http://ffmpeg.arrozcru.org/builds/ , some additional stuff you might wanna check out http://www.ehow.com/how_4716678_install-ffmpeg-windows.html
falomir
A: 

If you don't want to use ffmpeg I believe you could do the following:

load the main swf,

for each of the flv files,

  • load flv;

  • send the flv to the desired time;

  • create a new BitmapData Object;

  • draw the content of the flv to the
    bitmap data using draw method;

  • add the BitmapData to a Bitmap Object and display this in your listbox;

When this is complete show the main application

An aproach that does something simmilar to this but it uses cuepoints to trigger the drawing can be found here:

http://blog.flexexamples.com/2007/08/03/creating-flv-cuepoint-thumbnails-using-the-bitmap-and-bitmapdata-classes/

One more thing, in order to manipulate the flvs(the draw method to work) the files must reside in your own domain or there should be a crossdomain file on the root server that holds the flv which states that your domain is allowed access

Example: http://api.flickr.com/crossdomain.xml

Oliver