2014-01-14 5 views
1
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); 

Здесь я получаю ошибку под названием «Операция не может быть выполнена, потому что контакты не подключены». Где моя проблема ?! Я пытаюсь добавить наложение текста в захваченное видео, а затем сохранить его. Любой совет будет оценен по достоинству.Я получаю сообщение об ошибке при использовании samplegrabber с smarttee

hr = captureGraphBuilder.RenderStream(null, null, smartTeeFilter, null, null); 
DsError.ThrowExceptionForHR(hr); 

ответ

1

Вы sourcePin и outPin переменные с одним штифтом точно. Таким образом, вы пытаетесь подключить штырь, который уже подключен.

0

Подключите контакты, как это:

FilterGraphTools.ConnectFilters(graphBuilder, inPin, outPin); 
Смежные вопросы