现在我做的摄像头能保存录像了   就是太大了    几十秒就有好几百M 。 应该怎么办啊??? 请指点迷经啊!!!!namespace 摄像头on1
{
    public partial class Form1 : Form
    {
        private int hHwnd;
        private IntPtr lwndC;       //保存无符号句柄        public Form1()
        {
            InitializeComponent();
        }        public struct videohdr_tag
        {
            public byte[] lpData;
            public int dwBufferLength;
            public int dwBytesUsed;
            public int dwTimeCaptured;
            public int dwUser;
            public int dwFlags;
            public int[] dwReserved;        }
        public delegate bool CallBack(int hwnd, int lParam);
        ///   <summary>   
        ///   必需的设计器变量。   
        ///   </summary>   
        [DllImport("avicap32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        //创建视频捕捉窗口
        public static extern int capCreateCaptureWindowA([MarshalAs(UnmanagedType.VBByRefStr)]   ref   string lpszWindowName, int dwStyle, int x, int y, int nWidth, short nHeight, int hWndParent, int nID);
        [DllImport("avicap32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern bool capGetDriverDescriptionA(short wDriver, [MarshalAs(UnmanagedType.VBByRefStr)]   ref   string lpszName, int cbName, [MarshalAs(UnmanagedType.VBByRefStr)]   ref   string lpszVer, int cbVer);
        [DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern bool DestroyWindow(int hndw);        [DllImport("user32", EntryPoint = "SendMessageA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern int SendMessage(int hwnd, int wMsg, int wParam, [MarshalAs(UnmanagedType.AsAny)]   object lParam);
        [DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern int SetWindowPos(int hwnd, int hWndInsertAfter, int x, int y, int cx, int cy, int wFlags);
        [DllImport("vfw32.dll")]
        public static extern string capVideoStreamCallback(int hwnd, videohdr_tag videohdr_tag);
        [DllImport("vicap32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern bool capSetCallbackOnFrame(int hwnd, string s);        //用户向Windows系统发送消息机制(窗口句柄 要发送的消息  消息参数 消息参数)。
        [DllImport("User32.dll")]
        public static extern bool SendMessage(IntPtr hWnd, int wMsg, bool wParam, int lParam);
        [DllImport("User32.dll")]
        public static extern bool SendMessage(IntPtr hWnd, int wMsg, short wParam, int lParam);        private const int WM_USER = 0x400;
        private const int WS_CHILD = 0x40000000;
        private const int WS_VISIBLE = 0x10000000;
        private const int SWP_NOMOVE = 0x2;
        private const int SWP_NOZORDER = 0x4;
        private const int WM_CAP_START = WM_USER;
        private const int WM_CAP_STOP = WM_CAP_START + 68;
        private const int WM_CAP_SEQUENCE = WM_CAP_START + 62;
        private const int WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 20;        /// <summary>
        ///开始 录制
        /// </summary>
        /// <param name="path">保存路径</param>
        private void StarKinescope(string path)
        {
            //开始复制
            IntPtr hBmp = Marshal.StringToHGlobalAnsi(path);
            //( 窗口句柄 。
            SendMessage(hHwnd, WM_CAP_FILE_SET_CAPTURE_FILEA, 0, hBmp.ToInt32());
            SendMessage(hHwnd, WM_CAP_SEQUENCE, 0, 0);
        }
        /// <summary>
        /// 停止录制
        /// </summary>
        /// <param name="path"></param>
        public void StopKinescope()
        {
            SendMessage(lwndC, WM_CAP_STOP, 0, 0);
        }
        private void OpenCapture()
        {
            try
            {
                int intWidth = this.panel1.Width;
                int intHeight = this.panel1.Height;
                int intDevice = 0;
                string refDevice = intDevice.ToString();
                hHwnd = Form1.capCreateCaptureWindowA(ref   refDevice, 1342177280, 0, 0, 640, 480, this.panel1.Handle.ToInt32(), 0);
                if (Form1.SendMessage(hHwnd, 0x40a, intDevice, 0) > 0)
                {
                    Form1.SendMessage(this.hHwnd, 0x435, -1, 0);
                    Form1.SendMessage(this.hHwnd, 0x434, 0x42, 0);
                    Form1.SendMessage(this.hHwnd, 0x432, -1, 0);
                    Form1.SetWindowPos(this.hHwnd, 1, 0, 0, intWidth, intHeight, 6);
                }
                else
                {
                    Form1.DestroyWindow(this.hHwnd);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }       //开始录像
        private void button1_Click(object sender, EventArgs e)
        {
            this.button1.Enabled = false;
            this.button2.Enabled = true;
            this.button3.Enabled = true;
            //打开录像
          //  this.OpenCapture();
            StarKinescope(@"F:\新建文件夹\qq.MPG");
            MessageBox.Show("成功保存!");
        }
        //关闭录像
        private void button2_Click(object sender, EventArgs e)
        {
            this.button1.Enabled = true;
            this.button2.Enabled = false;
            this.button3.Enabled = false;
            Form1.SendMessage(this.hHwnd, 0x40b, 0, 0);
            Form1.DestroyWindow(this.hHwnd);   
        }
        //拍照
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                Form1.SendMessage(this.hHwnd, 0x41e, 0, 0);
                IDataObject obj1 = Clipboard.GetDataObject();
                if (obj1.GetDataPresent(typeof(Bitmap)))
                {
                    Image image1 = (Image)obj1.GetData(typeof(Bitmap));
                  //  image1.Save(@"C:\Documents and Settings\Administrator\桌面\aa.bmp");
                    image1.Save(@"F:\新建文件夹\aa.bmp");
                    MessageBox.Show("图像已经保存到桌面");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("截取头像失败,请联系管理员,错误原因为" + ex.ToString());
            }
        }        private void Form1_Load(object sender, EventArgs e)
        {
            this.button2.Enabled = false;
            this.button3.Enabled = false;        }