我想使用PushSource
过滤器进行捕获,但我需要将其“连接”到“videocap”示例。这个过滤器不是一个独立的过滤器,所以它不能被枚举为捕获设备,我也不希望它像那样转换
答案 0 :(得分:2)
好吧,我使用的是未在GraphEdit中显示的Nvidia编码器过滤器。为此,我只需定义GUID:
Const
CLSID_NVIDIA_VideoEncoderFilter : TGUID = '{B63E31D0-87B5-477f-B224-4A35B6BECED6}';
然后我在内存中创建过滤器:
Var
N: IBaseFilter;
begin
CoCreateInstance(CLSID_NVIDIA_VideoEncoderFilter, Nil, CLSCTX_INPROC_SERVER, IID_IBaseFilter, N);
if Assigned(N) then
Begin
// connect to any filter that you can use in your system
End;
此外,您现在可以在GraphEdit中看到这个“隐藏”过滤器。
编辑:这是我链接过滤器的代码。它搜索可能连接到下一个过滤器的每个引脚。此代码将音频输出引脚与引脚和视频输出引脚中的音频连接到引脚等视频。它非常灵活。
Procedure Connect(Builder: IGraphBuilder; SourceFilter, DestFilter: IBaseFilter);
Var
SourceEnum, DestEnum: IEnumPins;
SourcePin, DestPin: IPin;
FI: _FilterInfo;
S, D: String;
Begin
SourceFilter.QueryFilterInfo(FI);
S := FI.achName;
DestFilter.QueryFilterInfo(FI);
D := FI.achName;
SourceFilter.EnumPins(SourceEnum);
DestFilter.EnumPins(DestEnum);
DestEnum.Reset;
While DestEnum.Next(1, DestPin, Nil) = S_OK Do
Begin
SourceEnum.Reset;
While SourceEnum.Next(1, SourcePin, Nil) = S_OK Do
If Builder.Connect(SourcePin, DestPin) = S_OK Then
Begin
SourceEnum := Nil;
DestEnum := Nil;
SourcePin := Nil;
DestPin := Nil;
Exit;
End;
End;
SourceEnum := Nil;
DestEnum := Nil;
SourcePin := Nil;
DestPin := Nil;
Raise Exception.Create(Format('There is no pin from %s to connect to %d', [S, D]));
End;
现在,您可以将此方法与过滤器一起使用,如以下代码
Var
SourceFilter, DestFilter: IBaseFilter;
Builder: IGraphBuilder;
Begin
SourceFilter := SrcFilter As IBaseFilter;
DestFilter := DstFilter As IBaseFilter;
Builder := FilterGraph As IGraphBuilder;
Connect(Builder, SourceFilter, DestFilter);
End;
希望这会有所帮助。我们都是新手一次;)