I want to use PushSource
filter to capture but I need to "connect" it to "videocap" sample. This filter is not a standalone filter, so it can't be enumerated as capture device, also I dont want it to convert like that
Asked
Active
Viewed 1,272 times
0

John Smith
- 6,129
- 12
- 68
- 123
-
I use DSPack a lot. Can you be more specific? Are you trying to capture still images? – Celal Ergün Apr 15 '12 at 13:16
-
I try to capture video. (PushSourceDesktop) I tried it with GraphEdit and it worked, its just not a filter to connect, but I know there are methods to include filters into your own application instead of registering with filesystem. – John Smith Apr 15 '12 at 13:19
-
similar like this topic http://stackoverflow.com/questions/3560855/how-to-use-install-custom-directshow-filter I just no idea how to include it... – John Smith Apr 15 '12 at 13:23
1 Answers
2
Well, I use Nvidia Encoder Filter that does not show up in GraphEdit. To do that I just define the GUID:
Const
CLSID_NVIDIA_VideoEncoderFilter : TGUID = '{B63E31D0-87B5-477f-B224-4A35B6BECED6}';
Then I create the filter in memory like that:
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;
Also you can see this "hidden" filter in your GraphEdit now.
Edit: Here is the code that I link filters. It searches for every pin that may be connected to the next filter. This code connects audio out pins to audio in pins and video out pins to video in pins etc. It is very flexible.
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;
Now you can use this method with your filters as in the following code
Var
SourceFilter, DestFilter: IBaseFilter;
Builder: IGraphBuilder;
Begin
SourceFilter := SrcFilter As IBaseFilter;
DestFilter := DstFilter As IBaseFilter;
Builder := FilterGraph As IGraphBuilder;
Connect(Builder, SourceFilter, DestFilter);
End;
Hope this helps. We were all newbies once ;)

Celal Ergün
- 955
- 2
- 14
- 30
-
thanx for the answers for now. Could you detail the "connect to any filter" part? :) I have no idea how to connect it to VideoSourceFilter component... or what to – John Smith Apr 15 '12 at 14:07
-
1Sure. I use to encrypt the video and then connect this filter to a "MatroskaMuxer" filter that I create, then connect it to a file writer filter and I have a graph that records H264 encoded video into a Matroska file. Use IGraphBuilder's Connect method to connect pins. Hint: GraphBuilder := FilterGraph1 As IGraphBuilder; – Celal Ergün Apr 15 '12 at 14:14
-
-
1Add a new filter to your form (or create it with CoCreateInstance, doesn't matter), double click and select AVI Mux from DirectShow filters. Add another filter and double click it, select File Writer, set file name. Set their filter graph property (probably FilterGraph1). This will create an AVI file. For streaming media, you can use ASFWriter component of DSPack. Check this out: http://www.vwlowen.co.uk/directshow/asfwriter/page02.htm – Celal Ergün Apr 16 '12 at 12:03