C#屏幕录像机未合并音频

时间:2018-12-02 05:50:06

标签: c# audio screen-recording

我目前正在尝试使用C#制作屏幕录像机。现在,我拥有成功制作视频文件和音频文件的位置,但是我不知道如何合并它们。这是我到目前为止的内容:

public void Stop()
        {
            int width = bounds.Width;
            int height = bounds.Height;

            var framRate = 30;

            //Save audio:
            string audioPath = "save recsound " + outputPath + "\\mic.wav";
            record(audioPath, "", 0, 0);
            record("close recsound", "", 0, 0);

            using (var vFWriter = new VideoFileWriter())
            {
                //Create new video file:
                vFWriter.Open(outputPath + "//video.mp4", width, height, framRate, VideoCodec.MPEG4);

                //Make each screenshot into a video frame:
                foreach (var imageLocation in inputImageSequence)
                {
                    Bitmap imageFrame = System.Drawing.Image.FromFile(imageLocation) as Bitmap;
                    vFWriter.WriteVideoFrame(imageFrame);
                    imageFrame.Dispose();
                }

                //Add audio:
                byte[] audioByte = File.ReadAllBytes(outputPath + "\\mic.wav");
                vFWriter.WriteAudioFrame(audioByte);

                //Close:
                vFWriter.Close();
            }
            //Delete the screenshots and temporary folder:
            DeletePath(tempPath);
        }

我没有收到任何错误,但是音频没有添加到video.mp4中。任何帮助表示赞赏!

0 个答案:

没有答案