處理“錄像”按鈕的單擊事件,代碼如下:
void CCaptureDlg::OnKinescope()
{
if(!m_Kinescope) //判斷是否錄像
{
if(CPreView::m_CurIndex != -1)
{
//創(chuàng)建文件保存對(duì)話框
CFileDialog fDlg(FALSE,"avi","avi_001",OFN_HIDEREADONLY
| OFN_OVERWRITEPROMPT,"AVI|*.avi",this);
if (fDlg.DoModal()==IDOK)
{
m_Kinescope = TRUE;
CString file = fDlg.GetPathName(); //獲得文件保存路徑
//設(shè)置MPEG壓縮的關(guān)鍵幀間隔,必須大于等于幀率
VCASetKeyFrmInterval(CPreView::m_CurIndex,250);
//設(shè)置MPEG壓縮的位率,范圍為56Kbps ~ 10Mbps
VCASetBitRate(CPreView::m_CurIndex,256);
//設(shè)置視頻捕獲幀率,bFrameRateReduction參數(shù)為保留參數(shù)
//PAL顯示幀率始終為25,NTSC顯示幀率始終為30
//PAL捕獲幀率最大為25,NTSC捕獲幀率最大為30
VCASetVidCapFrameRate(CPreView::m_CurIndex,25);
//設(shè)置視頻捕獲尺寸
VCASetVidCapSize(CPreView::m_CurIndex,320,240);
//設(shè)置MPEG4_XVID壓縮的質(zhì)量
VCASetXVIDQuality(CPreView::m_CurIndex,10,3);
//設(shè)置MPEG4_XVID壓縮模式
VCASetXVIDCompressMode(CPreView::m_CurIndex,XVID_VBR_MODE);
BOOL ret = VCAStartVideoCapture(CPreView::m_CurIndex,CAP_ORIGIN_MPEG4_STREAM,
MPEG4_AVIFILE_CALLBACK ,file); //開始視頻捕獲
GetDlgItem(IDC_KINESCOPE)->SetWindowText("停止錄像");
}
}
}
else
{
m_Kinescope = FALSE;
GetDlgItem(IDC_KINESCOPE)->SetWindowText("錄像");
VCAStopVideoCapture(CPreView::m_CurIndex); //停止視頻捕獲
}
}