0

嘿,我正在尝试保存网络摄像头的视频并将其保存为未压缩的。但是,只要单击保存按钮,应用程序就会冻结,直到保存完成。我将不胜感激所提供的任何建议。我正在为网络摄像头“FLea 3”使用托管代码(来自点灰色)

    private void button1_Click(object sender, EventArgs e)
    {
       uint k_numImages = 100;
       // ManagedAVIRecorder aviRecorder = new ManagedAVIRecorder();
       // List<ManagedImage> imageList = new List<ManagedImage>();



            List<ManagedImage> imageList = new List<ManagedImage>();
            ManagedImage rawImage = new ManagedImage(m_rawImage);
           for (int imageCnt = 0; imageCnt < k_numImages; imageCnt++)
       // while (m_grabImages == true)
            {
                m_camera.RetrieveBuffer(rawImage);
                ManagedImage tempImage = new ManagedImage(rawImage);
                imageList.Add(tempImage);

             }


            if (m_grabImages==true)
            {
           //Encoding bit
            string aviFileName;



            AviOption option = new AviOption();
            option.frameRate = 24;
            aviFileName = String.Format("SaveCSharp-aviuncompressed");
            aviRecorder.AVIOpen(aviFileName, option);
           // aviFileName = String.Format("SaveCSharp-h264");
          //  H264Option option = new H264Option();
          //  option.frameRate = 24;
          //  option.bitrate = 20000000;
          //  option.height = Convert.ToInt32(m_rawImage.rows);
           // option.width = Convert.ToInt32(m_rawImage.cols);
         //   aviRecorder.AVIOpen(aviFileName, option);

         for (int imageCnt = 0; imageCnt < imageList.Count; imageCnt++)
                {
                    aviRecorder.AVIAppend(imageList[imageCnt]);



                }
             aviRecorder.AVIClose();
            }




        }

    private void button2_Click(object sender, EventArgs e)
    {
    //  aviRecorder.AVIClose();
    }
    }



   }
4

1 回答 1

2

您很可能希望在另一个线程上运行记录操作。但是,这会有点棘手,因为您必须将消息来回传递给记录器线程,例如告诉它何时停止。

于 2013-07-24T16:26:46.610 回答