Welling Posted November 15, 2008 Share Posted November 15, 2008 Hi! I'm trying to get thumbnails of SWF files in png or any other image format. I know there are desktop applications that do this but I would like to do this from php or with a linux program. Like I do with images I can't do with SWF because ImageMagick doesn't support SWF. Any idea? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/132849-make-thumbnail-of-swf/ Share on other sites More sharing options...
The Little Guy Posted November 17, 2008 Share Posted November 17, 2008 If you are loading flv files into your swf files, you can use ffmpeg to take a snapshot of a frame in a video... SWF can take snap shots of its self I believe... How/what do you have access to for the SWF file? Quote Link to comment https://forums.phpfreaks.com/topic/132849-make-thumbnail-of-swf/#findComment-692040 Share on other sites More sharing options...
Welling Posted November 18, 2008 Author Share Posted November 18, 2008 The SWF is a file which is in a folder of my host and I would like to show a small thumb of the swf in image format to avoid having to load a flash. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/132849-make-thumbnail-of-swf/#findComment-692803 Share on other sites More sharing options...
dreamer79 Posted May 12, 2010 Share Posted May 12, 2010 I found a few ways to get thumbnails from swf using php. Today I was researching if I could make a game site of mine handle uploads as I use Mochi media games for this moment only. The first one is complicated- php-ffmpeg is a PECL extension that allows getting frames from avi, flv, mpg. It can't work with swf. There's a project you can use to convert swf to avi in php, but it uses some python stuff I couldn't make work on my Ubuntu. Maybe someone will try this approach. Just search for "pyvnc2swf" on google. Another aproach is to take a browser screenshot. This was a successful strategy for me. There are two possible projects I found. The problem is that they can't work on a normal hosting machine. For video manipulation this is not such a problem though. There'a a class in phpclasses that uses Mozilla to capture images. It needs X installed. I couldn't try it, because I can't install libxul on Ubuntu 10.04, but I used a similar approach with a Windows XP virtual machine. So... The steps I used to succeed: 1. Make the virtual host visible to the main machine. I didn't have such connection. It was simple- create a host adapter for the VM. 2. Install WAMP. Another windows apache+php bundles may need extra installation of COM support. For the scripts to work you need to make some administrative tasks- go to control panel- administrative tools - services. Select apache and in the properties window in Log On check "Allow this service to interract with desktop.". 3. Get the capture class from http://www.phpclasses.org/package/4608-PHP-Take-screenshots-of-pages-with-Internet-Explorer.html . 4. Patch the screenshot.class.php file this way: - add a public $sleep=0; variable for the class - patch the navigate function this way: public function navigate( $url = 'about:blank' ) { $url = ( $url ) ? $url : 'about:blank'; $this->IE->Navigate( ($url) ? $url : 'about:blank' ); $this->url = $url; $time = time(); if ($this->sleep){ set_time_limit(100); sleep($this->sleep); } while ( $this->IE->ReadyState != '4' and $time + 2 > time() ) { $this->pump(); } if ( $this->pump ) { $this->pump( 1000 ); } return true; } The code for sleep is mine. 5. Write a simple script to fetch images: require_once('screenshot.class.php'); class_exists('screenshot') or die('screenshot class does not exist.'); $screen = new screenshot(false, 768, 1024); $screen->sleep= 30; $screen->navigate('http://hot2.kefche.net/games/d67wtx.swf'); $screen->title('You can set custom titles too (and custom body if you want)'); $screen->position(0, 0); $screen->screenshot(); $screen->output(); $screen->save('image.jpg'); $screen->quit(); unset($screen); Why do we need sleep(30)? When a flash game is loaded it has some loading time, advertising. The screenshot script without sleep would get the loading bar most of the times. So... We have a really slow thumbnail system. What we need is some extra stuff for a queue of the swfs and sending images to the main server. A cron called once every 2-3 minutes for a thumb will help too. Maybe an infinite process with no cron is possible on a machine that servers thumbnails only. The attached image is generated by the script I described. http://dreamer79.eu , http://dreamerwebdesign.blogspot.com (blog in bulgarian language) [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/132849-make-thumbnail-of-swf/#findComment-1057302 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.