首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将samplegrabber文件保存到avi?

如何将samplegrabber文件保存到avi?
EN

Stack Overflow用户
提问于 2014-01-12 17:14:40
回答 1查看 296关注 0票数 0
代码语言:javascript
复制
 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 );

我把一些文本放到捕获的视频中,最后,我想把它保存到一个文件中。我该怎么做呢?如果我使用samplegrabber,我就不能使用capturegraph,反之亦然。有谁可以帮我?

EN

回答 1

Stack Overflow用户

发布于 2014-01-12 23:51:20

如果您想使用SampleGrabber来抓取帧,然后写入avi文件,则需要一个编解码器和一个库来写入avi文件。您可能需要自己搜索库或sdk。

然而,我建议不要使用SampleGrabber,而是使用T型过滤器。到第二个输出的三通连接编码器,和avi文件的写入器。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21073034

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档