UnderMine has asked for the wisdom of the Perl Monks concerning the following question:

I currently have a system that allows the upload of Flash files to be embedded in dynamic webpages.

Now comes the hard part. I need to extract enough info out of the files to be able to generate the appropriate embedded object in the HTML.

<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase= +"http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0 +" ID=test WIDTH=270 HEIGHT=250> <PARAM NAME=movie VALUE="/flash/welcome3.swf"> <PARAM NAME=menu VALUE=false> <PARAM NAME=quality VALUE=high> <PARAM NAME=salign VALUE=RB> <PARAM NAME=bgcolor VALUE=#cccccc> <EMBED src="/flash/welcome3.swf" menu=false quality=high salig +n=RB align="center" bgcolor=#cccccc WIDTH=270 HEIGHT=250 TYPE="appli +cation/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shoc +kwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED> </OBJECT>
The important parts are the width and height but I would also like to be able to verify the version used (to stop uploading of Flash 6 files) and whether the file is actually a valid Flash file.

I have looked at CPAN with no luck. Perl::Flash and Flash::SWF handle flash but these seem to be based on version 3 or 4 and have not been updated for ages.

Does anyone know how to do this?

Thanks in advance
UnderMine

Replies are listed 'Best First'.
Re: Extracting info from SWF Files
by tachyon (Chancellor) on Nov 23, 2002 at 16:19 UTC

    Perhaps you could find out about the SWF format http://www.openswf.org/spec/SWFfileformat.html

    You might then consider updating the existing modules to do what you want. The author of Flash::SWF asks for help to do just this. As it happens Flash::SWF is a nice bit of OO code that does not require much modification to do what you want....

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      Thanks for that. The open SWF format appear to go upto version 3. However the full spec of SWF 6 is available from MacroMedia and Open SWF spec goes upto version 5 now. This would at least give an idea about the magnitude of work required. Perl::Flash appears to go upto version 4 but is only just ahead of Flash::SWF but I think that this can easily be caught up.

      The only problem I can see with updating the modules is that Flash 4 and above contain ActionScript a simple programming language in its own right.

      This is going to be hard work... but it could be a lot of fun. Anyone be interested in serving personalised Flash on demand?

      Hope this is worth it...
      UnderMine

      Asside: ajt mentioned this which shows how to cut down the size of the Flash embedded object tags.

      After digging quite a way I think I have found what I am looking for.

      Barely documented feature of ming is its perl support.

      Project: Ming - an SWF output library: Summary output library Ming is an SWF ("Flash") file format output library. It is written in C, with wrappers for C++, Python, and PHP, plus rudimentary support for Ruby and Perl.
      Also on CPAN there is SWF::File which is far more upto date than Flash::SWF or Flash::perl and already has Flash 6 support. But this seams overly complex for the job at hand.

      What I can see needing to be done in the not so far future is a merging of these to areas and approaches.

      Just for general info
      UnderMine