TVideoGrabber
Version 6.0 rev d - February 5, 2003
Home page: http://www.datastead.com
mirror#1: http://www.delphicity.com
mirror#2: http://www.datastead.info
Contact: contact@datastead.com
Support: support@datastead.com
OVERVIEW OF THE MAJOR METHODS, PROPERTIES AND EVENTS, BY CATEGORY
Preview
AVI capture
Frame capture
Auto-generated file names
DV (Digital Video)
Video device
Audio device
Playback
Drawing over frames
Third-party filters
Transparency
Miscellaneous
Frame capture
Video format
Avoiding dropped frames
Writing text over frames
Drawing shapes over frames
Audio/video compression
Interactive vs. programmatically use
Device-dependent parameters
Component dynamically created at runtime
Player
Third-party filters
Transparency
ProVideo multi-ports capture card SDK
procedure FastForwardsPlayerprocedure AttachVideoWindow
function AudioCompressorName
function AudioDeviceName
function CaptureFrameTo
procedure ClosePlayer
function CrossbarCanConnectInput
function CrossbarConnectInput
function CrossbarGetInputConnected
function CrossbarGetPinCounts
procedure DetachVideoWindow
procedure DynamicallyCreated
property AnalogVideoStandards: string;
property AudioCompressors: string;
property AudioCompressorsCount: longint;
property AudioDevices: string;
property AudioDevicesCount: longint;
property AudioFormats: string;
property AudioInputs: string;
property AudioInputsCount: longint;
property AutoConnectRelatedPins: boolean;
property Busy: boolean;
property CaptureDuration: double;
property CurrentFrameRate: Double;
property CurrentState: TCurrentState;
property DeliveredFrames: int64;
property DroppedFrames: longint;
property ImageRatio: double;
property InFrameProgressEvent: boolean;
property IsAnalogVideoDecoderAvailable: boolean;
property IsAnalogVideoIn: boolean;
property IsAudioCrossbarAvailable: boolean
property IsDigitalVideoIn: boolean;
property IsDirectX8OrHigherInstalled: boolean;
property IsVCRCommandAvailable: boolean;
property IsTimeCodeReaderAvailable: boolean;
property IsTVTunerAvailable: boolean;
property IsOverlayAvailable: boolean;
property IsVideoCrossbarAvailable: boolean;
property IsVideoQualityAvailable: boolean;
function IsWDMVideoDriver: boolean;
property Last_AVICapture_FileName: string;
property PlayerDuration: int64;
property PlayerFrameCount: int64;
property PlayerFramePosition: int64;
property PlayerFrameRate: double;
property PlayerTimePosition: int64;
property VideoCompressors: string;
property VideoCompressorsCount: longint;
property VideoCrossbarInput: longint;
property VideoCrossbarInputs: string;
property VideoCrossbarInputsCount: longint;
property VideoDevices: string;
property VideoDevicesCount: longint;
property VideoDeviceKsPropertySet: IKsPropertySet;
property VideoDevicePinKsPropertySet: IKsPropertySet;
property VideoHeight: longint;
property VideoSizes: string;
property VideoSizesCount: longint;
property VideoSubTypes: string;
property VideoSubtypesCount: longint;
property VideoWidth: longint;
property VideoWindowHandle: HWND;
property AnalogVideoStandard: longint;
property AudioCompressor: longint;
property AudioDevice: longint;
property AudioFormat: TAudioFormat;
property AudioInput: integer;
property AudioInputLevel: longint;
property AudioVolume: longint;
property AutoFileName: TAutoFileName;
property AutoFilePrefix: string;
property AutoSize: boolean;
property AutoStartPreview: boolean;
property AutoConnectRelatedPins: boolean;
property OpenDMLFormat: boolean;
property BurstCount: longint;
property BurstInterval: longint;
property BurstMode: boolean;
property BurstType: TFrameCaptureDest;
property BusyCursor: TCursor;
property CaptureAudio: boolean;
property CaptureFileExt: string;
property CaptureFileName: string;
property ColorKeyEnabled: Boolean;
property CompressionMode: TCompressionMode;
property CompressionType: TCompressionType;
property DVNativeInterleavedToAVI: boolean;
property DVRgb219: boolean;
property DVReduceFrameRate: boolean;
property DVUseExternalAudio: boolean ;
property FrameBuffers: longint;
property FrameCaptureZoomSize: boolean;
property FrameGrabberEnabled: boolean
property FrameRate: double;
property FullScreenPreview: boolean;
property JPEGPerformance: TJPEGPerformance;
property JPEGProgressiveDisplay: boolean;
property JPEGQuality: TJPEGQualityRange;
property MaintainImageRatio: boolean;
property NormalCursor: TCursor;
property OverlayEnabled: boolean;
property PlayerAutoStart: boolean;
property PlayerFastSeekMultiplier: longint;
property PlayerFileName: string;
property PlayerFrameRate: double;
property PreallocCapFileEnabled: boolean;
property PreallocCapFileName: string;
property PreallocCapFileSizeInMB: longint;
property PreallocCapFileRecreate: boolean;
property PreviewZoomSize: longint;
property RefreshPreviewOnParamChange: boolean;
property RenderAudio: boolean;
property ShapeOnFrame: TShape;
property ShapeOnFrameEnabled: boolean;
property StoragePath: string;
property StoreDeviceSettingsInRegistry: boolean;
property TextOnFrameAlign: TTextOnFrameAlign;
property TextOnFrameBkColor: TColor;
property TextOnFrameEnabled: boolean;
property TextOnFrameFont: TFont;
property TextOnFrameString: string;
property TextOnFrameTransparent: boolean;
property TextOnFrame_Left: longint;
property TextOnFrame_Right: longint;
property TextOnFrame_Top: longint;
property VCompKeyFrameRate: longint;
property VCompQuality: double;
property VideoCompressor: longint;
property VideoDevice: longint;
property VideoSize: longint;
property VideoSubType: longint;
property Visible: boolean;
event OnCaptureCompleted
event OnCaptureReadyToStart
event OnCaptureStarted
event OnChangeAudioDevice
event OnChangeVideoDevice
event OnColorKeyChange
event OnComponentLoaded
event OnCopyPreallocDataCompleted
event OnCopyPreallocDataStarted
event OnCreatePreallocFileCompleted
event OnCreatePreallocFileStarted
event OnDeviceArrival
event OnDeviceLost
event OnDeviceRemoval
event OnDiskFull
event OnDrawOverFrame
event OnErrorLog
event OnFrameCaptureCompleted
event OnFrameProgress
event OnFullScreenKeyPress
event OnNoVideoDevices
event OnPlayerEndOfStream
event OnPlayerFileNotFound
event OnPlayerStarted
event OnPreviewStarted
event OnRecompressCompleted
event OnRecompressStarted
event OnResizeVideo
ANALOG VIDEO DECODER functions
TAudioFormat
TAutoFileName
TCompressionMode
TCurrentState
TDialog
TFrameCaptureDest
TVideoQuality
CleanTVideoGrabberRegistryOnExit: boolean;
CodecsDisabledFromIDE: boolean;
RegKeyId: string;
RegistryUpdateErrorMsg: string;
VfwDriversEnabled: boolean;
1. If a previous package of TVideoGrabber is already installed, remove it first:
- Components | Install Packages
- Click on "DataStead TVideoGrabber"
- Click "Remove"
- Click "Yes"
- Click "Ok".
- search for "TVidGrab.*" and "VidGrab*.*" files in your
Borland directories and delete them, to be certain that old units will not
remain in the Borland's search paths.
2. Install the current package:
- Unzip the archive in a folder of your choice (e.g. c:\vidgrab). Be sure to unzip the full directory structure (with WinZip check "folders names" ).
- according to your version of Delphi/C++Builder, copy all the Delphi\*.* or CBuilder\*.* files
to your \Borland\Delphi\Imports or \Borland\CBuilder\Imports directory,
- Run Delphi or C++Builder,
- Select Component | Install packages,
- Press the "Add" button,
- Locate the TVidGrab.bpl file in the Imports directory and select it,
- Select Open
- Select Ok
- Check the ActiveX tab in the right of the component palette. The TVideoGrabber object should have been added.
Note about C++Builder:
Go to Project | Options | Packages and uncheck "Build with runtime
packages", or keep it checked but remove "TVidGrab" at the end of the
package list, otherwise you will get a "TVidGrab.bpi file not
found at build time.
OVERVIEW OF THE MAJOR METHODS, PROPERTIES
AND EVENTS, BY CATEGORY
Notes:
- most of the preview properties are used during the AVI capture
- the Frame Capture methods and properties can be used during Preview as well as
AVI capture
General
procedure StartPreview;
procedure StopPreview;
property AutoStartPreview; boolean;property Visible: boolean;
property RefreshPreviewOnParamChange: boolean;
property OnFrameProgress (Sender: TObject; FrameInfo: TFrameInfo);
property OnPreviewStarted (Sender: TObject);
Overlay
property OverlayEnabled: boolean;
property IsOverlayAvailable: boolean; (device dependant)Window Size
property VideoHeight: longint;
property VideoWidth: longint;property PreviewZoomSize: longint;
property AutoSize: boolean;
property MaintainImageRatio: boolean;
property FullScreenPreview: boolean;
property OnFullScreenKeyPress (Sender: TObject; var Key: Char);property OnResizeVideo (Sender: TObject; FVideoWidth, FVideoHeight: longint);
property ImageRatio: double;
General
procedure StartCapture;
procedure StopCapture;property CaptureAudio: boolean;
property OnCaptureCompleted (Sender: TObject; FileName: string; Succeeded: boolean);
property OnFrameProgress (Sender: TObject; FrameInfo: TFrameInfo);
property OnDiskFull (Sender: TObject);property FrameBuffers: longint;
AVI file name
property Last_AVICapture_FileName: string;
property StoragePath: string;property AutoFileName: TAutoFileName;
property AutoFilePrefix: string;property CaptureFileExt: string;
property CaptureFileName: string;AVI compression
property CompressionMode: TCompressionMode;
property CompressionType: TCompressionType;property VideoCompressor: longint;
property VideoCompressors: string;
property VideoCompressorsCount: longint;property AudioCompressor: longint;
property AudioCompressors: string;
property AudioCompressorsCount: longint;procedure ShowDialog (dlg_Compressor);
property OnRecompressCompleted (Sender: TObject; Succeeded: boolean);
property OnRecompressStarted (Sender: TObject);Preallocated huge file
property PreallocCapFileEnabled: boolean;
property PreallocCapFileName: string;
property PreallocCapFileSizeInMB: longint;
property PreallocCapFileRecreate: boolean;property OnCopyPreallocDataCompleted (Sender: TObject; Succeeded: boolean);
property OnCopyPreallocDataStarted (Sender: TObject);
property OnCreatePreallocFileCompleted (Sender: TObject; Succeeded: boolean);
property OnCreatePreallocFileStarted (Sender: TObject);
General
property FrameGrabberEnabled: boolean; (must be enabled)
property FrameCaptureZoomSize: boolean;property StoragePath: string;
one-shot frame capture
function CaptureFrameTo
property OnFrameCaptureCompleted (Sender: TObject; const FrameData: TFrameData; DestType: TFrameCaptureDest; FileName: string; Success: boolean);
property Last_CaptureFrameTo_FileName: string;automated frame capture
property BurstCount: longint;
property BurstInterval: longint;
property BurstMode: boolean;
property BurstType: TFrameCaptureDest;property OnFrameCaptureCompleted (Sender: TObject; const FrameData: TFrameData; DestType: TFrameCaptureDest; FileName: string; Success: boolean);
property Last_BurstFrameCapture_FileName: string;
Auto-generated file names (AVI capture and frame capture)
General
property AutoFileName: TAutoFileName;
property AutoFilePrefix: string;
DV (Digital Video)
General
function SendVCRCommand
property IsDigitalVideoIn: boolean;
property DVRgb219: boolean;
property DVReduceFrameRate: boolean;
property DVNativeInterleavedToAVI: boolean;
property DVUseExternalAudio: boolean ;Time code
property IsTimeCodeReaderAvailable: boolean;
property OnFrameProgress (Sender: TObject; FrameInfo: TFrameInfo); (time code returned within the FrameInfo record. See OnFrameProgress.
TVideoGrabber keeps and restores the current values for each device if StoreDeviceSettingsInRegistry is enabled.
The video device settings and properties noted by an asterisk (*) are device-dependant. So, the values change when the video device change. The best location to retrieve the new values for the current video device is from the OnChangeVideoDevice event.
General
property VideoDevice: longint;
property VideoDevices: string;
property VideoDevicesCount: longint;* property FrameRate: double;
property CurrentFrameRate: double;procedure ShowDialog (dlg_Device);
procedure ShowDialog (dlg_StreamConfig);property StoreDeviceSettingsInRegistry: boolean;
event OnChangeVideoDevice (Sender: TObject);
event OnNoVideoDevices (Sender: TObject);
event OnDeviceArrival (Sender: TObject);
event OnDeviceLost (Sender: TObject);
event OnDeviceRemoval (Sender: TObject);Crossbar (Tuner, S-Video, Composite, etc...)
procedure ShowDialog (dlg_VideoCrossbar);
* property VideoCrossbarInput: longint;
* property VideoCrossbarInputs: string;
* property VideoCrossbarInputsCount: longint;
* property IsVideoCrossbarAvailable: boolean;Frame size (320x240, 640x480, etc...)
* property VideoSize: longint;
* property VideoSizes: string;Media subtypes (YUV2, I420, RGB24, RGB555, etc...)
* property VideoSubType: longint;
* property VideoSubTypes: string;Analog video standard (NTSC, PAL, etc...)
* property AnalogVideoStandard: longint;
* property AnalogVideoStandards: string;
* property IsAnalogVideoDecoderAvailable: boolean;TV
procedure ShowDialog (dlg_TVTuner);
function TVPutChannel ...
* function TVGetChannel ...
* property IsTVTunerAvailable: boolean;
General
event OnChangeAudioDevice
property AudioDevice: longint;
property AudioDevices: string;
property AudioDevicesCount: longint;property RenderAudio: boolean;
property CaptureAudio: boolean;property AudioFormat: TAudioFormat;
property AudioVolume: longint;Audio input
property AudioInputs: string;
property AudioInputsCount: longint;
property AudioInput: integer;
property AudioInputLevel: longint;
General
property PlayerFileName: string;
procedure RunPlayer
procedure RunPlayerBackwards
procedure PausePlayer
procedure StopPlayer
procedure OpenPlayer
procedure ClosePlayer
property PlayerFrameRate: double;procedure FastForwardsPlayer
procedure RewindsPlayer
property PlayerAutoStart: boolean;event OnPlayerEndOfStream (Sender: TObject);
event OnPlayerFileNotFound (Sender: TObject; FileName: string);
event OnFrameProgress (Sender: TObject; FrameInfo: TFrameInfo);
event OnPlayerStarted (Sender: TObject);Information
property PlayerDuration: int64;
property PlayerFrameCount: int64;
property PlayerFramePosition: int64;
property PlayerFrameRate: double;
property PlayerTimePosition: int64;
text on frame
property TextOnFrameAlign: TTextOnFrameAlign;
property TextOnFrameBkColor: TColor;
property TextOnFrameEnabled: boolean;
property TextOnFrameFont: TFont;
property TextOnFramestring: string;
property TextOnFrameTransparent: boolean;
property TextOnFrame_Left: longint;
property TextOnFrame_Right: longint;
property TextOnFrame_Top: longintshape on frame
property ShapeOnFrame: TShape;
property ShapeOnFrameEnabled: boolean;custom drawing
event OnDrawOverFrame (Sender: TObject; FrameInfo: TFrameInfo; Dc: HDC);
property ColorKeyEnabled: Boolean;
procedure SetColorKeys (LowestRGBColorValue: TColor; HighestRGBColorValue: TColor);
event OnColorKeyChange (Sender: TObject; ColorKey: TColor) of object;
TThirdPartyFilterList enumeration
function ThirdPartyFilter_AddToList
function ThirdPartyFilter_ClearList
function ThirdPartyFilter_Enable
function ThirdPartyFilter_GetInterface
function ThirdPartyFilter_RemoveFromList
function ThirdPartyFilter_ShowDialog
event OnErrorLog (Sender: TObject; ErrorCode: longint; ErrorMsg: string);
property IsDirectX8OrHigherInstalled: boolean;
HOW DOES IT WORK
Video preview
- the preview is started by StartPreview and stopped by StopPreview.
The preview is done by default in a window derived from a TPanel. The borders can be disabled by setting BorderStyle to BsNone, and by setting BevelInner and BevelOuter to bvNone.
It is possible to attach/detach the video window with AttachVideoWindow and DetachVideoWindow.
The preview can be switched to full screen mode by enabling FullScreenPreview.
- during the preview, each frame is reported by the OnFrameProgress event.
To start the preview automatically at run time, enable the AutoStartPreview property or call StartPreview from the OnComponentLoaded event.
Video capture
- the AVI capture is started by StartCapture and stopped by StopCapture.
- during the AVI capture, each frame is reported by the OnFrameProgress event.
You are notified of the end of the AVI capture by the OnCaptureCompleted event.
Frame capture:
The frame capture is enabled by FrameGrabberEnabled.
Whatever you are in preview mode, AVI capture mode or playback mode, TVideoGrabber can capture frames one by one (snapshot mode) using CaptureFrameTo, or automatically using BurstMode, BurstType, BurstCount and BurstInterval.
The MainDemo project shows how to capture frames one by one or in burst mode. The QuickStartDemo project included in the package shows how to capture continuously all the frames, returns them as TBitmap and display them in a contiguous TImage component.
In all cases the frames captured are returned by the OnFrameCaptureCompleted
event.
They can be returned as memory TBitmap or written directly to disk as BMP files or a JPEG
files, according to the TFrameCaptureDest
parameter.
In "one shot mode", it is passed as "Dest" parameter when calling CaptureFrameTo,
In burst mode, it is passed as "BurstType"
property.
For
BMP or JPEG files:
- in one shot mode using CaptureFrameTo, you can
pass the file name to assign to the captured frame,
- in burst mode the file name is generated automatically according to the StoragePath,
AutoFileName and AutoFilePrefix
properties.
To be able to capture frames without previewing the video, simply disable the Visible property, because stopping the preview stream using StopPreview will stop the frame grabber as well.
Note: the component can be used without Form and without Parent. Look at the NonVisible demo project included in the package.
Format of the capture to frames and AVI files according to the TVideoGrabber's settings:
|
frame grabber ENABLED | frame grabber DISABLED | ||
any video source | video source is NOT DV | DV video source | ||
any video size | any video size | default video size | NOT default video size | |
AVI capture (without video compressor): | DIB 16, 24 or 32 bits, according to the current display color resolution |
format selected in the video subtypes list |
format selected in the video
subtypes list (usually dvsd) |
DIB |
Single frame capture: | DIB 16, 24 or 32 bits according to the current display color resolution |
n/a | n/a | n/a |
Avoiding dropped frames:
To reduce the dropped frames rate, act on one or more of the following parameters:
- disable the frame grabber (FrameGrabberEnabled)
- disable the color key used for window transparency (ColorKeyEnabled)
- try another video subtype (RGB555, RGB24, YUY2, etc...) and / or another screen display color resolution (16, 24 or 32 bits)
- reduce the frame rate, if possible
- reduce the video size
- check that FrameBuffers is greater than 1
- be careful not to save the AVI to a slow drive (mapped network drive, etc...).
Writing text over frames
To write text over frames:
- set the TextOnFrameString property with
the text string to write. Some variables names are accepted. See TextOnFrameString
for more information,
Look also at the MainDemo project to get sample code.
- choose the font size and color using the TextOnFrameFont property,
- if you want the text to be transparent, enable the TextOnFrameTransparent property, otherwise set the TextOnFrameBkColor with a background color,
- choose the alignment of the text using the TextOnFrameAlign property. See TextOnFrameAlign for more information,
- position the text over the frame using TextOnFrame_Left,
TextOnFrame_Right and TextOnFrame_Top
properties.
If you want the text to be aligned to the right and/or bottom of the
video, use the VideoWidth and VideoHeight
properties.
- enable the TextOnFrameEnabled property to
get the text displayed over frames.
Drawing shapes over frames
TVideoGrabber is able do draw geometrical shapes over frames (rectangle, square, circle, ...). If both text and shape are drawn on the same area, the text is written over the shape.
To avoid defining redundant properties, TVideoGrabber uses an external TShape VCL component to define the shape properties.
So, you have to create this TShape component, define its properties and assign it to the TVideoGrabber's ShapeOnFrame property. The TShape component can be took on the component palette and placed on a form, or dynamically created at runtime.
TShape component placed on a form at design time:
- put a TShape component anywhere on your form (this component will not be visible at runtime).
- assign the TShape component to the ShapeOnFrame property,
- define the shape properties of the component (color, background, aspect...). You can also define the Width and Height, but DO NOT DEFINE the Left and Top properties. Let it at the place where you put it on the form.
- at runtime, define the Left and Top properties, and if necessary the Width and Height.
These 4 properties are used by TVideoGrabber to position and size the shape over the video.- to draw the shape over the frame enable the ShapeOnFrameEnabled property.
TShape component dynamically created at runtime:
Here is some sample code that draws a stripped circle over frames:
procedure TForm1.Button1Click(Sender: TObject);
var
VideoShape: TShape;
begin
VideoShape := TShape.Create (Self);
VideoShape.Left := 10;
VideoShape.Top := 10;
VideoShape.Width := 140;
VideoShape.Height := 100;
VideoShape.Brush.Color := clAqua;
VideoShape.Brush.Style := bsBDiagonal;
VideoShape.Pen.Style := psClear;
VideoShape.Shape := stCircle;
VideoGrabber1.ShapeOnFrame := VideoShape;
VideoGrabber1.ShapeOnFrameEnabled := CheckBox11.Checked;
end;
audio/video compression:
The codecs returned by TVideoGrabber are those available on the current platform.
TVideoGrabber automatically saves and retrieves the current settings of each codec. The current states are saved in the RegKeyId registry key string that you can change to the key name of your choice.
For the best capture quality, we recommend to use the Microsoft's MPEG-4 codec. The DivX codec gives similar results, but it is not free for commercial use.
The Microsoft's MPEG-4 codec, is available from http://www.microsoft.com
-> Downloads | Download Center | Windows Media Player Codecs.
DivX codec is available for download at http://www.divx.com/download/index.php.
Codecs can be applied "on the fly", while capturing, or after
capture according to the CompressionMode
property.
- of course, the "on the fly" method requires CPU, but less disk
access because the file to write is smaller.
- the "after capture" methods recompress the file after capture, so it
creates big uncompressed files before recompressing. Capture and/or preview are
not available during recompression.
Video and audio codecs can be applied respectively to the video stream and/or the audio stream according to the CompressionType property.
If you do not use video compression, the capture will require a high disk availability because the data flow is very important. In this case prefer NTFS partitions and avoid having other software requiring disk access (e.g. disk backup) during the AVI capture, otherwise you could get dropped frames.
Note: some third-party codecs (like Voxware audio codecs) have internal bugs that cause Delphi to pause on unwanted breakpoints when running a project from the IDE (no problem out of the IDE). Although it is just necessary to press F9 several times to go on, if you are worried by these unwanted breakpoints, you can temporarily disable the codecs from the IDE using the global variable CodecsDisabledFromIDE.
Interactive versus programmatically use:
TVideoGrabber has been designed to be used interactively as well as programmatically.
By default, changing the TVideoGrabber settings while previewing automatically restart the preview if RefreshPreviewOnParamChange is enabled, allowing to preview the changes in real time. However, this behavior does not apply to the AVI capture.
To programmatically preset several parameters in preview mode without restarting preview each time a parameter is set, simply disable RefreshPreviewOnParamChange. Then, after all the parameters have been set, call StartPreview to restart the preview using the new parameters.
Another way is to stop the graph using StopPreview or StopCapture, set all the parameters and then restart the preview using StartPreview or StartCapture.
Note: no parameter changes are applied during AVI capture. You must stop the capture first, using StopCapture, and then restart the capture using StartCapture for the new settings to be effective.
Device-dependent parameters:
The following parameters are device-dependent. For this reason, and to avoid having to handle the complexity of saving them, TVideoGrabber is able to save them automatically for each video device separately if StoreDeviceSettingsInRegistry is enabled.
The device dependent parameters are changed by TVideoGrabber each time another device is selected by assigning the VideoDevice property. When the new parameters have been reloaded by TVideoGrabber, the OnChangeVideoDevice event occurs. Use this event to refresh your settings if necessary (look at the MainDemo project for sample code).
The allowed values for the current device are returned as a list of strings. The current value is selected by assigning the index of the string in the list to the corresponding index property.
Parameters whose values change from a platform to the other:
VideoDevices list -> VideoDevice
index
AudioDevices list -> AudioDevice
index
VideoCompressors list -> VideoCompressor
index
AudioCompressors list -> AudioCompressor
index
Parameters whose values change from a device to the other:
VideoSizes list -> VideoSize
index
VideoSubTypes list -> VideoSubType
index
Note:
- these lists are strings that can be directly assigned to list-based
components. E.G.:
ComboBox1.Items.Text := VideoGrabber1.VideoSizes;
- these lists can be assigned to lists to get the number of available items. E.g.:
var
TheList: TStringList;
ItemCount: integer;
begin
TheList := TStringList.Create;
TheList.Text := VideoGrabber1.VideoSizes;
ItemNumber := TheList.count;
TheList.Free;
end;
Component dynamically created at runtime
To create the component:
- call the create method of the component,
- set its Parent property,
- set all the required properties and events,
- call the DynamicallyCreated method
To destroy the component:
- call its Free method.
See the NonVisible project demo and the DynamicallyCreated method for sample code.
The TVideoGrabber's embedded player allows to playback AVI or MPEG clips at their nominal rate, slower or faster. It can be used separately to play any clip.
Open a clip with OpenPlayer, run it with RunPlayer, pause it with PausePlayer and close it with ClosePlayer.
Third-party filters:
TVideoGrabber allows you to use third-party DirectShow filters that you can get from other companies. To use a third-party filter, proceed as follows:- register it first on the
platform
where your app will be run, either manually from the command line with regsvr32,
either programmatically with the RegisterComServer (ComObj unit),
- choose the insertion point of the filter (see 2. below),
- obtain the CLSID (ActiveX identifier) of the filter (see 3. below),
- declare the filter in TVideoGrabber before starting preview, capture or
playback (see 3. below).
1. install and register the third-party filter
1a. third-party filter registered from the command line
E.g. let's say you want to use the DSCALER deinterlacer. The filter file is deinterlace.ax. Proceed as following:
- copy the deinterlace.ax file in your windows\system32 or
winnt\system32 directory
- click on "Start", "Execute", then enter the following
command line: regsvr32 c:\windows\system32\deinterlace.ax
1b. third-party filter registered programmatically
E.g. let's say you want to use the DSCALER deinterlacer. The filter file is deinterlace.ax. Proceed as following:
- add the unit ComObj to the "uses" statement of
your unit,
- copy the deinterlace.ax file in your windows\system32 or winnt\system32
directory (e.g. using CopyFile),
- call RegisterComServer ('c:\windows\system32\deinterlace.ax');
2. choose the location point of
the filter
within the preview, capture or playback graph. You can determine the location according to the
TThirdPartyFilterList
enumeration. The location points are explained in the ThirdPartyFilter_AddToList
function.
3. call ThirdPartyFilter_AddToList to add the filter to the list. E.g.:
procedure TForm1.Button1Click (Sender: TObject);
const
CLSID_DSCALER: TGUID = (D1:$463D645D; D2:$48F7; D3:$11D4; D4:($84,$64,$00,$08,$C7,$82,$A2,$57));
var
ThirdPartyFilterIndex: integer;
begin
ThirdPartyFilterIndex := VideoGrabber1.ThirdPartyFilter_AddToList(tpf_VideoSource,
CLSID_DSCALER, 'DSCALER deinterlacer', True, True);
if ThirdPartyFilterIndex <> -1 then begin
...
end;
end;
So, you have to know the CLSID of the filter to pass it to the function. If you do not know the CLSID, you can retrieve it in the registry after it has been registered (see 1. above). To retrieve the CLSID, proceed as following:
- run regedit
- at the top of the tree, click on "edit", "search", and enter the file name of the filter (e.g. deinterlace.ax). Start the search. Locate the HKEY_CLASSES_ROOT\CLSID\{...} and create a CLSID const as show in the sample code above using the hex values of the key name.
4. set the filter properties interactively using ThirdPartyFilter_ShowDialog or programmatically using ThirdPartyFilter_GetInterface. It is possible that some filters don't show the dialog if a graph is not running (preview, capture or playback).
5. the filter(s) will be automatically used in the next preview / AVI capture / AVI playback until ThirdPartyFilter_ClearList is called or the filter is disabled with ThirdPartyFilter_Enable.
Transparent windows can be used usually when the video capture device offers an overlay. Simply enable the ColorKeyEnabled
property. If the color key can be set on the overlay, the OnColorKeyChange event returns this color key, that you can use to make a window or control transparent (sample code shown in the MainDemo project).You can change the default color keys with SetColorKeys.
Note: even if no overlay is available on the current video capture device, the transparency can be available in certain cases, according to your OS and/or video display.
ProVideo multi-ports capture card SDK:
The TVideoGrabber's package includes a wrapper that gives you access to the PV150 SDK functions of the PV150 ProVideo multi-ports capture card.
The wrapper is the pv150.dll file included in the TVideoGrabber's package. It wraps the SDK functions of the PVProp150.dll (included in the ProVideo SDK) and gives you access to the ProVideo SDK functions from Delphi or C++Builder.
To use it you must copy the TVideoGrabber's pv150.dll file and the ProVideo SDK's PVProp150.dll files to your WINNT\SYSTEM32 or WINDOWS\SYSTEM32 directory.
The functions exposed by TVideoGrabber are:
function PV150_InitDLL: Boolean;
function PV150_UnInitDLL: Boolean;
function PV150_GetProtectID (iDevNum: longint; byData: pByte): Boolean;
function PV150_SetBrightness(iDevNum: longint; VideoSource: longint; wValue: word): boolean;
function PV150_SetSaturation(iDevNum: longint; VideoSource: longint; wValue: word): boolean;
function PV150_SetContrast(iDevNum: longint; VideoSource: longint; wValue: word): boolean;
function PV150_SetHue(iDevNum: longint; VideoSource: longint; wValue: word): boolean;
function PV150_SetVideoSource(iDevNum: longint; wValue: word): boolean;
function PV150_GetVideoSignal(iDevNum: longint; bHasSignal: pBoolean): boolean;
Note: you must call PV150_InitDLL before using the other functions, and call PV150_UnInitDLL after using them.
Here is some sample code about how to use these functions to switch from a "master" video input to its "daughter" video input (on the same device).
if PV150_InitDLL then begin
PV150_SetVideoSource(1, 4);
sleep(20);
PV150_SetVideoSource(1, 0);
PV150_UnInitDLL;
end;
Note: these functions are only wrappers to the ProVideo functions, so no support is provided about how to use them or about their behavior. Look at the ProVideo's P150 SDK or contact the ProVideo support for more information about these functions.
procedure AttachVideoWindow;
Put the video in its normal "child" position
on the component. Useful only if the window has been detached using DetachVideoWindow.
function AudioCompressorName (index:
longintfunction AudioDeviceName (index:
longint
Retrieves the name of the audio input device whose range is index in the
AudioDevices list (range = 0..AudioDevicesCount-1). See AudioDevice.
function CaptureFrameTo
(Dest: TFrameCaptureDest;
Captures the current frame to a memory
Bitmap, a BMP file or a JPEG file, according to the Dest
parameter.
The captured frame is returned by the
OnFrameCaptureCompleted
event.
To capture a frame to a TBitmap:
- call CaptureFrameTo (fc_TBitmap);
- the frame is returned by the OnFrameCaptureCompleted
event.
Dest parameter values:
Dest = fc_TBitmap:
The frame capture will return only a TBitmap. In this case the FileName parameter is ignored.
Dest = fc_BmpFile:
The frame capture creates a BMP file. See the notes below.
Dest = fc_JpegFile:
same for BMP files above, but creates a JPEG file. See the notes below.For Dest = fc_BmpFile or Dest = fc_JpegFile :
1. if FileName is left blank, a file name is automatically generated in the StoragePath directory according to the AutoFileName and AutoFilePrefix properties. The file name generated is returned for each frame captured by the OnFrameCaptureCompleted event.
2. the memory TBitmap is always returned by OnFrameCaptureCompleted, even if the Dest parameter is fc_BmpFile or fc_JpegFile. The reason is that you can need to save the file as BMP or JPEG and display it, e.g. in a TImage. The bitmap returned avoids you to have to read the BMP or JPEG file to display the bitmap.CaptureFrameTo and BurstMode:
- if BurstMode is disabled: calling CaptureFrameTo captures a single frame,
- if BurstMode is enabled: calling CaptureFrameTo captures a BurstCount number of frames.
. if BurstInterval <> 0, frames are captured each BurstInterval frames, until BurstCount is reached,
. if BurstCount = 0, frames are captured indefinitely until BurstMode is enabled or the end of the video stream is reached.Note: the FileName is passed as var because it returns a file name automatically generated by TVideoGrabber if FileName is left blank. E.g.:
var
FilePath: string;
begin
FilePath := '';
VideoGrabber1.CaptureFrameTo (fc_JpegFile, FilePath);
ShowMessage ('file name assigned by TVideoGrabber: ' + FilePath);
end;
procedure ClosePlayer;
Closes the current clip, if opened.
function CrossbarCanConnectInput (Crossbar:
TCrossbarSelector; InputIndex, OutputIndex:
longint): boolean;
Returns true if the InputIndex crossbar input can be connected to the OutputIndex
crossbar output.
function CrossbarConnectInput (Crossbar:
TCrossbarSelector; InputIndex, OutputIndex:
longint): boolean;
Tries to connect the InputIndex crossbar input to the OutputIndex
crossbar output and returns true on success.
function CrossbarGetPinCounts (Crossbar:
TCrossbarSelector; var InputCount, OutputCount:
longint): boolean;
Gets the number of inputs and outputs of the crossbar. Returns true on success.
function CrossbarGetInputConnected
(Crossbar:
TCrossbarSelector; OutputIndex: longint; var
InputIndex: longint): boolean;
Retrieves the index of the crossbar input connected to the OutputIndex
crossbar output. Returns true on success.
procedure DetachVideoWindow (Left, Top, Width, Height:
longint);
Detaches the video window from the component and put it
on the top of the screen at the specified position and size. Call AttachVideoWindow
to send back the video window to its child position on the component. Then, you
can access directly to the window handle with the VideoWindowHandle
property.
procedure
DynamicallyCreated;
If you dynamically create the component at runtime,
call this procedure after all the parameters have been set. E.g.:
if not assigned (VGrab) then begin
VGrab := TVideoGrabber.Create (Self);
VGrab.Parent := Self;
VGrab.Visible := False;
VGrab.OnChangeVideoDevice := ChangeVideoDevice;
VGrab.OnFrameCaptureCompleted := OnFrameCaptureCompleted;
VGrab.VideoDevice := 0;
VGrab.DynamicallyCreated;
end;
procedure FastForwardsPlayer;
Scans quickly forwards through the
current clip. The nominal speed is multiplied by PlayerFastSeekMultiplier.
function GetVideoCompressionSettings (var
DataRate, KeyFrameRate, PFramesPerKeyFrame, WindowSize: longint; var Quality:
double; var
CanQuality, CanCrunch, CanKeyFrame, CanBFrame, CanWindow: boolean;
Retrieves the video compression settings supported by
certain codecs. Returns true if the current video compressor supports this
interface.
DataRate: retrieves the output data rate.
KeyFrameRate: The key-frame rate is the number of frames per key frame. For example, if the rate is 15, then a key frame occurs every 15 frames.
PFramesPerKeyFrame: P frames are used only in MPEG compression. E.g. let's say a key frame occurs once every 10 frames, and there are three P frames per key frame. The P frames will be spaced evenly between the key frames. The remaining six frames are bi-directional (B) frames.
WindowSize: retrieves the number of frames over which the compressor will maintain the average data rate. E.g. if a data rate of 100K/sec and a frame rate of 10 frames per second, if the window size is 1, then every frame will be 10K or less. If the window size is 5, then every five consecutive frames will average 10K per frame, but individual frames may exceed this size.
Quality: The quality is expressed as a value between 0.0 and 1.0, where 1.0 indicates the best quality and 0.0 indicates the worst quality. If the value is negative, the filter will use the default quality.CanCrunch: the compressor can compress video to a specified data rate (see DataRate above).
CanKeyFrame: the compressor supports the KeyFrame property above.
CanBFrame: the compressor supports the PFramesPerKeyFrame property above.
CanWindow: the compressor supports WindowSize property above.
CanQuality: the compressor supports Quality property above.
function GetVideoQuality (Setting:
TVideoQuality):
longint;
Retrieves the current value of the TVideoQuality
setting.
function IsCrossbarAvailable (Crossbar:
TCrossbarSelector):
boolean;
Retrieves the availability of the audio or video crossbar.
function IsDialogAvailable
(Dialog: TDialog):
boolean;
retrieves true if the Dialog is available for the
current video device.
See also: ShowDialog.
function IsVideoQualitySettingAvailable (Setting:
TVideoQuality) :
boolean;
retrieves true if the setting passed as parameter is available for the
current video device.
procedure OpenPlayer;
Opens the clip specified by the PlayerFileName
property.
procedure PauseCapture;
Pauses the AVI capture started by StartCapture. The
AVI capture can be resumed by ResumeCapture.
Note: this feature is not available if capturing both audio and video.
procedure
PausePlayer;
Pauses the opened clip, if currently playing.
procedure ResumeCapture;
Resumes the AVI capture initially started by StartCapture
and then paused by PauseCapture.
Note: this feature is not available if capturing both audio and video.
procedure RewindsPlayer;
Scans quickly backwards through the
current clip. The nominal speed is multiplied by PlayerFastSeekMultiplier.
procedure RunPlayer;
Plays a clip, opened by OpenPlayer, or restarts a clip
paused by PausePlayer.
procedure RunPlayerBackwards;
Same as RunPlayer above, but plays the clip backwards.
procedure SetColorKeys (LowestRGBColorValue: TColor; HighestRGBColorValue: TColor);
Change the default color keys used for transparency
and related effects. Usually the same value is assigned to both lowest and
highest value.
Use with ColorKeyEnabled and OnColorKeyChange.
See the MainDemo project for sample code.
function SendVCRCommand
(VCRCommand: TVCRCommand): boolean;
Sends the specified transport command to the DV camcorder. Returns true on success.
Most DV camcorders accept transport command without additional requirements.
Non-DV VCR or camcorders can accept transport commands, however, to control an external VCR, certain hardware requirements are recommended. VCRs with an RS-422 serial interface require a special serial port card or an external RS-232-to-RS-422 adapter. In addition, for best performance, your computer should have a serial port card built with a 16550 high-performance UART to sustain higher baud rates, such as 38.4 baud.
function SetVideoCompressionDefaults:
boolean;
Sets the video compression settings supported by
certain codecs to their default values. See GetVideoCompressionSettings
for more information.
function SetVideoCompressionSettings
(DataRate, KeyFrameRate, PFramesPerKeyFrame, WindowSize: longint; Quality:
double): boolean;
Sets the video compression settings supported by
certain codecs. See GetVideoCompressionSettings
for more information.
function SetVideoQuality (Setting:
TVideoQuality; Value: longint) :
boolean;
Sets the TVideoQuality setting to a new
value.
procedure ShowDialog
(Dialog: TDialog);
displays the TDialog dialog, if available for the current
video device. Use IsDialogAvailable to
test the dialog availability for the current device.
The TDialog dialogs values are:
dlg_Device
general device properties.
dlg_Compressor
video compressor dialog, if any.
dlg_StreamConfig
stream config dialog. This dialogs allows usually to change the video size, video subtype and frame rate.
Note: in certain cases it is not possible to change more that 1 parameter at the same time.
dlg_VfwFormat
format dialog for old vfw drivers,
dlg_vfwSource
source dialog for old vfw drivers,
dlg_vfwDisplay
display dialog for old vfw drivers,
dlg_VideoCrossbar
video crossbar dialog. Allows to switch input and output pins, if any.
dlg_AudioCrossbar
audio crossbar dialog. Allows to switch input and output pins, if any.
dlg_TVTuner
tv tuner dialog, if any.
dlg_TVAudio
tv audio dialog, if any.
dlg_Audio
audio device dialog, if any.
procedure
ShutdownGraph;
Ends immediately the current graph (previewing, capturing or playing). The frame grabber is disabled. Using it should be avoided, it is better
to cleanly stop the current graph with StopCapture, StopPreview
or ClosePlayer.
procedure StartCapture;
Starts the AVI capture to the CaptureFileName file.
If CaptureFileName is left blank, a filename is automatically generated according to
the AutoFileName property. The file is
created in the
StoragePath directory.
procedure
StartPreview;
Starts or restarts the preview.
Use it to start the preview or to restart the preview. It is not necessary to
call StopPreview before to restart the preview.
procedure StopCapture;
Stops the AVI capture started by StartCapture.
procedure StopPlayer
;
Pauses the opened clip, if it is currently playing.
procedure
StopPreview;
Stops the current preview.
Note: the frame capture is not available when the preview is stopped. To
disable the preview but keep the frame capture alive, simply set the Visible
property to false.
function ThirdPartyFilter_AddToList (Location: TThirdPartyFilterList; GUID: TGUID; Name: string; Enable: boolean; SaveFilterState: boolean): longint;
Adds a third-party filter into the "Location" list. The filters will be inserted in the graph in the order they were added to the list. A filter can be inserted only 1 TIME in the same list.
The filter must have been registered on the current platform using regsvr32. See the Third-party filters tips for more information about how to use third-party filters.
Location: location where the filter will be inserted in the graph, according to the TThirdPartyFilterList enumeration:
- tpf_VideoSource: filter inserted before the video capture/preview switching, so the effect is applied to both video preview and capture.
- tpf_VideoPreview: filter inserted on the video preview stream, after the capture/preview switching. The effect is applied only to video preview.
- tpf_VideoCapture: filter inserted on the video capture stream, after the capture/preview switching. The effect is applied only to video capture.- tpf_AudioSource: filter inserted before the audio capture/render switching, so the effect is applied to both audio rendering and capture.
- tpf_AudioRender: filter inserted on the audio render stream, after the capture/render switching. The effect is applied only to audio rendering.
- tpf_AudioCapture: filter inserted on the audio capture stream, after the capture/render switching. The effect is applied only to audio capture.Name: name of the filter, any value accepted. Used mainly by the OnErrorLog event.
Enable: if true, the filter will be inserted in the next preview / capture / playback run.
SaveFilterState: if true, the filter current settings are automatically saved / retrieved from the registry.
RETURN VALUE: the return value is the index of the filter in the Location list. This index is necessary to access to the filter through the other ThirdPartyFilter... functions.
The return value is -1 on failure (e.g. if the filter is already in the list).
function ThirdPartyFilter_ClearList
(Location: TThirdPartyFilterList): boolean;
Clear the Location filter list. Call it to remove
the filters inserted in the list by ThirdPartyFilter_AddToList
in the Location list.
function ThirdPartyFilter_Enable
(Location: TThirdPartyFilterList; Index: longint; Enable: boolean): boolean;
Enables/disables the Index filter for the next
preview / capture / playback run. Avoids to have to remove and reinsert the
filter several times.
function ThirdPartyFilter_GetInterface
(Location: TThirdPartyFilterList; Index: longint; out
IUnkIntf: IUnknown): boolean;
Retrieves the IUnknown interface of the filter. Useful
to access programmatically to the filter settings.
function ThirdPartyFilter_RemoveFromList
(Location: TThirdPartyFilterList; Index: longint): boolean;
Removes the Index filter from the Location
list.
function ThirdPartyFilter_ShowDialog
(Location: TThirdPartyFilterList; Index: longint): boolean;
Displays the filter's dialog, if any.
function VideoCompressorName (index:
integer): string;
Retrieves the name of the video compressor whose range is index in the
VideoCompressors list (range = 0..VideoCompressorsCount-1). See
VideoCompressor.
function VideoDeviceName (index:Retrieves the name of the video input device whose range is index in the VideoDevices list (range = 0..VideoDevicesCount-1). The current index is returned by the VideoDevice property.
Note: a "~" at the end of a WDM device name indicates that this device has been disconnected.
function VideoQualityDefault (Setting: TVideoQuality): Resets the TVideoQuality setting to its default value.function VideoQualityMax
(Setting: TVideoQuality):
longint;
Retrieves the max value of the TVideoQuality
setting.
function VideoQualityMin
(Setting: TVideoQuality):
longint;
Retrieves the min value of the TVideoQuality
setting.
function VideoQualityStep (Setting: TVideoQuality):
longint;
Retrieves
the step size of the TVideoQuality setting. The
step size is the smallest increment by which the property can change.
property AnalogVideoStandards:
string;
Test IsAnalogVideoDecoderAvailable
first to know if the current video device exposes this interface.
List of the analog video standards.
This list can be directly assigned to list-based components. E.g.:
ComboBox1.Items.Text:= AnalogVideoStandards
Select the video standard by assigning its list index to the AnalogVideoStandard
property. E.G.:
VideoGrabber1.AnalogVideoStandard := ComboBox1.ItemIndex;
property
AudioCompressors:
string;
List of the audio
compressors available on the current platform.
This list can be directly assigned to list-based components. E.g.:
ComboBox1.Items.Text:= VideoGrabber1.AudioCompressors;
Select the audio compressor by assigning its list index to the
AudioCompressor
property. E.g.:
VideoGrabber1.AudioCompressor := ComboBox1.ItemIndex;
property
AudioCompressorsCount:
longint
Retrieves the number of audio compressors available on the current
platform.
property AudioDevices:
string;
List of the audio input devices available on the current platform.
This list can be directly assigned to list-based components. E.g.:
ComboBox1.Items.Text := VideoGrabber1.AudioDevices;
Select the device by assigning the list index to the AudioDevice
property. E.g.:
VideoGrabber1.AudioDevice := ComboBox1.ItemIndex;
property AudioDevicesCount:
longint
Retrieves the number of audio input devices available on the current platform.
property AudioFormats:
string;
List of the audio formats available.
This list can be directly assigned to list-based components. E.g.:
ComboBox1.Items.Text :=VideoGrabber1.AudioFormats;
Select the audio format by assigning its list index to the AudioFormat
property. E.g.:
VideoGrabber1.AudioFormat := TAudioFormat (ComboBox1.ItemIndex);
Note: the
audio format is applied to DV only if type 2
capture with PCM audio compression is used.
property AudioInputs:
string;
List of the audio inputs available on the current audio input device.
This list can be directly assigned to list-based components. E.g.:
ComboBox1.Items.Text := VideoGrabber1.AudioInputs;
Select the device by assigning the list index to the AudioInput
property. E.g.:
VideoGrabber1.AudioInput := ComboBox1.ItemIndex;
Note: this list is refreshed each time a new audio device is selected.
You should use it from the OnChangeAudioDevice
event.
property AudioInputsCount:
longint;
Retrieves the number of audio inputs available on the current audio device.
Note: this list is refreshed each time a new audio device is selected. You
should use it from the OnChangeAudioDevice
event.
property AutoConnectRelatedPins:
boolean;
when selecting an input pin, automatically connects related pins, if any.
The related pin is a pin on the same filter, with the same direction; it
typically represents the same physical jack or connector. For example, a video
tuner and an audio tuner might be related pins. The ATI crossbar includes such
related pins.
Disable this property to capture the audio sound from another source than the
source associated by default.
property Busy:
boolean;
Returns true if TVideoGrabber is in an intermediary state
(e.g. when switching from preview mode to capture mode,
when restarting after a parameter changes, etc...)
and cannot execute commands or certain parameter changes immediately).
However, commands and certain parameter changes received by the component when it is in a Busy state are queued and executed as soon as the component becomes available. So, you can send commands without waiting for the component to be back from its busy state.
property CaptureDuration:
double;
Duration of the last captured file since the application started.
property CurrentFrameRate:
Double;
Returns the real frame rate used for preview or
AVI capture. This property is read-only. It differs from the FrameRate
property, which is the desired frame rate.
CurrentFrameRate is particularly useful to know the frame rate of DV sources
(where the frame rate cannot be set by the FrameRate property).
property CurrentState:
TCurrentState;
Returns the state of TVideoGrabber.
cs_Down: the component is stopped.
cs_Preview: the component is previewing, accepting
frame captures.
cs_Capture: the component is capturing video (and
audio if enabled) to an AVI file.
cs_Playback: the component is playing back a video.
cs_Compress: the component is recompressing a video (activated by StopCapture when CompressionMode
was set to cm_CompressAfterCapture).
property DeliveredFrames:
int64;
current number of frames delivered since the StartPreview or StartCapture call.
property DroppedFrames:
longint;
current number of dropped frames since the StartPreview or StartCapture call.
property
ImageRatio:
double;
Returns the ratio between the Width and Height of the video source.
property InFrameProgressEvent:
boolean;
Returns true if the OnFrameProgress
event is currently called.
The purpose of this property is mainly to avoid updating the trackbar position
from its OnChange event when this position is set from the OnFrameProgress
event.
Otherwise, the loop back update of the trackbar position in its OnChange event
produces a "jerky" and "not smooth" motion of the
trackbar.
Look at the MainDemo project for sample code.
property IsAnalogVideoDecoderAvailable:
boolean;
Returns True if the Analog Video Decoder functions are
available for the current video device. If true, the AnalogVideoStandard
and AnalogVideoStandards properties can be
used.
property
IsAnalogVideoIn:
boolean;
Returns true if the current video device is analog video.
property IsAudioCrossbarAvailable:
boolean
returns true if the current video capture device driver exposes an audio
crossbar (WDM drivers only).
property IsDigitalVideoIn: returns true if the current video device format is DV (digital video). See the demo project for DV versus analog video settings.
property IsDirectX8OrHigherInstalled:
boolean;
returns true if DirectX 8 or higher is installed on the
current platform. TVideoGrabber does not work with older versions of DirectX.
property IsVCRCommandAvailable:
boolean;
returns true if the DV device (usually a VCR or a
camcorder) accepts transport commands.
property IsTimeCodeReaderAvailable:
boolean;
returns true is the time code reader is available for the current video
device.
property IsTVTunerAvailable:
boolean;
Returns True if the TV Tuner functions are available for the
current video device.
property IsOverlayAvailable:
boolean;
Returns True if the current video device has a video port (overlay) allowing
fast preview. If available, the overlay can be enabled by the OverlayEnabled
property.
property IsVideoCrossbarAvailable:
boolean
returns true if the current video capture device
driver exposes a video crossbar (WDM drivers only).
property IsVideoQualityAvailable:
boolean;
returns true is the video adjust settings are available for the current
video device.
function IsWDMVideoDriver:
boolean;
returns true if the video capture device driver is a WDM driver
returns false if the video capture device driver is a VFW driver.
property Last_AVICapture_FileName:
string;
name of the last AVI file created by the AVI capture. Particularly useful if the
capture name as been automatically generated by TVideoGrabber.
The best location to use it is from the OnCaptureCompleted
event.
property Last_BurstFrameCapture_FileName:
string;
name of the last BMP or JPEG file created by the frame capture in burst
mode. Always useful because in this mode the BMP or JPEG file name is always
generated automatically.
The best location to use it is from the OnFrameCaptureCompleted
event.
property Last_CaptureFrameTo_FileName:
string;
name of the last BMP or JPEG file created by the frame capture in "one
shot" mode, using CaptureFrameTo.
Particularly useful if the frame file name as been automatically generated by
TVideoGrabber (occurs when CaptureFrameTo is
called without passing a file name).
The best location to use it is from the OnFrameCaptureCompleted
event.
property PlayerDuration: Returns the total length in seconds of a clip currently opened by OpenPlayer (expressed in in 100-nanosecond units, divide it by 10000000 to convert in seconds).
property PlayerFrameCount:
int64;
Returns the total frame count of a clip currently opened by
OpenPlayer.
property PlayerFramePosition: int64;
Sets or retrieves the current frame position of a clip
opened by
OpenPlayer.
property
PlayerFrameRate:
double;
Returns the frame rate of a clip opened by
OpenPlayer.
property PlayerTimePosition: int64;
Sets or retrieves the current time position of a clip
opened by
OpenPlayer (expressed in in 100-nanosecond units,
divide it by 10000000 to convert in seconds).
property
TVTuner: IAMTVTuner
Gives full control on the functions of the
IAMAnalogVideoDecoder interface, the
IAMTVTuner interface, derived from the
IAMTuner interface.
Note: TVTuner is available if the TV card is WDM compliant.
property VideoCompressors:
string;
List of the video
compressors (codecs) available on the current platform.
This list can be directly assigned to list-based components. E.g.:
ComboBox1.Items.Text:= VideoGrabber1.VideoCompressors.
Select the video compressor by assigning its list index to the
VideoCompressor
property. E.g.:
VideoGrabber1.Video
property VideoCompressorsCount:
longint
Retrieves the number of video compressors available on the current platform.
property VideoCrossbarInput:
longint;
sets or retrieves the video input currently in use.
Useful only if IsVideoCrossbarAvailable
is true.
property VideoCrossbarInputs:
string;
List of the video crossbar inputs available for the current video capture
device.
This list depends of the current video device and changes when another video
device is selected.
This list can be directly assigned to list-based components. E.g.:
ComboBox1.Items.Text := VideoGrabber1.VideoCrossbarInputs
Select the video crossbar input by assigning its list index to the
VideoCrossbarInput property above. E.g.:
VideoGrabber1.VideoCrossbarInput:=ComboBox1.ItemIndex
Useful only if IsVideoCrossbarAvailable
is true.
property VideoCrossbarInputsCount:
longint;
Number of video inputs available for the current video device.
Useful only if IsVideoCrossbarAvailable
is true.
property VideoDevices:
List of the video devices available on the current platform.
This list can be directly assigned to list-based components. E.g.:
ComboBox1.Items.Text:= VideoGrabber1.VideoDevices;
Select the video device by assigning its list index to the VideoDevice
property. E.g.:
VideoGrabber1.VideoDevice := ComboBox1.ItemIndex;
Note: a "~" at the end of a WDM device name indicates that this device has been disconnected. The device name can also be obtained by the VideoDeviceName property.
property VideoDevicesCount:
longint
Retrieves the number of video input devices available on the current platform.
property VideoDeviceKsPropertySet:
IKsPropertySet;
Retrieves the interface to the Ks property of the video
capture device.
property VideoDevicePinKsPropertySet:
IKsPropertySet;
Retrieves the interface to the Ks property on the output
pin of the video capture device.
property VideoHeight:
longint;
Returns the height of the video source, in pixels.
property
VideoSizes:
string;
Assign it from the OnChangeVideoDevice event.
List of the video sizes supported by the current video
device.
As this list depends of the current video device, it changes when another video
device is selected.
This list can be directly assigned to list-based components. E.g.:
ComboBox1.Items.Text := VideoGrabber1.VideoSizes;
Select the video size by assigning its list index to the
VideoSize
property. E.g.:
VideoGrabber1.VideoSize := ComboBox1.ItemIndex;
See also: VideoSize
Note: For Digital Video (DV) the VideoSizes list return "dc", "quarter", "half" or "full" according to DV video standard as following:
VideoSizes values | NTSC | PAL |
default | 360 x 240 | 360 x 288 |
dc | 88 x 66 | 88 x 72 |
quarter | 180 x 120 | 180 x 144 |
half | 360 x 240 | 360 x 288 |
full | 720 x 480 | 720 x 576 |
property VideoSizesCount:
longint;
Returns then number of items currently available in the VideoSizes
list.
property
VideoSubTypes:
Assign it from the OnChangeVideoDevice event.
List of the video sub types supported by the current video
device. The video subtype is usually the FOURCC code or the RGBnnn type.
This list depends of the current video device and changes when another video
device is selected.
This list can be directly assigned to list-based components. E.g.:
ComboBox1.Items.Text := VideoGrabber1.VideoSubTypes;
Select the video sub type by assigning its list index to the VideoSubType
property. E.g.:
VideoGrabber1.VideoSubType := ComboBox1.ItemIndex;
property VideoSubtypesCount:
longint;
Returns then number of items currently available in the
VideoSubtypes
list.
property VideoWidth:
longint;
Returns the width of the video source, in pixels.
property VideoWindowHandle:
HWND;
Returns the handle of the current video window, or 0
if the component is inactive. Useful to handle the window out of the component
if it has been detached using DetachVideoWindow.
property AnalogVideoStandard:
longint;
Sets or retrieves the index of the AnalogVideoStandard in the AnalogVideoStandards
list.
Test IsAnalogVideoDecoderAvailable
first to know if the current video device exposes this interface.
property
AudioCompressor:
longint;
Sets or retrieves the index of the active audio compressor in the
AudioCompressors
list. Effective only if CompressionMode is set to
cm_CompressOnTheFly or cm_CompressAfterCapture and
CaptureAudio is enabled.
property AudioDevice:
longint;
Sets or retrieves the index of the active audio device in the AudioDevices
list.
property AudioFormat:
TAudioFormat;
Sets or retrieves the current audio format. The TAudioFormat
enumerated type matches the AudioFormats
list.
Note: the audio format is applied to DV only if type 2 capture with PCM audio compression is used.
property AudioInput:
integer;
Sets or retrieves the index of the audio input (in the
AudioInputs list) selected for the current audio device. This value is audio
device-dependent and is does not correspond to the same input from an audio
device to the other.
Note: because this index depends of the AudioInputs
list, it should be updated each time a new audio device is selected. The best
location to use it is from the OnChangeAudioDevice
event.
property AudioInputLevel:
longint;
Sets or retrieves the record level of the current audio
input (selected by the AudioInput property above). The
range goes from - 10,000 to 0 (-10,000 is silence, full volume is 0).
property AudioVolume:
longint;
Sets or retrieves the audio
volume. The range goes from - 10,000
to 0 (-10,000 is silence, full volume is 0).
property AutoFileName:
TAutoFileName;
fn_Sequential: the file name is based on a
sequential number, starting from 000001.
fn_DateTime: the file name is based on a date/time format, like yymmdd_hhmmss_zzz
(zzz =
milliseconds).
Note about AVI capture file name:
you can choose to force the AVI file name created by the capture stream by setting the CaptureFileName property before calling StartCapture. If CaptureFileName is left blank, a file name is generated automatically and returned by the OnCaptureCompleted event.Note about BMP or JPEG capture file name:
you can choose to force the file name of BMP and JPEG files created by the frame capture by specifying a file name when calling the CaptureFrameTo procedure. If the file name is left blank in CaptureFrameTo, a BMP or JPEG file name is generated automatically and returned by the OnFrameCaptureCompleted event.
property AutoFilePrefix:
string
Sets or retrieves a prefix string placed at the beginning of a capture file name
generated automatically. Especially used to distinguish different
serials of files when AutoFileName is set to fn_Sequential (e.g. when several
TVideoGrabber components are used in the same app and you want to generate
separated serials of files for each component).
property AutoSize:
boolean;
Enables or disables the automatic resizing of the video preview window, when the
video source size changes.
property
AutoStartPreview:
boolean;
If enabled, the preview is automatically started at runtime (enabled
by default).
property OpenDMLFormat:
boolean;
True indicates an AVI 2.0
index format. AVI 2.0 index format allows for increased AVI file size (greater
than 1 GB), hierarchical indexing, incremental growth of files, and minimal disk
seeks.
property BurstCount:
longint
Sets or retrieves the number of frames to capture when BurstMode
will be enabled.
Setting BurstCount to 0 and BurstInterval to 0 will grab ALL THE FRAMES.
property BurstInterval:
longint
Sets or retrieves the number of frames to skip between 2 captured frames. Set
this value to 0 if you do not want to skip frames (E.g. BurstInterval = 20 means
that 1 frame is grabbed every 20 frames).
Note: enable BurstMode to start the automatic frame
capture process.
property
BurstMode:
boolean
Starts/stops the automatic frame capture process. The number of frames captured
depends of the BurstCount and
BurstInterval parameters. The destination of the
captured frame depends of the BurstType parameter.
property
BurstType:
TFrameCaptureDest
Sets or retrieves the destination of captured frames:
fc_TBitmap: the frames will be returned as a
TBitmap by the OnFrameCaptureCompleted
event.
fc_BmpFile, fc_JpegFile: the frames will be stored
in BMP or JPEG files according to the AutoFileName
and AutoFilePrefix properties. The file
names will be automatically generated and can be retrieved from the OnFrameCaptureCompleted
event, that returns also the frames as TBitmap.
Note: enable BurstMode to start the automatic frame
capture process.
property BusyCursor:
TCursor
Sets or retrieves the cursor displayed while the component processes
significant tasks (like recompressing or copying captured data,
restarting preview or capture). The BusyCursor is
displayed when the process starts, and then, the NormalCursor
is displayed back when the process finishes.
Set BusyCursor to crDefault to
disable cursor changes. In this case NormalCursor is ignored.
property
CaptureAudio:
boolean;
Enables or disables the audio capture channel. If false, only the Video stream
is captured.
property CaptureFileExt:
string
Default extension used to create AVI files when the file name is automatically
created. The default value is "avi".
property CaptureFileName: Sets or retrieves the full qualified path and name of the AVI capture file to create. If the file is overwritten if it exists when the capture starts. If CaptureFileName is left blank, a file name is generated automatically according to the AutoFileName property.
property ColorKeyEnabled:
Boolean;
sdf
property CompressionMode:
TCompressionMode;
Sets or retrieves the compression mode
applied to the capture:
cm_NoCompression: no compression is applied to the avi file created,
cm_CompressOnTheFly: the VideoCompressor and/or AudioCompressor are applied WHILE capturing data,
cm_CompressAfterCapture: the VideoCompressor is applied on the captured file AFTER the capture ends.Note: this is an enumerated type of 3 elements, so, an longint value from 0 to 2 can be assigned. E.g.: VideoGrabber1.CompressionMode := TCompressionMode (RadioGroup.ItemIndex).
property
CompressionType:
TCompressionType
Sets or retrieves the compression type applied to the capture:
ct_Video: only the video stream is compressed by the VideoCompressor codec,
ct_Audio: only the audio stream is compressed by the Audiocompressor codec,
ct_AudioVideo: both audio and video streams are compressed by the VideoCompressor and AudioCompressor codecs.Note: this is an enumerated type of 3 elements, so, an longint value from 0 to 2 can be assigned. E.g.:
VideoGrabber1.CompressionType := TCompressionType (RadioGroup.ItemIndex).
property DVNativeInterleavedToAVI:
boolean;
DV cameras produce interleaved audio-video; each frame of video also contains
the audio information.
disabled (default):
Splits the DV data into separate audio and video streams, with types auds and vids. The video stream can be modified (compression, drawing over frames...).enabled:
the native interleaved data is saved as a single stream in the AVI file, with type ivas. No AVI frame processing or compression is possible in this format.
property DVRgb219: The DV video format has a dynamic range of 16–235. By default, when the DV Video Decoder decodes to 24-bit or 32-bit RGB, by stretching the color range from to 0–255. In RGB-219 mode, the decoder does not stretch the color range.
property DVReduceFrameRate:
boolean;
Enables or disables the reduction of the
frame rate. If enabled, discards half of the frames in the video stream. For
NTSC, the frame rate is reduced from 30 frames per second (fps) to 15 fps. For
PAL, the frame rate is reduced from 25 fps to 12.5 fps.
property DVUseExternalAudio:
DV cameras
produce interleaved audio-video; each frame of video also contains the audio
information.
If DVNativeInterleavedToAVI is disabled, enable DVUseExternalAudio to
can capture to the AVI another audio source than the audio stream coming from
the DV stream (e.g. the microphone from a webcam). This allows you e.g. to add
audio comments on a DV video stream.
property FrameBuffers:
longint;
Numbers of buffers allocated during preview, AVI capture
or playback. The good range is between 2 and 5. Below 2, you will get more
dropped frames, and above 5 you waste memory, especially with large frames.
Note: using large values allows to store the frames in memory, so you can
capture a FrameBuffers number of frames at maximal rate without
dropping frames.
property FrameCaptureZoomSize:
boolean;
Sets or retrieves the size of the captured images using CaptureFrameTo
or BurstMode, in percentage of the
nominal size. Default value: 100%.
Note: when the value is greater or lower than 100, the frame image is COPIED
and STRETCHED, so the frame capture process is slowed down, especially with
large zoom values.
property FrameGrabberEnabled:
boolean;
Enables the frame capture and drawing over frames
functions. The concerned functions and events are listed here.
Disable the frame grabber to save CPU and get less dropped frames,
especially when capturing large video sizes to AVI.
property FrameRate:
Sets or retrieves the frame rate in frames per second.
If FrameRate = 0, the default frame rate of the video capture device is used.
This property is the desired frame rate and does not
apply to DV (see DV resolutions above). You can retrieve the effective
frame rate (for analog as well as DV) by reading the CurrentFrameRate
property.
property FullScreenPreview:
boolean;
if true, the preview window is displayed in full screen mode. If set to false
while previewing in full screen mode, the preview is switched back to the normal
windowed mode.
property JPEGPerformance:
TJPEGPerformance = (jpBestQuality, jpBestSpeed);
Controls the trade-off between color quality and speed of decompression of
JPEG files created by CaptureFrameTo.
property JPEGProgressiveDisplay:
boolean;
Use ProgressiveDisplay to turn on or off the incremental display of an image
when reading in JPEG files created by CaptureFrameTo.
property JPEGQuality:
TJPEGQualityRange = 1..100;
Use CompressionQuality to set the compression quality of a JPEG image created by
CaptureFrameTo. Higher compression results in a
poorer picture quality, but a smaller file size.
property MaintainImageRatio:
boolean;
Maintains the image ratio of the video within the display control.
property NormalCursor:
TCursor
Sets or retrieves the cursor type that is restored after a process finishes
that displayed BusyCursor. If BusyCursor is left
to crDefault, NormalCursor is ignored. See the BusyCursor
property.
property OverlayEnabled:
Enable the overlay mixer, if available for the current video device.
The overlay accelerates display, but third-party filters are no more previewed, because the video device capture writes frames
directly into video memory.
property PlayerAutoStart:
boolean;
If enabled, clips starts automatically after calling
OpenPlayer. If disabled, clips are opened and immediately displayed in a
paused mode.
property PlayerFastSeekMultiplier:
longint;
Sets or retrieves the speed multiplier used by FastForwardsPlayer
and RewindsPlayer. Default value: 4.
property PlayerFileName:
string;
Sets or retrieves the file name of the clip to play. Then, call
OpenPlayer.
property PlayerFrameRate:
double
Sets or retrieves the value of the player frame rate, used when playing a captured
file or a clip (call OpenPlayer, and then
RunPlayer). The value is expressed as a
ratio of the normal speed. 1.0 is normal playback speed, 0.5 is half speed, 2.0
is twice speed.
property PreallocCapFileEnabled:
boolean;
Enables the pre-allocation of a capture file. For best capture results, capture
to a unfragmented, pre-allocated capture file that is larger than the size of the
capture data.
property PreallocCapFileName:
string;
Sets or retrieves the full qualified path and name of the pre-allocated file. If left blank,
a generic filename is created in the StoragePath
directory. Effective only if PreallocCapFileEnabled
is true.
property PreallocCapFileSizeInMB:
longint;
Size of the preallocated capture file in Mb. For best results, the size should
be larger than the size of the capture data. Effective only if PreallocCapFileEnabled
is true.
property PreallocCapFileRecreate:
boolean;
If true, the preallocated file is recreated each time a capture starts.
Effective only if PreallocCapFileEnabled
is true.
property PreviewZoomSize:
longint;
Sets or retrieves the size of the preview window, in percentage of the
nominal size.
This property is ignored if AutoSize is enabled.
Default value: 100%.
property RefreshPreviewOnParamChange:
boolean;
If true, the previewed video is restarted each time a parameter
is set.
If false, the previewed video is not refreshed when
new values are assigned to the TVideoGrabber parameters. In this case use StartPreview to apply the new
parameters (it is not necessary to call StopPreview to restart the preview with
StartPreview).
property RenderAudio:
boolean;
Enables or disables the audio rendering. If the audio capture device is a
microphone and RenderAudio is enabled, take care to keep the microphone away
from the speakers, otherwise you will get loop back echoes.
property ShapeOnFrame: TShape;
Shape that will be drawn over frames if ShapeOnFrameEnabled
= true.
You can either put a TShape on the form or create the TShape
programmatically at runtime.
property ShapeOnFrameEnabled:
boolean;
If enabled, the ShapeOnFrame TShape component is drawn
over the video frames. The ShapeOnFrame property above must be assigned.
property StoragePath:
string;
Sets or retrieves the full qualified path where video captures and bmp snapshots
will be stored. If left blank, the default storage path is the
directory.
Note: this property is not saved by the component, because it depends
of the platform and disk layout.
Simply set in from the FormCreate event or later in your code.
E.g.:
procedure TForm1.FormCreate(Sender: TObject);
begin
...
VideoGrabber1.storagepath := 'c:\MyNewPath';
...
end;
property StoreDeviceSettingsInRegistry:
boolean;
If true, the current settings are kept in memory and
automatically retrieved. The settings are individually kept for each video or
audio capture device.
property TextOnFrameAlign:
TTextOnFrameAlign;
Alignment of the text displayed on the frame between the
TextOnFrame_Left and TextOnFrame_Right
positions:
tf_Left: the text is left-padded
tf_Center: the text is centered
tf_Right: the text is right-padded
property TextOnFrameBkColor: TColor;
Background color of the text written over the frames. TextOnFrameTransparent
must be disabled.
property TextOnFrameEnabled:
boolean;
If enabled, the TextOnFramestring
is written on the frame according to the other TextOnFrame... properties.
property TextOnFrameFont: TFont;
Font used to write the text on the frame. Can be set
programmatically as well as from the object inspector.
property TextOnFrameString:
stringstring to write on the frame. Can be set in real
time.
The text string can be composed of several lines separated by cr-lf
(chr(10)+chr(13)).
You can use several variables within the string. When TVideoGrabber detects
these variables it replace them by their current values:
- %frame_count% : number of the current frame
- %frame_ns% : time of the
current frame, in nano-seconds
- %frame_sec% : time of the current frame, in
seconds with 2 decimals
- %time_code% : current time code, if available
(mainly with DV)
property TextOnFrameTransparent:
boolean;
If enabled, the text is transparent (the frame is
visible under the text). If disabled, the text is opaque and the background
color can be set by TextOnFrameBkColor.
property TextOnFrame_Left:
longint;
Left position where the text will be displayed over the
frame.
The text will be left-padded on this position if TextOnFrameAlign
= tf_Left.
property TextOnFrame_Right:
longint;
Right
property TextOnFrame_Top:
longint;
Top
property VCompKeyFrameRate:
longint;
Sets or retrieves then desired video
compressor's key-frame
rate. If the value is negative, the filter will use the default key-frame rate.
If the value is zero, only the first frame will be a key frame.
property VCompQuality:
double;
Specifies the video compressor's quality as a value between 0.0
and 1.0, where 1.0 indicates the best quality and 0.0 indicates the worst
quality. If the value is negative, the filter will use the default quality.
property VideoCompressor:
longint;
Sets or retrieves the index of the active video format in the
VideoCompressors
list. Effective only if CompressionMode is set to
cm_CompressOnTheFly
or cm_CompressAfterCapture.
property VideoDevice:
longint;
Sets or retrieves the index of the current active video device in the VideoDevices
list.
property
VideoSize:
longint;
Sets or retrieves the index of the video size in the VideoSizes
list. Does not apply to DV.
property VideoSubType:
string;
Sets or retrieves the index
of the video subtype in the VideoSubTypes
list. The list Does not apply to DV.
property
Visible:
boolean;
If enabled, the preview window (or player window) is visible. Is
disabled, the preview is not visible.
Note: do not stop preview if you need to capture frames when the component is
not visible. The preview must go on running in the background.
event OnCaptureCompleted
(Sender: TObject; FileName: string; Succeeded: boolean);
Occurs after a StopCapture call, when the process is
fully completed (with or without success).
FileName returns the file name of the AVI file. Useful to know the file name
automatically generated if CaptureFileName was
left blank before calling StartCapture.
event
OnCaptureReadyToStart
(Sender: TObject; var OkToStart:
boolean);
Occurs after calling StartCapture, when the capture
is really ready to start writing data to disk. Use this event to accurately
start capturing data, e.g. using a MessageDlg box like "start capture
now?". At this point the capture can be cancelled by setting OkToStart =
false.
event
OnCaptureStarted
(Sender: TObject);
Occurs when the capture starts writing captured data to the disk.
event
OnChangeAudioDevice
(Sender: TObject);
Occurs when a new device is selected (or disconnected).
event
OnChangeVideoDevice
(Sender: TObject);
Occurs when a new device is selected (or disconnected).
event OnColorKeyChange (Sender: TObject;
ColorKey: TColor) of object;
Occurs if ColorKeyEnabled
is true, and if the overlay can be used. This event occurs usually immediately
after starting preview, AVI capture or playback.
Use the color key to set part of a window transparent (see the MainDemo
project for sample code). You can change the
default color keys with SetColorKeys.
event
OnComponentLoaded
(Sender: TObject);
Occurs immediately after starting the application, when the component is fully
loaded and ready to accept commands.
event
OnCopyPreallocDataCompleted
(Sender: TObject; Succeeded: boolean);
Occurs when the valid data has been fully copied from the pre-allocated file to a
new file. As a result, the new file can be much smaller than the preallocated
file.
event OnCopyPreallocDataStarted
(Sender: TObject);
Occurs when the valid data is about to be copied from the pre-allocated file.
event
OnCreatePreallocFileCompleted
(Sender: TObject; Succeeded: boolean);
Occurs when the pre-allocated file is created.
event
OnCreatePreallocFileStarted
(Sender: TObject);
Occurs when the pre-allocated file is about to be created.
event OnDeviceArrival
(Sender: TObject);
Occurs when a video or audio device is
connected.
event
OnDeviceLost
(Sender: TObject);
Occurs when the video or audio device currently previewing
or capturing is disconnected.
event OnDeviceRemoval
(Sender: TObject);
Occurs when the current video or audio device is disconnected.
Note: a "~" at the end of a WDM device name indicates that this device
has been disconnected. The device name is returned by the VideoDevices
list and the VideoDeviceName property.
event
OnDiskFull (Sender: TObject);
Occurs when no more disk space is available while capturing data
or recompressing a file. The detection level is 25 Mb
free.
event OnDrawOverFrame (Sender: TObject; FrameInfo:
TFrameInfo; Dc: HDC);
Allows to draw anything (text, shapes, images) over
the video frames bitmaps, using their device context. See OnFrameProgress
about the TFrameInfo content.
Note if you are capturing video to an AVI file:
this event is synchronous and TIME CRITICAL. It must be completed as soon as
possible. DO NOT perform disk access or slow operations from this event.
If you have to write external bitmaps over the video frames, prepare them and
store them to the memory OUT OF THIS EVENT (i.e. from a thread), and perform
only the bitmap copy from memory here.
event
OnErrorLog (Sender: TObject; ErrorCode: ErrorCode: longint; ErrorMsg: string);
Returns warning or error messages, with their associated
code. The error code can be used programmatically to handle the errors or
warnings.
event OnFrameCaptureCompleted (Sender: TObject; const FrameData: TFrameData; DestType: TFrameCaptureDest; FileName: string; Success: boolean
Returns the captured frame after a call to CaptureFrameTo or when BurstMode is enabled:
FrameData returns the following structure:
TFrameData = record
Bitmap: TBitmap;
FrameNumber: longint;
FrameTime: int64;
end;where:
- Bitmap is image returned as TBitmap (Graphics unit type),
- FrameNumber is the frame number since the stream started,
- FrameTime is the time from the beginning of the stream in 100ns units.
DestType returns the destination of the frame: bitmap, bitmap and JPEG file, bitmap and BMP file. The value is returned only for informational purpose. It has been set when calling CaptureFrameTo (for individual frame capture) or BurstMode (for automated frame capture).
FileName returns the name of the JPEG or BMP file created if DestType was fc_JpegFile or fc_BmpFile.
event OnFrameProgress (Sender: TObject; FrameInfo:
TFrameInfo);
Occurs for each frame delivered by the video stream.
FrameInfo is a TFrameInfo record that reports the following frame information:
Notes:
- all the values above are related to the start time of the current video stream
- the time code values return -1 if the time code is not availableFrameInfo returns the following data (see TFrameInfo):
FrameNumber: number of the current frame,
FrameTime: time of the current frame since the beginning of the stream, in which each unit of time is 100 nanoseconds
DroppedFrameCount: number of dropped frames (meaningful for preview and AVI capture only)
SampleTime_TotalMin: total number of minutes,
SampleTime_TotalSec: total number of seconds,
SampleTime_TotalHs: total number of hundreds of seconds,
SampleTime_Hour: number of hours of the frame time,
SampleTime_Min: number of minutes of the frame time,
SampleTime_Sec: number of seconds of the frame time,
SampleTime_Hs: number of hundreds of seconds of the frame time,
TimeCode_Hour: number of hours of the time code,
TimeCode_Min: number of minutes of the time code,
TimeCode_Sec: number of seconds of the time code,
TimeCode_Ff: number of the frame in the current second of the time code,
TimeCode_TrackNumber: number of the track of the time code.
event
OnFullScreenKeyPress
(Sender: TObject; var Key: Char);
Occurs when pressing a key while displaying in full screen mode. Allow to
associate commands with keyboard keys (ESC is reserved to the exit from the full
screen mode).
event
OnNoVideoDevices
(Sender: TObject);
Occurs if there is no video device available when
the component loads.
event
OnPlayerEndOfStream
(Sender: TObject);
Occurs when end of the clip currently playing is reached.
event
OnPlayerFileNotFound
(Sender: TObject; FileName: string);
Occurs if the play back file invoked by OpenPlayer is not found.
event
OnPlayerStarted
(Sender: TObject);
Occurs when a file playback starts.
event
OnPreviewStarted
(Sender: TObject);
Occurs when the preview is active.
event
OnRecompressCompleted
(Sender: TObject; Succeeded: boolean);
Occurs when a video file stream recompression ends.
Returns true on success.
event
OnRecompressStarted
(Sender: TObject);
Occurs when a video file stream recompression starts.
event
OnResizeVideo
(Sender: TObject; FVideoWidth, FVideoHeight: longint);
Occurs when the size of the video source changes.
TV TUNER functions
THE SIMPLEST WAY IS TO CALL THE WDM DIALOG: S
howDialog (dlg_TVTuner); (TVideoGrabber keeps
the current settings in the registry)
The following methods give a full control on the IAMTVTuner
interface, that is derived from the IAMTuner
interface.
Note: the TV card must be WDM compliant.
function TVAutoTune (lChannel: longint; out
plFoundSignal: longint): boolean;
function TVChannelMinMax (out lChannelMin,
lChannelMax: longint): boolean;
function TVGetAvailableTVFormats (out
lAnalogVideoStandard: longint): boolean;
function TVGetTVFormat (out
plAnalogVideoStandard: longint): boolean;
function TVGetAudioFrequency (out lFreq: longint):
boolean;
function TVGetAvailableModes (out plModes: longint):
boolean;
function TVGetChannel (out lChannel,
lVideoSubChannel, lAudioSubChannel: longint): boolean;
function TVGetConnectInput (out plIndex: longint):
boolean;
function TVGetCountryCode (out lCountryCode: longint):
boolean;
function TVGetInputType (lIndex: longint; out
InputType: TTunerInputType): boolean;
function TVGetMode (out plMode:
TAMTunerModeType): boolean;
function TVGetNumInputConnections (out
plNumInputConnections: longint): boolean;
function TVGetTuningSpace (out lTuningSpace: longint):
boolean;
function TVGetVideoFrequency (out lFreq: longint):
boolean;
function TVLogon (hCurrentUser: THandle): boolean;
function TVLogout: boolean;
function TVPutChannel (lChannel,
lVideoSubChannel, lAudioSubChannel: longint): boolean;
function TVPutConnectInput (lIndex: longint):
boolean;
function TVPutCountryCode (lCountryCode: longint):
boolean;
function TVPutInputType (lIndex: longint;
InputType: TTunerInputType): boolean;
function TVPutMode (lMode: TAMTunerModeType):
boolean;
function TVPutTuningSpace (lTuningSpace: longint):
boolean;
function TVSignalPresent (out plSignalStrength:
longint): boolean;
function TVStoreAutoTune: boolean;
ANALOG VIDEO DECODER functions
The following methods give a full control on the IAMAnalogVideoDecoder
interface.
Note: the TV card must be WDM compliant.
function VDECGetHorizontalLocked (out
plLocked: longint): boolean;
function VDECGetNumberOfLines (out
plNumberOfLines: longint): boolean;
function VDECGetOutputEnable (out
plOutputEnable: LongBool): boolean;
function VDECGetVCRHorizontalLocking (out
plVCRHorizontalLocking: longint): boolean;
function VDECPutTVFormat
(lAnalogVideoStandard: longint): boolean;
function VDECPutOutputEnable (lOutputEnable:
LongBool): boolean;
function VDECPutVCRHorizontalLocking
(lVCRHorizontalLocking: longint): boolean;
TFrameInfo = record
FrameNumber: longint;
DroppedFrameCount: longint;
SampleTime_TotalMin: longint;
SampleTime_Hour: longint;
SampleTime_Min: longint;
SampleTime_Sec: longint;
SampleTime_Hs: longint;
TimeCode_Hour: longint;
TimeCode_Min: longint;
TimeCode_Sec: longint;
TimeCode_Ff: longint;
TimeCode_TrackNumber: longint;
FrameTime: int64;
SampleTime_TotalSec: int64;
SampleTime_TotalHs: int64;
end;
TFrameInfo is returned by the OnFrameProgress and the OnDrawOverFrame events. The content is described here.
TFrameData
= record
Bitmap: TBitmap;
FrameNumber: longint;
FrameTime: int64;
end;
TFrameData is returned by the OnFrameCaptureCompleted event. The content is described here.
TAutoFileName =
(fn_Sequential, fn_DateTime);
See the AutoFileName property.
TCompressionMode
= (cm_NoCompression, cm_CompressOnTheFly, cm_CompressAfterCapture);
See the CompressionMode property.
TCompressionType =
(ct_Video, ct_Audio, ct_AudioVideo);
See the CompressionType property.
TCrossbarSelector = (cs_VideoCrossbar, cs_AudioCrossbar);
TCurrentState =
(cs_Down, cs_Preview, cs_Capture, cs_Playback, cs_Compress);
See the CurrentState property.
TDialog = (
dlg_Device,
dlg_Compressor,
dlg_StreamConfig,
dlg_VfwFormat,
dlg_vfwSource,
dlg_vfwDisplay,
dlg_VideoCrossbar,
dlg_AudioCrossbar,
dlg_TVTuner,
dlg_TVAudio,
dlg_Audio,
dlg_DSCALER
);
See the ShowDialog procedure.
TVCRCommand = (
vcr_Play,
vcr_Stop,
vcr_Freeze,
vcr_FF,
vcr_Rew,
vcr_Record,
vcr_RecordFreeze,
vcr_StepFwd,
vcr_StepRev,
vcr_PlayFastestFwd,
vcr_PlaySlowestFwd,
vcr_PlayFastestRev,
vcr_PlaySlowestRev);
See the SendVCRCommand function.
TFrameCaptureDest
= (fc_TBitmap, fc_BmpFile, fc_JpegFile);
See the CaptureFrameTo procedure.
TAudioFormat
= (
af_default,
af_8000_8b_1ch,
af_8000_8b_2ch,
af_8000_16b_1ch,
af_8000_16b_2ch,
af_11025_8b_1ch,
af_11025_8b_2ch,
af_11025_16b_1ch,
af_11025_16b_2ch,
af_12000_8b_1ch,
af_12000_8b_2ch,
af_12000_16b_1ch,
af_12000_16b_2ch,
af_16000_8b_1ch,
af_16000_8b_2ch,
af_16000_16b_1ch,
af_16000_16b_2ch,
af_22050_8b_1ch,
af_22050_8b_2ch,
af_22050_16b_1ch,
af_22050_16b_2ch,
af_24000_8b_1ch,
af_24000_8b_2ch,
af_24000_16b_1ch,
af_24000_16b_2ch,
af_32000_8b_1ch,
af_32000_8b_2ch,
af_32000_16b_1ch,
af_32000_16b_2ch,
af_44100_8b_1ch,
af_44100_8b_2ch,
af_44100_16b_1ch,
af_44100_16b_2ch,
af_48000_8b_1ch,
af_48000_8b_2ch,
af_48000_16b_1ch,
af_48000_16b_2ch);
See the AudioFormat and AudioFormats
property.
TTextOnFrameAlign = (tf_Left, tf_Center, tf_Right);
See property TextOnFrameAlign
TThirdPartyFilterList = (
tpf_VideoSource,
tpf_VideoPreview,
tpf_VideoCapture,
tpf_AudioSource,
tpf_AudioRender,
tpf_AudioCapture
);
See ThirdPartyFilter_AddToList for
more information.
TVideoQuality = (
vq_Brightness,
vq_Contrast,
vq_Hue,
vq_Saturation,
vq_Sharpness,
vq_Gamma,
vq_ColorEnable,
vq_WhiteBalance,
vq_BacklightCompensation,
vq_Gain
);
See GetVideoQuality, IsVideoQualitySettingAvailable,
SetVideoQuality
Global variables
CleanTVideoGrabberRegistryOnExit:
boolean;
TVideoGrabber stores settings of video devices and compression filter in
the HKEY_CURRENT_USER\Software\VideoGrabber registry key.
If CleanTVideoGrabberRegistryOnExit is enabled the TVideoGrabber registry key is
removed when exiting the app.
Note: you can change the name of the registry key with RegKeyId.
CodecsDisabledFromIDE:
boolean;
Can be set in the
initialization section of the unit.
Enable this property if you get "breakpoint"
CPU windows when running your project from the IDE.
Explanations: some third-party codecs (like Voxware codecs) generates "int
3" breakpoints when TVideoGrabber query them to generate the codecs
list.
Although this phenomena has no consequences when running your application out of
the IDE, when running from the IDE the Debugger stops the project when it
receives these breakpoints and shows the CPU window. You can continue by
pressing the "F9" key as many times as necessary, but this is rather
messy. 2 solutions to avoid this problem:
1. if you do not need the debugger, you can disable it in Tools | Debugger
Options and uncheck "Integrated debugging" at the bottom of the dialog
pages,
2. if you need the debugger but do not need the audio and / or video codecs,
enable the CodecsDisabledFromIDE property to avoid enumerating them.
RegistryUpdateErrorMsg
: string;
Can be set in the
initialization section of the unit.
TVideoGrabber uses its own DirectX filter, named tvg_splt.ax. At runtime,
TVideoGrabber checks if the tvg_splt.ax filter matches the version of
TVideoGrabber. If the filter does not exist or the version is obsolete,
TVideoGrabber tries to update and/or register itself this filter. If the process
fails because the current user does not have administrator rights, the
RegistryUpdateErrorMsg message is displayed.
Default value: = 'TVideoGrabber cannot register tvg_splt.ax in the system32
directory';
RegKeyId:
Can be set in the
initialization section of the unit.
This is the identifier of the
"\Software" registry key used by TVideoGrabber to store its current
settings into the registry. You can change is to the name of your choice in the
initialization section of the TVideoGrabber form.
Note: don't forget the '\' at the
end of the string.
E.g.:
unit ...
interface
...
implementation
...
initialization
RegKeyId := '\Software\MyProject\';
end.
VfwDriversEnabled:
Can be set in the
initialization section of the unit.
If enabled, the old VFW drivers are listed in
the video devices list, otherwise they aren't.
Although TVideoGrabber accepts VFW drivers, we highly recommend to use WDM
(Windows Driver Model) drivers instead of old VFW (Video For Windows) drivers.
VFW is poorly implemented in DirectX and older versions can cause crashes.
Update to WDM every time it is possible.
. look at the SimpleDemo project included in the package. It illustrates well the basic features of TVideoGrabber.
. a bit more complex, the Demo project includes near all of the possibilities of TVideoGrabber.
DESIGN MODE:
The TVideoGrabber component does not display anything in design mode. The video is previewed only at runtime.
HOW TO SELECT VIDEO DEVICES, AUDIO DEVICES, COMPRESSORS:
The explanations below (about video devices) are the same for audio devices, video compressors and audio compressors.
- video input devices can be selected by assigning a number to the VideoDevice property (index),
- the video input devices list is available in the
VideoDevices string property. This list can be directly assigned to a TListBox,
TComboBox, TMemo, etc...
E.g. ComboBox1.Items.Text := VideoGrabber1.VideoDevices (see the SimpleDemo
project).
- the number of video input devices is available through the VideoDevicesCount property,
- the name of an individual video input device is available through the VideoDeviceName (Index) property. Index is the position of the device in the VideoDevices list. The index range is 0 to VideoDevicesCount - 1.
Please note that this License supercedes any license conditions that may or may not have been written elsewhere inside the actual software archives.
Copyright
All DataStead software components and applications are copyrighted by Michel FORNENGO (hereafter "author"), and shall remain the exclusive property of the author.
General agreement
By installing this software you agree with:
- You may not use the source code in this package to create competitive software
product.
- You may not manipulate any binary files included or generated by
Delphi/C++Builder using the package.
- You may not distribute source code or registered version to non registered
people.
Development components agreement
By installing the registered version of this development component you agree with:
- You are allowed to build and distribute a compiled APPLICATION including the registered version of the component for a precise purpose. This application can be commercial, shareware of freeware.
- You may not distribute or communicate any part of the source code of the registered component to non registered people,
- You may not distribute any part of the registered version of the component (dcu, binaries, lib, dcp, bpl files) to non registered people,
- You may not distribute any SDK or development tool built with the registered version of the component,
- You may not distribute any project including parts (sources or binaries) of the registered version of the component under Open Source license, GNU license or similar.
Registered versions license statement
This software and any accompanying documentation
are protected by copyright law and by International Treaty provisions.
Any use of this software in violation of copyright law or the terms of this
agreement will be prosecuted to the best of the author's ability.
You are hereby authorized to make archival copies of this software for the sole
purpose of back-up and protecting your investment from loss.
Under no circumstances may you copy this software or documentation for the
purposes of distribution to others. Under no conditions may you remove the
copyright notices made part of the software or documentation.
Distribution Rights
You are granted a non-exclusive, royalty-free right to produce and distribute executable binary files (executables, DLLs, etc.) that are built with the registered version of the software unless specifically stated otherwise.
Restrictions
Without the express prior written consent of the author, you may not distribute any of the author's commercial source code, compiled units or documentation by any means whatsoever. You may not transfer, lease, lend, copy, modify, translate, sublicense, time-share, or electronically transmit or receive the software or documentation.
Upgrade
The upgrade version of the software constitutes a single product of the author's software that you upgraded. For example, the upgrade and the software that you upgraded cannot both be available for use by two different people at the same time, without written permission from the author.
Disclaimer
The Author cannot and does not warrant that any
functions contained in the Software will meet your requirements, or that its
operations will be error free. The entire risk as to the Software performance or
quality, or both, is solely with the user and not the Author. You assume
responsibility for the selection of the component to achieve your intended
results, and for the installation, use, and results obtained from the Software.
The Author makes no warranty, either implied or expressed, including without
limitation any warranty with respect to this Software documented here, its
quality, performance, or fitness for a particular purpose. In no event shall the
Author be liable to you for damages, whether direct or indirect, incidental,
special, or consequential arising out the use of or any defect in the Software,
even if the Author has been advised of the possibility of such damages, or for
any claim by any other party.
All other warranties of any kind, either express or implied, including but not
limited to the implied warranties of merchantability and fitness for a
particular purpose, are expressly excluded.
General
This Agreement is the complete statement of the Agreement between the parties on the subject matter, and merges and supersedes all other or prior understandings, order orders, agreements and arrangements. This Agreement shall be governed by the laws of France. Exclusive jurisdiction and venue for all matters relating to this Agreement shall be in courts and fora located in France, and you consent to such jurisdiction and venue. There are no third party beneficiaries of any promises, obligations or representations made by DataStead.
TVideoGrabber is a VCL video capture component for Delphi or C++ Builder.
TVideoGrabber allows you to include video capture capabilities in your project.
It can be used as a standard visible VCL component, or as a "background" non-visible component.
Based on DirectX, TVideoGrabber it is fully WDM compliant.
With TVideoGrabber, you can:
PREVIEW the video streams in a windowed control, an external window or in full screen mode,
CAPTURE FRAMES to TImage, TBitmap, BMP or JPEG files, individually or automatically in "burst" mode,
CAPTURE VIDEO STREAMS to AVI files, with or without audio stream,
COMPRESS the captured AVI, on the fly or after capture, using the codecs available on the current platform. Additional codecs like MPEG4 and DivX are automatically recognized,
WRITE TEXT
, DRAW SHAPES OR BITMAPS OVER FRAMES during preview, capture or playback,USE TRANSPARENT WINDOWS,
PLA
YBACK video clips at their nominal rate, forwards, backwards, slower, faster, in a resizable window, an external window or in full screen mode,CONTROL
- the settings of video devices,
audio devices and video compressors
- the audio and video formats,
- the video quality, like brightness, hue, saturation, contrast, white
balance,...
- the frame rate,
- the preview and capture size,
-
the number of delivered
frames and dropped frames,
- the DV capture mode, if any (interleaved or separated audio/video),
- the TV tuner,
- etc...
USE THIRD-PARTY CODECS AND FILTERS in the preview stream and / or the AVI capture stream.
Benefits
- saves you having to tangle with DirectX and DirectShow,
- easy to use.
NO RUNTIME LICENSE
The license is a "per developer" license that grants you the royalty-free right to use the TVideoGrabber component compiled in your end-user applications.
this component is suited for target acquisition, target tracking, motion detection
Click here to be transported to the TVideoGrabber registration page.
cannot select the video input of a 4 inputs
capture card
cannot select the video input of a ProVideo PV143
cannot select video input of a Trust 814PCI
high dropped frames rate
asked for TVIDGRAB.LIB
don't want vfw drivers
nothing displayed during playback
Delphi6 trial
CPU window when running from the IDE
I cannot select the video input of a video capture card with 4 inputs and BT848/BT878 family chip
Some of their drivers do not expose the IAMCrossbar interface (that allows to change the current input under WDM).
1) First of all, go to the support page of your capture card manufacturer and check that you have the latest version of the driver, otherwise download it, upgrade your driver and try again (*)
2) if you have the latest version of the driver and you cannot select the input, there are 2 ways to fix the problem:
a) slow method: contact the support of your capture card and request a driver upgrade that exposes the WDM IAMCrossbar Interface
b) fast method: try this generic BT848/BT878 driver.
- run the BtInstaller.exe, choose "Install this Driver"
- in the "Select you Video Capture Card" list box, try to locate and select your card model, or the nearest model, if any. If you do not find a card model that match your card, select "Generic Bt8xx based with 4 Composite ins"
- install the driver and try again (*)
(*) the TVideoGrabber's IsVideoCrossbarAvailable property will be updated AFTER the preview starts. So, after upgrading the driver, it is possible that you have to start your app, exit your app and restart your app a 2nd time to get the video inputs available.
I cannot select the video input of a ProVideo PV143 (4 inputs) capture card:
The latest version of the driver do not expose the WDM crossbar. We have tested an older version of the driver (5 March 2001) that works fine. Otherwise you can use the generic BT848/BT878 driver above.
I cannot select the video input of a Trust814 PCI (4 inputs) capture card:
Extracted from the FAQ section of the Trust 814PCI card (from Trust
support):
Q: Can this product also work with other 4 channel video software?
A: No, the software and hardware are specially designed for each other...
I get an high number of dropped frames when capturing to AVI
Look at the "Avoiding dropped frames" section in the "TIPS" chapter of the user guide.
Using C++Builder, I'm asked for the TVIDGRAB.LIB, and I don't have this file.
When installing the TVideoGrabber component, C++Builder automatically adds
TVidGrab in the "build with runtime" packages.
The TVidGrab package name must be manually removed. Proceed as following:
- go to Project | Options | packages
- at the bottom of the form, there is a "build with runtime packages"
checkbox,
- below this checkbox there is an edit field with a list of packages,
- check "build with runtime packages": the edit field now can be
edited,
- move at the end of the edit field, you should see "...;TVidGrab;...",
- remove only ";TVidGrab" and leave the other packages names,
- uncheck "build with runtime packages.
- try to rebuild your project, you should no more be asked for the TVidGrab.lib
file.
I do not want to use vfw drivers, only WDM drivers. How can I avoid having vfw drivers get listed in the video devices list?
In the initialization section at the bottom of your project, add the
following statement:
...
initialization
VfwDriversEnabled := False;
end.
I get an error when opening mpeg clips. Nothing is displayed.
1. the codec required by your
clip is probably not installed on your platform. To check that, try to open the clip with
the Windows Media Player.
- if the media player reports an error, try to find and install the required
codec.
- if the media player downloads and install automatically the codec, and then,
plays the clip, try again to open the clip with TVideoGrabber.
2. errors when opening clips are often caused by bugs in third-party codecs. Try to open the clip in the Windows Media Player. If the clip don't work in the WMP as well, and you have an additional codec installed, remove it and try again.
I loaded up the demo for
TVideoGrabber in Delphi 6 Trial and
tried to build it.
I am getting the following error: Access violation at address 009807e7 in
module dcc60.dll read of address 000E9c6.
The trial version comes with a different DCU format than the real one. TVideoGrabber or other third-party components can't be used in the trial.
I get an exception error CPU window occurs when running the project from the IDE, but not out of the IDE:
If you see "breakpoint" labels in the CPU window, this problem is commonly caused by debug statements left in of some codecs (like Voxware audio codecs) that stops the program by sending unwanted "int 3" breakpoints to the Delphi or C++Builder debugger. This problem occurs when TVideoGrabber enumerates the codecs.
This has absolutely no consequences on the application, but is annoying debug the project from the IDE.
To avoid this problem, an option has been added to disable the codecs
enumeration when running the project from the IDE. To use this option, add an
initialization section at the bottom of your TVideoGrabber's form as following:
...
initialization
CodecsDisabledFromIDE := true;
finalization
end.
However, the codecs cannot be used by TVideoGrabber if this option is enabled and Delphi or C++Builder is running. If you need to test your project with compression filters, disable this option and press "F9" at run time as many times as necessary, then enable the option again when you have finished testing the codecs.
[vidgrab/include/tips.htm]