简体   繁体   English

使用Directshow和C#录制视频时的文本叠加

[英]Text overlay when video is recording using Directshow and C#

By using DirectShowLib i can able to record the video by using ASF writter here is the code to start recording 通过使用DirectShowLib,我可以使用ASF writter录制视频,这里是开始录制的代码

 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);

Now i want to add an text overlay on the video when video is recoding and by using DirectshowLib is this posible? 现在,我想在对视频进行重新编码时在视频上添加文字叠加层,并且可以使用DirectshowLib吗?

For example when video recording get start video should get recorded with an text overlay. 例如,当开始录制视频时,应该使用文本覆盖来录制视频。

我在软件中通过将SampleGrabber过滤器插入到图形中的方式进行此SampleGrabber ,并在图片到达时将其转换为Bitmap对象,然后使用Graphics对其进行绘制。

Look at the DMO and DxLogo examples in the DirectShow.Net samples to do what your looking for. 查看DirectShow.Net示例中的DMO和DxLogo示例,以完成所需的工作。 what Daniel Mošmondor is explaining you can find in the DxSnap example... 您可以在DxSnap示例中找到DanielMošmondor解释的内容...

http://directshownet.sourceforge.net/ http://directshownet.sourceforge.net/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM