嘿,我正在尝试保存网络摄像头的视频并将其保存为未压缩的。但是,只要单击保存按钮,应用程序就会冻结,直到保存完成。我将不胜感激所提供的任何建议。我正在为网络摄像头“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();
}
}
}