我目前正在尝试使用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
中。任何帮助表示赞赏!