Wouldn’t it be cool if you could read the meta-data of Swf file in ColdFusion? The most common use case I can think of is to find the dimension of swf movie so that you can set the dimension for the same in object tag while you are embedding the flash movie in your page. And the good news is that you can do that currently in ColdFusion with just 2-3 lines of code!! All you need to do is to create a TagDecoder and decoder the header with it. Here is the complete code.
<cfscript> fis = createObject("java", "java.io.FileInputStream").init("C:\test.swf"); // Create the FileInputStream decoder = createObject("java", "macromedia.swf.TagDecoder").init(fis); // create TagDecoder header = decoder.decodeHeader(); // Decode the header. fis.close(); rect = header.size; WriteOutput(" Is Compressed : #header.compressed#<br> Frame Count : #header.framecount#<br> Frame rate : #header.rate#<br> Version : #header.version#<br> Height : #rect.getHeight()#<br> Width : #rect.getWidth()#"); </cfscript>
The height and width value that you see here would be in twips which is defined as 1/20 of a point or 1/1440 inch. This means, for a 72 dpi screeen, you will have to divide it by 20 to get the height and width in pixels.

#1 by Giancarlo Gomez on February 15th, 2008
| Quote
Thank you so much!!!!!!! This is great as I can use this in a current project to display movies!!!! Never knew you could do this. Great Post!
#2 by Steve Bryant on February 15th, 2008
| Quote
This is great! Where did you find this?
#3 by Rupesh Kumar on February 18th, 2008
| Quote
Thanks guys! It will be great if you could share where you need the meta-data for flash movies.
Steve, I am part of the ColdFusion engg team
#4 by Giancarlo Gomez on April 2nd, 2008
| Quote
Hello Rupesh,
I am currently creating a site that will use this feature and once it is up I will post the link and explain how it is used. Thank you again!
#5 by Thomas on June 5th, 2008
| Quote
I’m trying to display the movie duration.. how can I do that?
#6 by Rupesh Kumar on June 5th, 2008
| Quote
Thomas, that will be framecount/framerate.
#7 by Thomas on June 5th, 2008
| Quote
Is Compressed : NO
Frame Count : 4608
Frame rate : 0
Version : 1
Height : 1
Width : 0
this is what I getting pulling from my file. Is it because i’m reading a .flv file.. I just want to get the duration of a .flv video to put in a database… not sure how..??