0

我无法从我的网络摄像头录制视频。我尝试实现 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();
            }
        }

提前致谢

4

1 回答 1

2

很简单,Afrog VideoFileWriter 使用了 FFMPEG.dll,所以下载 FFMPEG zip,将所有 5 个 dll 从 bin(avcodec-53.dll,.....etc) 复制到您的项目中,右键单击您的项目,单击添加现有引用,选择所有 dll,像往常一样复制它们的属性,+ 你需要 .net 3.5 或更低版本。所以使用较低的框架工作

于 2014-03-22T16:54:46.750 回答