Click here to Skip to main content
Licence CPOL
First Posted 10 Aug 2007
Views 57,940
Downloads 958
Bookmarked 27 times

Reader of SWF Header File in Pure C#

By | 10 Aug 2007 | Article
Reader of SWF header file in pure C# with a single class
Screenshot - SwfHeaderReader.jpg

Introduction

It's my first article on The Code Project. Please excuse my English.

This article describes how to read the header of the flash file. (This file has the extension .swf )

The Format Header SWF is described in this link.

You can also read a good article on SWF which describes the library SwfDotNet.

I wrote this article for myself and for people who want small source code.
To read this header, I translate PHP code to C#. The original source code in PHP is at this address.

This is the code of a class which can provide information of the Swf Flash:

  • FrameRate
  • FrameCount
  • Width
  • Height
  • Version

Warning, this class doesn't work with the compressed Flash File.

Using the Code

The name of the class is FlashHeaderReader and takes for the constructor a parameter, the filename of the flash file.

It calls these methods:

  • ReadSignature();
  • mVersion=GetNextByte();
  • ReadFileLength();
  • ReadFrameSize();
  • ReadFrameRate();
  • ReadFrameCount();

Later, you can access the properties of the swf file :

FlashHeaderReader swfreader = new FlashHeaderReader(openFileDialog1.FileName);

listBox1.Items.Clear();
listBox1.Items.Add("Frames : " + swfreader.FrameCount);
listBox1.Items.Add("Width : " + swfreader.Width );
listBox1.Items.Add("Height : " + swfreader.Height);

Points of Interest

The method ReadFrameSize is complex because the swf format also compresses the header and information has a different size.

History

  • 10th August, 2007: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

zebulon75018

Software Developer (Senior)
http://www.cmb-soft.com/
France France

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 5 Pinmembermanoj kumar choubey21:12 26 Feb '12  
NewsCode Snipped to implement Duration PinmemberHorst Klein0:59 24 Nov '11  
Questioninfo shown are totally off PinmemberMember 842930422:53 23 Nov '11  
GeneralMy Vote of 5 PinmemberAlan Burkhart6:12 11 Jun '11  
GeneralMy vote of 1 Pinmembergunjan9um1:36 13 Jul '09  
GeneralMy vote of 1 Pinmembercrayzeecoder21:45 25 Jun '09  
GeneralRead FLV and Real Media file meta data PinmemberVishal Dedaniya10:42 22 Dec '08  
GeneralRe: Read FLV and Real Media file meta data PinmemberMember 43871433:16 18 Feb '09  
QuestionCan we read Compressed SWF files PinmemberShikhardadhich20:31 17 Sep '08  
AnswerRe: Can we read Compressed SWF files Pinmemberzebulon750189:09 1 Dec '08  
GeneralImproving read efficiency Pinmemberdssdss18:18 11 Oct '07  
GeneralRe: Improving read efficiency Pinmemberzebulon750182:34 12 Oct '07  
QuestionVector info? PinmemberX3m9:34 10 Oct '07  
AnswerRe: Vector info? Pinmemberzebulon750182:39 12 Oct '07  
I know some code in Java :
 
http://anotherbigidea.com/javaswf/javaswf1.html
 
May be it can help you.
 


GeneralRe: Vector info? PinmemberX3m22:49 14 Oct '07  
QuestionDoes this work with FLV files?? Pinmemberdclark13:01 12 Aug '07  
AnswerRe: Does this work with FLV files?? PinmemberSMStallings22:55 14 Aug '07  
GeneralRe: Does this work with FLV files?? Pinmembervidalc23:30 19 Aug '07  
AnswerRe: Does this work with FLV files?? I guess No :( Pinmembervidalc23:27 19 Aug '07  
GeneralRe: Does this work with FLV files?? Pinmemberzebulon750183:35 6 Feb '08  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120529.1 | Last Updated 10 Aug 2007
Article Copyright 2007 by zebulon75018
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid