ICCompressEnd出错>>>>>

lwk6647 2008-10-29 08:30:33
系统有时会在运行到ICCompressEnd(m_Com.hic);时出错:XVIDCORE.DLL:0xc0000005:Access Violation
void CMyView::OnStartlu()
{
// TODO: Add your command handler code here

// CFileDialog FileDlg(FALSE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
// _T("图片文件(*.jpg;*.jpeg;*.gif;*.bmp)|*.jpg;*.jpeg;*.gif;*.bmp|位图文件(*.BMP)|*.BMP|JPEG文件(*.JPG)|*.JPG|GIF文件(*.GIF)|*.GIF||"));
CFileDialog FileDlg(FALSE,"avi");
if (FileDlg.DoModal()==IDOK)
{
filenamenewday = FileDlg.GetPathName();

capGetVideoFormat(hwndc,&m_InInfo,sizeof(m_InInfo));
m_Frame = 0 ;
//AVI文件初始化
AVIFileInit() ;
//设置压缩参数
InitCompress();
//打开文件
AVIFileOpen(&m_pFile,filenamenewday,OF_WRITE | OF_CREATE,NULL);
memset(&strhdr, 0, sizeof(strhdr)) ;
strhdr.fccType = streamtypeVIDEO;
strhdr.fccHandler = 0 ;
strhdr.dwScale = 1 ;
strhdr.dwRate = 15 ;
strhdr.dwSuggestedBufferSize = m_InInfo.bmiHeader.biSizeImage;
SetRect(&strhdr.rcFrame, 0, 0, m_InInfo.bmiHeader.biWidth,
m_InInfo.bmiHeader.biHeight);
ps = NULL;
//文件文件流
AVIFileCreateStream(m_pFile,&ps,&strhdr);
m_Captured = TRUE;//开始捕捉
capCaptureSequenceNoFile(hwndc);
}
//向添加InitCompress方法,设置压缩参数信息。
void CMyView::InitCompress()
{
capGetVideoFormat(hwndc,&m_InInfo ,sizeof(BITMAPINFO));
capGetVideoFormat(hwndc,&m_OutInfo,sizeof(BITMAPINFO));
memset(&m_Com,0,sizeof(COMPVARS));
m_Com.cbSize=sizeof(m_Com);
//利用代码选择压缩器
m_Com.dwFlags=ICMF_COMPVARS_VALID;
m_Com.fccHandler=mmioFOURCC('x','v','i','d');
m_Com.fccType=ICTYPE_VIDEO;
m_Com.lFrame=0;
m_Com.lKey=15;
m_Com.lKeyCount=0;
m_Com.lDataRate = 780;
m_Com.lpbiOut=(BITMAPINFO*)&m_OutInfo;
m_Com.hic= ICOpen(ICTYPE_VIDEO,mmioFOURCC('x','v','i','d'),ICMODE_COMPRESS);
m_Com.cbState = 1180;
//利用对话框选择压缩器
//ICCompressorChoose(NULL,ICMF_CHOOSE_ALLCOMPRESSORS ,
//(LPVOID)&m_InInfo,NULL,&m_Com,"选择压缩类型");
ICCompressGetFormat(m_Com.hic,&m_InInfo.bmiHeader,&m_OutInfo.bmiHeader);
//开始压缩
int ret = ICCompressBegin(m_Com.hic,(BITMAPINFO*)&m_InInfo,
(BITMAPINFO*)&m_OutInfo);
if (ret!=ICERR_OK )
MessageBox("压缩失败");
}
//结束录像
void CMyView::OnEndlu()
{
// TODO: Add your command handler code her
strroot2=filenamenewday;
int folderlen1=strroot2.ReverseFind('\\');
CString strPicFolder1=strroot2.Left(folderlen1+1);
//
tempfilename2=strroot2.Right(strroot2.GetLength()-strPicFolder1.GetLength());

//终止回调函数
capSetCallbackOnVideoStream(hwndc,NULL);
if(m_Com.hic!=NULL)
{
//结束数据压缩
ICCompressEnd(m_Com.hic);
//关闭压缩句柄
ICClose(m_Com.hic);
}
if (m_Captured)
{
m_Captured=FALSE;
selchg=TRUE;
selchg1=TRUE;
ifshow=TRUE;
CMainFrame* pmain50=(CMainFrame*)AfxGetMainWnd();
pmain50->ShowControlBar(&(pmain50->m_wndToolBar1),TRUE,TRUE);
//关闭AVI文件流

AVIStreamClose(ps);
if(m_pFile != NULL)
AVIFileRelease(m_pFile);
AVIFileExit();
}
}
...全文
58 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
lwk6647 2008-10-29
  • 打赏
  • 举报
回复

2,543

社区成员

发帖
与我相关
我的任务
社区描述
专题开发/技术/项目 多媒体/流媒体开发
社区管理员
  • 多媒体/流媒体开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧