24,854
社区成员
发帖
与我相关
我的任务
分享
// 创建AVI文件
hr = AVIFileOpen(&m_pFile, // returned file pointer
dlg.GetPathName(), // file name
OF_WRITE | OF_CREATE, // mode to open file with
NULL); // use handler determined
// from file extension....
if (hr != AVIERR_OK)
{
AfxMessageBox( _T("AVIFileOpen Error 1!") );
return;
}
AVISTREAMINFO strhdr; //AVI文件信息
memset(&strhdr, 0, sizeof(strhdr));
strhdr.fccType = streamtypeVIDEO;// stream type
strhdr.fccHandler = 0;
strhdr.dwScale = 1;
strhdr.dwRate = 15; // rate fps
strhdr.dwSuggestedBufferSize = Width * Height * 3;
SetRect(&strhdr.rcFrame, 0, 0, Width, Height);// rectangle for stream
// And create the stream;
hr = AVIFileCreateStream(m_pFile, // file pointer
&m_ps, // returned stream pointer
&strhdr); // stream header
if (hr != AVIERR_OK)
{
AfxMessageBox( _T("AVIFileCreateStream Error 1!") );
return;
}
AVICOMPRESSOPTIONS opts;
AVICOMPRESSOPTIONS FAR * aopts[1] = {&opts};
memset(&opts, 0, sizeof(opts));
if (!AVISaveOptions(NULL, ICMF_CHOOSE_PREVIEW, 1, &m_ps, (LPAVICOMPRESSOPTIONS FAR *) &aopts))
{
AfxMessageBox( _T("AVISaveOptions Error 1!") );
return;
}
hr = AVIMakeCompressedStream(&m_psCompressed, m_ps, &opts, NULL);
if (hr != AVIERR_OK)
{
AfxMessageBox( _T("AVIMakeCompressedStream Error 1!") );
return;
}
hr = AVIStreamSetFormat(m_psCompressed,
0,
m_pBmpInfo, // stream format
sizeof(BITMAPINFOHEADER) // format size
);
if (hr != AVIERR_OK)
{
AfxMessageBox( _T("AVIStreamSetFormat Error 1!") );
return;
}