hello,
I am trying to record video by aviwriter class in aforge but the resulting avi file is either 0Kb or the whole video is viewing only one picture

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AForge.Video;
using AForge.Video.DirectShow;
using AForge.Video.FFMPEG;
using AForge.Video.VFW;
using System.IO;
namespace WindowsFormsApplication12
{
    public partial class Form1 : Form
    {
        private FilterInfoCollection videocapturedevices;
        private VideoCaptureDevice finalvideo;
        public Form1()
        {
            InitializeComponent();
        }
        private void pictureBox1_Click(object sender, EventArgs e)
        {
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            videocapturedevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            foreach (FilterInfo VideoCaptureDevice in videocapturedevices)
            {
                comboBox1.Items.Add(VideoCaptureDevice.Name);
            }
            comboBox1.SelectedIndex = 0;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            finalvideo = new VideoCaptureDevice(videocapturedevices[comboBox1.SelectedIndex].MonikerString);
            finalvideo.NewFrame+=new NewFrameEventHandler(finalvideo_NewFrame);
            finalvideo.Start();
        }
        void finalvideo_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            //FilterInfoCollection x = new FilterInfoCollection(FilterCategory.VideoCompressorCategory);
            //foreach (FilterInfo y in x)
            //{
            //    MessageBox.Show(y.Name);
            //}
            Bitmap video = (Bitmap)eventArgs.Frame.Clone();
            //MessageBox.Show(video.Width.ToString());
            //MessageBox.Show(video.Height.ToString());
            pictureBox1.Image = video;
            // instantiate AVI writer, use WMV3 codec
            AVIWriter writer = new AVIWriter("DivX");
            // create new AVI file and open it
            writer.Open("test1.avi", 640, 480);
            // create frame image
            for (int i = 0; i < 576; i++)
            {
                // update image
                // add the image as a new frame of video file
                writer.AddFrame(video);
            }
            writer.Close();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            if (finalvideo.IsRunning)
            {
                finalvideo.Stop();
            }
            this.Close();
        }
    }
}

can u help me?

Why wouldn't you ask on the AForge forums?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.