Skip to content

Inserting third-party filters

Third-party filters can 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 OptionalDLLFilePath parameter, the filter does not need to be registered with regsvr32.exe: it is loaded directly from the .AX or .DLL file.

A third-party filter can also be used as a video source or an audio source when VideoSource = vs_ThirdPartyFilter (explained in the last sections below).

A filter can be inserted only once in the same list.

Overview

To use a third-party filter, proceed as follows:

  1. Register the filter on the current platform, either manually from the command line with regsvr32, or programmatically with the RegisterComServer function of the ComObj unit.
  2. Choose the location of the filter.
  3. Retrieve the CLSID of the filter.
  4. Declare the filter in TVideoGrabber before starting the preview, capture or playback.
  5. The filter is then used in the next preview, recording or playback.

Install and register the third-party filter

In the following steps, the filter to use is named "myfilter.ax".

Third-party filter registered from the command line

  1. Copy the myfilter.ax file into the windows\system32 or winnt\system32 directory.
  2. Click on "Start", "Run", then enter the following command line:

    regsvr32 c:\windows\system32\myfilter.ax
    

Third-party filter registered programmatically

  1. Add the ComObj unit to the "uses" statement of the unit.
  2. Copy the myfilter.ax file into the windows\system32 or winnt\system32 directory (e.g. with CopyFile).
  3. Call:

    RegisterComServer ('c:\windows\system32\myfilter.ax');
    

Choose the location of the filter

Choose the location of the filter within the preview, recording or playback graph, according to the TThirdPartyFilterList locations. This location tells ThirdPartyFilter_AddToList where to place the filter in the audio or video graph.

Retrieve the CLSID of the filter

The CLSID of the filter is required. It can be found in the user guide of the filter, or retrieved from the registry as follows:

  1. Run regedit.
  2. In the menu bar, click "Edit".
  3. Click "Find".
  4. Enter the file name of the filter (e.g. myfilter.ax).
  5. Start searching.
  6. When the search stops, locate the CLSID of the filter and copy the GUID key. It must be passed as a string to the ThirdPartyFilter_AddToList function.

Add the filter to 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, give the direct file path of the filter .AX or .DLL file, so that the filter 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\myfilter.ax', 'my custom source filter', True, True) then begin
    ...
  end;
end;

Set the filter properties

The filter properties can be set:

  • either interactively with ThirdPartyFilter_ShowDialog; some filters may not show the dialog if no graph is running (preview, capture or playback),
  • or programmatically from the OnThirdPartyFilterConnected event, which returns the IUnknown interface of the filter when the graph starts.

The filters are now used automatically

The filter(s) are used automatically during the next preview, recording or 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

To use the third-party filter as a video source:

  1. Set VideoSource = vs_ThirdPartyFilter.
  2. Invoke:

    VideoGrabber1.ThirdPartyFilter_AddToList(tpf_ThirdPartyVideoSource, CLSID of the video third-party filter, '', '...any label...', True, True);
    
  3. Invoke StartPreview or StartRecording.

For the audio:

  • If this filter exposes an audio pin and AudioDeviceRendering or AudioRecording is enabled, the audio output is used as audio source if AudioSource = as_Default.
  • If the video filter does not expose an audio pin and audio is needed 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 also exposes 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

To use the third-party filter as an audio source:

  1. Set VideoSource = vs_ThirdPartyFilter.
  2. Invoke:

    VideoGrabber1.ThirdPartyFilter_AddToList(tpf_ThirdPartyAudioSource, CLSID of the third-party filter, '', '...any label...', True, True);
    
  3. Invoke StartAudioRendering or StartAudioRecording.

If the filter exposes an audio pin and AudioDeviceRendering or AudioRecording is enabled, the audio output is used as audio source if AudioSource = as_Default.