简体   繁体   中英

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

 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?

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. what Daniel Mošmondor is explaining you can find in the DxSnap example...

http://directshownet.sourceforge.net/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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