0

通过使用 DirectShowLib,我可以使用 ASF 编写器来录制视频,这里是开始录制的代码

 try
        {
            IBaseFilter capFilter = null;
            IBaseFilter asfWriter = null;
            IFileSinkFilter pTmpSink = null;
            ICaptureGraphBuilder2 captureGraph = null;               
            GetVideoDevice();
            if (availableVideoInputDevices.Count > 0)
            {
                //
                //init capture graph
                //
                graphBuilder = (IFilterGraph2)new FilterGraph();
                captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();
                //
                //sets filter object from graph
                //
                captureGraph.SetFiltergraph(graphBuilder);
                //
                //which device will use graph setting
                //
                graphBuilder.AddSourceFilterForMoniker(AvailableVideoInputDevices.First().Mon, null, AvailableVideoInputDevices.First().Name, out capFilter);
                captureDeviceName = AvailableVideoInputDevices.First().Name;                    
                //
                //check saving path is exsist or not;if not then create
                //
                if (!Directory.Exists(ConstantHelper.RootDirectoryName + "\\Assets\\Video\\"))
                {
                    Directory.CreateDirectory(ConstantHelper.RootDirectoryName + "\\Assets\\Video\\");
                }
                #region WMV                   
                //
                //sets output file name,and file type
                //
                captureGraph.SetOutputFileName(MediaSubType.Asf, ConstantHelper.RootDirectoryName + "\\Assets\\Video\\" + videoFilename + ".wmv", out asfWriter, out pTmpSink);                    
                //
                //configure which video setting is used by graph
                //                
                IConfigAsfWriter lConfig = asfWriter as IConfigAsfWriter;
                Guid asfFilter = new Guid("8C45B4C7-4AEB-4f78-A5EC-88420B9DADEF");
                lConfig.ConfigureFilterUsingProfileGuid(asfFilter);
                #endregion
                //
                //render the stram to output file using graph setting
                //
                captureGraph.RenderStream(null, null, capFilter, null, asfWriter);
                m_mediaCtrl = graphBuilder as IMediaControl;
                m_mediaCtrl.Run();
                isVideoRecordingStarted = true;
                VideoStarted(m_mediaCtrl, null);

现在我想在视频重新编码时在视频上添加一个文本覆盖,并且通过使用 DirectshowLib 这可行吗?

例如,当视频录制开始时,视频应该与文本叠加一起录制。

4

2 回答 2

0

I'm doing it in my software in a way that SampleGrabber filter is inserted into a graph, and upon arrival of a picture, I convert it to Bitmap object, then draw on it with Graphics.

于 2012-06-02T17:08:33.073 回答
0

查看 DirectShow.Net 示例中的 DMO 和 DxLogo 示例来满足您的需求。Daniel Mošmondor 解释的内容可以在 DxSnap 示例中找到……

http://directshownet.sourceforge.net/

于 2012-10-06T20:29:15.240 回答