如何将视频帧和音频信号合并到单个流[Accord]?

时间:2018-01-07 13:31:19

标签: c# .net accord.net

我使用Accord框架捕获视频和音频。

           //accord video
            videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString);
            videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);

            //accord audio
            // Create default capture device
            audioSource = new AudioCaptureDevice();
            // Specify capturing options
            audioSource.DesiredFrameSize = 4096;
            audioSource.SampleRate = 22050;

            audioSource.NewFrame += audioSource_NewFrame;



        // capture audio frame
        private void audioSource_NewFrame(object sender, Accord.Audio.NewFrameEventArgs eventArgs)
        {
            // Read current frame...
            Signal s = eventArgs.Signal;
        }

        private void video_NewFrame(object sender, Accord.Video.NewFrameEventArgs eventArgs)
        {
            // get new frame
            Bitmap bitmap = eventArgs.Frame;

        }

现在我可以通过两个不同的事件audioSource_NewFramevideo_NewFrame来捕捉视频和音频。

我想将视频帧和音频合并到单个对象中进行视频通话,我可以知道这样做的方法吗?

1 个答案:

答案 0 :(得分:0)

You have to use VideoFileWriter class instance in both methods.

Here is for Audio:

_videoWriter.WriteAudioFrame(e.Signal);

And here is for Video:

_videoWriter.WriteVideoFrame(bitmap, offset);