Videocap.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:41k
- unit Videocap;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls,stdctrls,
- ExtCtrls,vfw,mmsystem,syncobjs;
- ///////////////////////////////////////////////////////////////////////////////
- // Video Capturing
- type
- // Types for audio-settings
- TChannel = (Stereo, Mono);
- TFrequency = (f8000Hz, f11025Hz, f22050Hz, f44100Hz);
- TResolution = (r8Bit, r16Bit);
- // Types for event-procedures
- type
- TCapStatusProc = procedure(Sender: TObject) of object;
- TCapStatusCallback = procedure (Sender:TObject;nID:integer;status:string) of object;
- TVideoStream = procedure (sender:TObject;lpVhdr:PVIDEOHDR) of object;
- TAudioStream = procedure (sender:TObject;lpWHdr:PWAVEHDR) of object;
- TError = procedure (sender:TObject;nID:integer; errorstr:string) of object;
- // Exceptions
- type ENoDriverException = class(Exception);
- type ENoCapWindowException = class(Exception);
- type ENotConnectException = class(Exception);
- type ENoOverlayException = class(Exception);
- type EFalseFormat = class(Exception);
- type ENotOpen = class(Exception);
- type EBufferFileError = class(Exception);
- type
- TAudioFormat = class (TPersistent)
- private
- FChannels :TChannel;
- FFrequency:TFrequency;
- FRes :TResolution;
- private
- procedure SetAudio(handle:Thandle); // Setting Audio Data to Capture Window
- public
- constructor create;
- published
- property Channels: TChannel read FChannels write Fchannels default Mono;
- property Frequency: TFrequency read FFrequency write fFrequency default f8000Hz;
- property Resolution : TResolution read FRes write FRes default r8Bit;
- end;
- type
- TVideoCap = class(TCustomControl)
- private
- fdriverIndex:integer; // Videodriver index
- fVideoDriverName : string; // name of videodriver
- fhCapWnd : THandle; // handle for CAP-Window
- fpDrivercaps : PCapDriverCaps; // propertys of videodriver
- fpDriverStatus : pCapStatus; // status of capdriver
- fscale : boolean; // window scaling
- fprop : boolean; // proportional scaling
- fpreviewrate : word; // Frames p. sec during preview
- fmicrosecpframe : cardinal; // framerate as microsconds
- fCapVideoFileName : string; // name of the capture file
- fTempFileName : String; // Name of temporary avi-file
- fTempFileSize : word; // size of Tmp- File in MB
- fCapSingleImageFileName : string; // name of the file for a single image
- fcapAudio :boolean; // Capture also audio stream
- fcapTimeLimit :word; // Time limit for captureing
- fIndexSize :cardinal; // size of the index in the capture file
- fcapToFile : boolean; // Write frames to file druing capturing
- FAudioFormat : TAudioFormat;// Audio Format
- fCapStatusProcedure : TCapStatusProc; // Event procedure for internal component status
- fcapStatusCallBack : TCapStatusCallback; // Event procedure for status of then driver
- fcapVideoStream : TVideoStream; // Event procedure for each Video frame during capturing
- fcapAudioStream : TAudiostream; // Event procedure for each Audio buffer
- fcapFrameCallback : TVideoStream; // Event procedure for each Video frame during preview
- fcapError : TError; // Event procedure for Error
- procedure setsize(var msg:TMessage); message WM_SIZE; // Changing size of cap window
- function GetDriverCaps:boolean; // get driver capitiyties
- procedure DeleteDriverProps; // delete driver capitilyites
- procedure CreateTmpFile(drvopn:boolean); // Create or delete a temp avi