我无法从我的网络摄像头录制视频。我尝试实现 VideoFileWriter 但不断收到错误“找不到指定的模块。(来自 HRESULT 的异常:0x8007007E)”。每当我注释掉视频编写器时,一切都很好,但是当尝试使用编写器将其记录到硬盘驱动器时,我得到了错误。我希望这是一个容易解决的问题。下面是我的代码。
private FilterInfoCollection VideoCaptureDevices;
private VideoCaptureDevice FinalVideoSource;
Bitmap image;
private VideoFileWriter writer;
void VideoShow()
{
VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
FinalVideoSource = new VideoCaptureDevice(VideoCaptureDevices[0].MonikerString);
FinalVideoSource.NewFrame += new NewFrameEventHandler(FinalVideoSource_NewFrame);
FinalVideoSource.DesiredFrameRate = 15;
FinalVideoSource.DesiredFrameSize = new Size(1280, 800);
FinalVideoSource.Start();
}
void FinalVideoSource_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
image = (Bitmap)eventArgs.Frame.Clone();
pictureBox1.Image = image;
writer.WriteVideoFrame(image);
}
public AForgeRecorder()
{
InitializeComponent();
}
private void btnStart_Click(object sender, EventArgs e)
{
writer = new VideoFileWriter();
VideoShow();
writer.Open(@"C:\testvvid.avi", 1280, 800, 15, VideoCodec.MPEG2, 128);
}
private void btnStop_Click(object sender, EventArgs e)
{
if (writer != null)
{
writer.Close();
}
}
提前致谢