graphBuilder = (IGraphBuilder)new FilterGraph();
//Create the Capture Graph Builder
ICaptureGraphBuilder2 captureGraphBuilder = null;
captureGraphBuilder = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();
//Create the media control for controlling the graph
mediaControl = (IMediaControl)this.graphBuilder;
// Attach the filter graph to the capture graph
int hr = captureGraphBuilder.SetFiltergraph(this.graphBuilder);
DsError.ThrowExceptionForHR(hr);
//Add the Video input device to the graph
hr = graphBuilder.AddFilter(theDevice, "source filter");
DsError.ThrowExceptionForHR(hr);
//Add the Video compressor filter to the graph
hr = graphBuilder.AddFilter(theCompressor, "compressor filter");
DsError.ThrowExceptionForHR(hr);
//////////// Smart Tee
IBaseFilter smartTeeFilter = (IBaseFilter)new SmartTee();
graphBuilder.AddFilter(smartTeeFilter, "Smart Tee");
IPin outPin = DsFindPin.ByDirection(theDevice, PinDirection.Output, 0);
IPin inPin = DsFindPin.ByDirection(smartTeeFilter, PinDirection.Input, 0);
graphBuilder.Connect(outPin, inPin);
/////
ISampleGrabber sampGrabber = new SampleGrabber() as ISampleGrabber;
IBaseFilter baseGrabFilter = sampGrabber as IBaseFilter;
graphBuilder.AddFilter(baseGrabFilter, "Grabber");
IPin sourcePin, grabPin;
sourcePin = DsFindPin.ByDirection(theDevice, PinDirection.Output, 0);
grabPin = DsFindPin.ByDirection(baseGrabFilter, PinDirection.Input, 0);
graphBuilder.Connect(sourcePin, grabPin);
graphBuilder.Render(DsFindPin.ByDirection(baseGrabFilter, PinDirection.Output, 0));
ConfigureSampleGrabber(sampGrabber);
hr = graphBuilder.AddFilter(baseGrabFilter, "Ds.NET Grabber");
DsError.ThrowExceptionForHR(hr);
////
SaveSizeInfo(sampGrabber);在这里,我得到一个题为“由于引脚没有连接而无法执行的操作”的错误。我的问题在哪里?!我试图添加一个覆盖文本到捕获的视频,然后保存它。如有任何建议,将不胜感激。
hr = captureGraphBuilder.RenderStream(null, null, smartTeeFilter, null, null);
DsError.ThrowExceptionForHR(hr);发布于 2014-01-14 21:19:27
像这样连接引脚:
FilterGraphTools.ConnectFilters(graphBuilder, inPin, outPin);https://stackoverflow.com/questions/21121958
复制相似问题