Recording using AForge's VideoFileWriter

0

I am having trouble recording a video from my webcam. I tried implementing the VideoFileWriter but keep getting the error "The specified module could not be found. (Exception from HRESULT: 0x8007007E)". Whenever i comment out the video writer everything works great but when attempting to record it to the hards drive using the writer the I get the error. I hope that this is a easy problem to solve. Below is the code i have.

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();
            }
        }

Thanks in advance

video
aforge

1 Answer

3

it's easy, Afrog VideoFileWriter used FFMPEG.dll, so download FFMPEG zip, copy all 5 dll from bin(avcodec-53.dll,.....etc), to your project, right clik on your project , click add existing reference, select all dll, make their propery as always copy, + you need .net 3.5 or less. so use lower frame work

answered on Stack Overflow Mar 22, 2014 by krp.eee

User contributions licensed under CC BY-SA 3.0