flv.int
上传用户:raido2005
上传日期:2022-06-22
资源大小:5044k
文件大小:5k
- //*******************************************************//
- // //
- // DelphiFlash.com //
- // Copyright (c) 2004-2008 FeatherySoft, Inc. //
- // info@delphiflash.com //
- // //
- //*******************************************************//
- // Description: tool functions for reading FLV files
- // Last update: 14 feb 2008
- unit FLV;
- interface
- Uses Windows, Classes, Contnrs,
- {$IFNDEF VER130}
- Types,
- {$ENDIF}
- SWFTools;
- type
- TVHeader = record
- CodecInfo: Byte;
- FrameCount: Word;
- KeyFrame: boolean;
- XDim: Word;
- YDim: Word;
- end;
- TSHeader = class(TObject)
- public
- MP3Frame: Cardinal;
- property Is16Bit: boolean read GetIs16bit;
- property IsStereo: boolean read GetIsStereo;
- property SoundFormat: byte read GetSoundFormat write SetSoundFormat;
- property SoundRate: byte read GetSoundRate;
- end;
- TVFrame = class (TObject)
- public
- property Len: LongInt read FLen write SetLen;
- property Start: LongInt read FStart write FStart;
- property InVideoPos: longint read FInVideoPos;
- end;
- TFLVDataType =
- (dtNumber, dtBoolean, dtString, dtObject, dtMovieClip, dtNull, dtUndefined,
- dtReference, dtECMAArray, dtStrictArray, dtDate, dtLongString);
- TFLVDataInfoType =
- (fdiDuration, fdiLastTimeStamp, fdiLastKeyFrameTimeStamp, fdiWidth, fdiHeight,
- fdiVideoDataRate, fdiAudioDataRate, fdiFrameRate, fdiCreationDate,
- fdiFileSize, fdiVideoSize, fdiAudioSize, fdiDatasize, fdiMetaDataCreator,
- fdiMetaDataDate, fdiVideoCodecID, fdiAudioCodecID, fdiAudioDelay,
- fdiCanSeekToEnd, fdiKeyFrames);
- TFLVCustomData = class (TObject)
- public
- function AsInteger: integer; virtual; abstract;
- procedure ReadFromStream(be: TBitsEngine); virtual;
- property VariableName: ansistring read FName write FName;
- property DataType: TFLVDataType read FDataType write FDataType;
- end;
- TFLVDataNumber = class (TFLVCustomData)
- public
- constructor Create;
- function AsInteger: integer; override;
- procedure ReadFromStream(be: TBitsEngine); override;
- property Value: double read FValue write SetValue;
- end;
- TFLVDataBoolean = class (TFLVCustomData)
- public
- constructor Create;
- function AsInteger: integer; override;
- procedure ReadFromStream(be: TBitsEngine); override;
- property Value: boolean read FValue write SetValue;
- end;
- TFLVDataWord = class (TFLVCustomData)
- public
- constructor Create;
- function AsInteger: integer; override;
- procedure ReadFromStream(be: TBitsEngine); override;
- property Value: Word read FValue write SetValue;
- end;
- TFLVDataDate = class (TFLVCustomData)
- public
- constructor Create;
- procedure ReadFromStream(be: TBitsEngine); override;
- property Value: TDateTime read FValue write SetValue;
- property LocalDateTimeOffset: single read FLocalDateTimeOffset write FLocalDateTimeOffset;
- end;
- TFLVDataString = class (TFLVCustomData)
- public
- constructor Create;
- function AsInteger: integer; override;
- procedure ReadFromStream(be: TBitsEngine); override;
- property Value: ansistring read FValue write SetString;
- end;
- TFLVDataECMAArray = class (TFLVCustomData)
- public
- constructor Create; virtual;
- destructor Destroy; override;
- procedure ReadFromStream(be: TBitsEngine); override;
- property Variable[index: integer]: TFLVCustomData read GetFLVCustomData;
- end;
- TFLVKeyFramesObjectData = class (TFLVCustomData)
- public
- constructor Create; virtual;
- destructor Destroy; override;
- procedure ReadFromStream(be: TBitsEngine); override;
- property KeyFrameCount: integer read FKeyFrameCount write SetKeyFrameCount;
- property Times[index: integer]: double read GetTimes write SetTimes;
- property Positions[index: integer]: longint read GetPosition write SetPosition;
- end;
- TFLVonMetaData = class (TFLVDataECMAArray)
- public
- function GetInfo(fdi: TFLVDataInfoType): TFLVCustomData;
- procedure ReadFromStream(be: TBitsEngine); override;
- property ObjectName: ansistring read FName write FName;
- end;
- TFLVData = class (TObject)
- public
- constructor Create(Fn: String);
- destructor Destroy; override;
- procedure Parse;
- function GetSoundFromList(index: Cardinal): TVFrame;
- property Data: TStream read FData write FData;
- property FileName: string read FFileName write FFileName;
- property Frame[index: LongInt]: TVFrame read GetFrameFromList;
- property FrameCount: Word read GetFrameCount;
- property Header: TVHeader read FHeader;
- property SoundExist: boolean read GetSoundExist;
- property KeyFrameCount: longint read FKeyFrameCount;
- property SoundPresent: boolean read FSoundPresent;
- property VideoPresent: boolean read FVideoPresent;
- property SoundCount: Cardinal read GetSoundCount;
- property SoundHeader: TSHeader read GetSoundHeader;
- property FPS:Word read FFPS;
- end;
- implementation