NYCPHP Meetup

NYPHP.org

[nycphp-talk] SWF -> JPEG/GIF?

Artur Marnik artur at marnik.net
Thu Sep 18 14:19:46 EDT 2008


Artur Marnik wrote:
> csnyder wrote:
>> On Thu, Sep 18, 2008 at 12:39 PM, tedd <tedd at sperling.com> wrote:
>>> At 3:38 PM -0400 9/17/08, Ajai Khattri wrote:
>>>> Is there any way to generate a thumbnail image of a Flash movie 
>>>> (SWF) in
>>>> PHP?
>>>>
>>>> -- 
>>>> A
>>>
>>> Yep, there is a way -- I've seen it done. But, I didn't do I myself 
>>> and I
>>> don't have a reference for you. But, it IS possible.
>>>
>>
>> If nothing else, you could go the Rube Goldberg route: script to open
>> movie in browser window, take screenshot of browser window, then
>> resize the resulting image and return the thumbnail.
>>
>> For your sake, I hope there's a library (or maybe a 3rd party service
>> with an api) that just does it directly.
>> _______________________________________________
> 
> 
> You can use http://ffmpeg.mplayerhq.hu/
> great tool I used it but you need a ssh access to your box to compile 
> the binary (I am using 1and1 and I compiled it without root privileges)
> 
> I used to use this script:
> 
> <?
> $script_path = "/kunden/homepages/16/xxx/htdocs/ffmpeg";
> $flv_path = "/kunden/homepages/16/xxx/htdocs/";
> $jpg_path = "/kunden/homepages/16/xxx/htdocs/jpg/";
> $filename = "test.flv";
> $seconds = 10;
> $image_name = "frame";
> 
> for ($i = 0; $i <= $seconds $i++) {
>     $command = $script_path."/ffmpeg -i ".$flv_path."/".$filename.
>         " -ss ".$i." -vframes 1 -f gif -pix_fmt rgb24".
>         $jpg_path."/".$image_name."_".$i.".gif";
>     echo $command."<BR>\n";
>     exec($command);
> }
> 
> echo "done\n\n";
> ?>
> 
> it will give you 10 frames (every 1 second) starting form the beginning 
> of the movie
> it worked great but I don't remember why I used .gif instead of .jpg :) 
> maybe on 1and1 some jpeg library was missing
> 
> Artur


I just noticed that you want SWF -> JPG not FLV -> JPG
I read "flash movie" and assumed .flv

I am not sure if ffmpeg can do swf - check their docs

Artur



More information about the talk mailing list