C# 如何将samplegrabber文件保存到avi?
我正在从我的网络摄像头捕获。我将一些文本放入捕获的视频中,最后,我想将其保存到一个文件中。我该怎么做? 我的项目是建立在DxText示例上的。C# 如何将samplegrabber文件保存到avi?,c#,video,avi,directshow.net,C#,Video,Avi,Directshow.net,我正在从我的网络摄像头捕获。我将一些文本放入捕获的视频中,最后,我想将其保存到一个文件中。我该怎么做? 我的项目是建立在DxText示例上的。 如果我使用samplegrabber,我不能使用capturegraph,反之亦然。有人能帮我吗?如果您想使用采样捕获器捕获帧,然后写入avi文件,则需要编解码器和库来写入avi文件。您可能需要自己搜索库或sdk 不过,我建议不要使用SampleGrabber,而是使用T形过滤器。将编码器和avi文件写入器连接到T形三通的第二个输出 谢谢,你的意思是我从
如果我使用samplegrabber,我不能使用capturegraph,反之亦然。有人能帮我吗?如果您想使用采样捕获器捕获帧,然后写入avi文件,则需要编解码器和库来写入avi文件。您可能需要自己搜索库或sdk
不过,我建议不要使用SampleGrabber,而是使用T形过滤器。将编码器和avi文件写入器连接到T形三通的第二个输出 谢谢,你的意思是我从我的网络摄像头中捕获视频,然后在上面放一些文字,然后,我使用编码器和avi文件编写器?我说的对吗?我不明白你想在上面加些文字。但是,是的,这也是可能的,然后你必须保留样本抓取器,并将球座放在它后面。另请参见DXLogo示例。
sampGrabber = new SampleGrabber() as ISampleGrabber;
capGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();
hr = m_FilterGraph.AddSourceFilterForMoniker(dev.Mon, null, dev.Name, out capFilter);
DsError.ThrowExceptionForHR(hr);
// Hopefully this will be the video pin
IPin iPinOutSource = DsFindPin.ByDirection(capFilter, PinDirection.Output, 0);
IBaseFilter baseGrabFlt = sampGrabber as IBaseFilter;
ConfigureSampleGrabber(sampGrabber);
iPinInFilter = DsFindPin.ByDirection(baseGrabFlt, PinDirection.Input, 0);
iPinOutFilter = DsFindPin.ByDirection(baseGrabFlt, PinDirection.Output, 0);
// Add the frame grabber to the graph
hr = m_FilterGraph.AddFilter( baseGrabFlt, "Ds.NET Grabber" );
DsError.ThrowExceptionForHR( hr );
hr = m_FilterGraph.Connect(iPinOutSource, iPinInFilter);
DsError.ThrowExceptionForHR( hr );
// Get the default video renderer
ibfRenderer = (IBaseFilter) new VideoRendererDefault();
// Add it to the graph
hr = m_FilterGraph.AddFilter( ibfRenderer, "Ds.NET VideoRendererDefault" );
DsError.ThrowExceptionForHR( hr );
iPinInDest = DsFindPin.ByDirection(ibfRenderer, PinDirection.Input, 0);
// Connect the graph. Many other filters automatically get added here
hr = m_FilterGraph.Connect(iPinOutFilter, iPinInDest);
DsError.ThrowExceptionForHR( hr );
SaveSizeInfo(sampGrabber);
// Set the output window
IVideoWindow videoWindow = m_FilterGraph as IVideoWindow;
hr = videoWindow.put_Owner( hWin.Handle );
DsError.ThrowExceptionForHR( hr );
hr = videoWindow.put_WindowStyle( WindowStyle.Child | WindowStyle.ClipChildren | WindowStyle.ClipSiblings );
DsError.ThrowExceptionForHR( hr );
hr = videoWindow.put_Visible( OABool.True );
DsError.ThrowExceptionForHR( hr );
Rectangle rc = hWin.ClientRectangle;
hr = videoWindow.SetWindowPosition( 0, 0, rc.Right, rc.Bottom );
DsError.ThrowExceptionForHR( hr );