Click here to Skip to main content
Click here to Skip to main content

Reader of SWF Header File in Pure C#

By , 10 Aug 2007
 
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
No Biography provided

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.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionHow does it handle garbage collection i cant dispose reader object Pinmemberinamul9-Dec-12 19:12 
AnswerRe: How does it handle garbage collection i cant dispose reader object Pinmemberzebulon750187-May-13 9:09 
GeneralMy vote of 5 Pinmembermanoj kumar choubey26-Feb-12 21:12 
NewsCode Snipped to implement Duration PinmemberHorst Klein24-Nov-11 0:59 
Questioninfo shown are totally off PinmemberMember 842930423-Nov-11 22:53 
GeneralMy Vote of 5 PinmemberAlan Burkhart11-Jun-11 6:12 
GeneralRe: My Vote of 5 Pinmemberzebulon750187-May-13 9:07 
GeneralMy vote of 1 Pinmembergunjan9um13-Jul-09 1:36 
GeneralMy vote of 1 Pinmembercrayzeecoder25-Jun-09 21:45 
GeneralRead FLV and Real Media file meta data PinmemberVishal Dedaniya22-Dec-08 10:42 
GeneralRe: Read FLV and Real Media file meta data PinmemberMember 438714318-Feb-09 3:16 
QuestionCan we read Compressed SWF files PinmemberShikhardadhich17-Sep-08 20:31 
AnswerRe: Can we read Compressed SWF files Pinmemberzebulon750181-Dec-08 9:09 
GeneralImproving read efficiency Pinmemberdssdss11-Oct-07 18:18 
GeneralRe: Improving read efficiency Pinmemberzebulon7501812-Oct-07 2:34 
QuestionVector info? PinmemberX3m10-Oct-07 9:34 
AnswerRe: Vector info? Pinmemberzebulon7501812-Oct-07 2:39 
GeneralRe: Vector info? PinmemberX3m14-Oct-07 22:49 
QuestionDoes this work with FLV files?? Pinmemberdclark12-Aug-07 13:01 
AnswerRe: Does this work with FLV files?? PinmemberSMStallings14-Aug-07 22:55 
GeneralRe: Does this work with FLV files?? Pinmembervidalc19-Aug-07 23:30 
AnswerRe: Does this work with FLV files?? I guess No :( Pinmembervidalc19-Aug-07 23:27 
GeneralRe: Does this work with FLV files?? Pinmemberzebulon750186-Feb-08 3:35 

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
Web01 | 2.6.130617.1 | Last Updated 10 Aug 2007
Article Copyright 2007 by zebulon75018
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid