Inserting third-party filters
Inserting third-party filters Third-party filters may be inserted in the preview, recording, or playback streams, in the order they were added to the list.
To simply add a filter to the graph, invoke ThirdPartyFilter_AddToList (tpf_AddToGraph,...) as shown in the example below.
if the file path of the filter is specified in the OptionalDLLPath parameter, the filter does not need to be registered with regsvr32.exe, it will be directly loaded from the.AX or.DLL file.
A third-party filter may be used also as a video source or an audio source when VideoSource = vs_ThirdPartyFilter (explained in the last paragraph below).
A filter can be inserted only 1 TIME in the same list.
To use a third-party filter, proceed as follows:
Overview 1. register the filter on the current platform, either manually from the command line with regsvr32, either programmatically with the ComObj unit's RegisterComServer function, 2. choose the location of the filter, 3. retrieve the CLSID of the filter, 4. declare the filter in TVideoGrabber before starting preview, capture or playback 5. the filter will now be used in the next preview, recording or play back.
- install and register the third-party filter Let's suppose the filter to use is named "myfilter.ax": 1a. third-party filter registered from the command line
- copy the myfilter.ax file in the windows/system32 or winnt/system32 directory
- click on "Start", "Execute", then enter the following command line: regsvr32 c:/windows/system32/myfilter.ax
1b. third-party filter registered programmatically - add the unit ComObj to the "uses" statement of the unit, - copy the myfilter.ax file in the windows/system32 or winnt/system32 directory (e.g. using CopyFile), - call RegisterComServer ('c:/windows/system32/myfilter.ax'); 2. choose the location of the filter within the preview, recording or playback graph. Find the right location according to the TThirdPartyFilterList location. This location will specify to the ThirdPartyFilter_AddToList where needed to place the filter in the audio or video graph.
- retrieve the filter's CLSID We have to know the CLSID of the filter. Either it can found in the filter's user guide, either it can be retrieved from the registry. To retrieve the CLSID from the registry, proceed as follows:
- run regedit
- at the top of the tree, click "edit"
- click "search"
- enter the file name of the filter (e.g. myfilter.ax).
- start searching.
-
when the search stops, locate the CLSID of the filter and copy the GUID key. It has to be passed as string to the ThirdPartyFilter_AddToList function.
-
add the filter in the list Call ThirdPartyFilter_AddToList with the CLSID of the filter.
E.g. to simply add a filter to the graph: procedure TForm1.Button1Click (Sender: TObject); const CLSID_MYFILTER: String = "{463D645D-48F7-11D4-8464-0008C782A257}"; begin if VideoGrabber1.ThirdPartyFilter_AddToList(tpf_AddToGraph, CLSID_MYFILTER, "", "my custom source filter", True, True) then begin ... end; end;
Alternatively it is possible to give the direct file path to the filter.AX or.DLL file, so it does not need to be registered with regsvr32.exe, e.g.: procedure TForm1.Button1Click (Sender: TObject); const CLSID_MYFILTER: String = "{463D645D-48F7-11D4-8464-0008C782A257}"; begin if VideoGrabber1.ThirdPartyFilter_AddToList(tpf_AddToGraph, CLSID_MYFILTER, "c:/myfolder.ax", "my custom source filter", True, True) then begin ... end; end;
- set the filter properties
- either interactively using ThirdPartyFilter_ShowDialog,
-
either programmatically using the OnThirdPartyFilterConnected event, that returns the IUnknown filter's interface when the graph starts. It is possible that some filters don't show the dialog if a graph is not running (preview, capture or play back).
-
Now the filter(s) will be automatically used during the next preview / recording / playback until ThirdPartyFilter_ClearList is called or the filter is disabled with ThirdPartyFilter_Enable.
How to use third-party filters as a video or video+audio source If needed the third-party filter to be used as a video source: - set VideoSource = vs_ThirdPartyFilter - invoke VideoGrabber1.ThirdPartyFilter_AddToList(tpf_ThirdPartyVideoSource, CLSID of the video third-party filter, '', '...any label...', True, True); - then invoke StartPreview or StartRecording
a) if this filter exposes an audio pin and AudioDeviceRendering or AudioRecording is enabled, the audio out will be used as audio source if AudioSource = as_Default
b) if the video filter does not expose an audio pin and needed audio from another third-party filter, invoke: VideoGrabber1.ThirdPartyFilter_AddToList(tpf_ThirdPartyAudioSource, CLSID of the audio third-party filter, '', '...any label...', True, True); (if the video filter exposes also an audio pin, set AudioSource = as_UseExternalAudio to ignore the audio pin of the video filter and use the audio pin of the audio filter instead).
How to use a third-party filter as an audio source only If needed the third-party filter to be used as an audio source: - set VideoSource = vs_ThirdPartyFilter - invoke VideoGrabber1.ThirdPartyFilter_AddToList(tpf_ThirdPartyAudioSource, CLSID of the third-party filter, '', '...any label...', True, True); - then invoke StartAudioRendering or StartAudioRecording
If the filter exposes an audio pin and AudioDeviceRendering or AudioRecording is enabled, the audio out will be used as audio source if AudioSource = as_Default