求助x264vfw !!!

lunat 2010-09-15 10:06:09
x264vfw.dll和avcodec.dll等等几个都已经安装成功,用ICInfo也可以正确得到x264编码器信息。

下面是我使用的代码:

ZeroMemory(&m_AviStreamInfo,sizeof(AVISTREAMINFO));
m_AviStreamInfo.fccType = streamtypeVIDEO;
m_AviStreamInfo.fccHandler = 0;//m_dwFCCHandler;
m_AviStreamInfo.dwScale = 1;
m_AviStreamInfo.dwRate = m_dwFrameRate; // Frames Per Second;
m_AviStreamInfo.dwQuality = -1; // Default Quality
m_AviStreamInfo.dwSuggestedBufferSize = nMaxWidth*nMaxHeight*4;
SetRect(&m_AviStreamInfo.rcFrame, 0, 0, nFrameWidth, nFrameHeight);
_tcscpy(m_AviStreamInfo.szName, _T("Video Stream"));

if(FAILED(AVIFileCreateStream(m_pAviFile,&m_pAviStream,&m_AviStreamInfo)))
{
SetErrorMessage(_T("Unable to Create Video Stream in the Movie File"));
return E_FAIL;
}


ZeroMemory(&m_AviCompressOptions,sizeof(AVICOMPRESSOPTIONS));
m_AviCompressOptions.fccType=streamtypeVIDEO;
m_AviCompressOptions.fccHandler= mmioFOURCC('X','2','6','4');//m_dwFCCHandler;
m_AviCompressOptions.dwFlags=AVICOMPRESSF_KEYFRAMES | AVICOMPRESSF_VALID;//|AVICOMPRESSF_DATARATE;
m_AviCompressOptions.dwKeyFrameEvery=1;
m_AviCompressOptions.cbParms = 0x000001d0;
//m_AviCompressOptions.dwBytesPerSecond=1000/8;
//m_AviCompressOptions.dwQuality=100;


if(FAILED(AVIMakeCompressedStream(&m_pAviCompressedStream,m_pAviStream,&m_AviCompressOptions,NULL)))
{
// One reason this error might occur is if you are using a Codec that is not
// available on your system. Check the mmioFOURCC() code you are using and make
// sure you have that codec installed properly on your machine.
SetErrorMessage(_T("Unable to Create Compressed Stream: Check your CODEC options"));
return E_FAIL;
}

BITMAPINFO bmpInfo;
ZeroMemory(&bmpInfo,sizeof(BITMAPINFO));
bmpInfo.bmiHeader.biPlanes = 1;
bmpInfo.bmiHeader.biWidth = nFrameWidth;
bmpInfo.bmiHeader.biHeight = nFrameHeight;
bmpInfo.bmiHeader.biCompression = BI_RGB;
bmpInfo.bmiHeader.biBitCount = nBitsPerPixel;
bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmpInfo.bmiHeader.biSizeImage = bmpInfo.bmiHeader.biWidth*bmpInfo.bmiHeader.biHeight*bmpInfo.bmiHeader.biBitCount/8;
bmpInfo.bmiHeader.biXPelsPerMeter = 15;
bmpInfo.bmiHeader.biYPelsPerMeter = 15;

COMPVARS cv = {0};

cv.cbSize = sizeof(cv);

HRESULT hr = AVIStreamSetFormat(m_pAviCompressedStream,0,(LPVOID)&bmpInfo, bmpInfo.bmiHeader.biSize);

if(FAILED(hr))
{
// One reason this error might occur is if your bitmap does not meet the Codec requirements.
// For example,
// your bitmap is 32bpp while the Codec supports only 16 or 24 bpp; Or
// your bitmap is 274 * 258 size, while the Codec supports only sizes that are powers of 2; etc...
// Possible solution to avoid this is: make your bitmap suit the codec requirements,
// or Choose a codec that is suitable for your bitmap.
SetErrorMessage(_T("Unable to Set Video Stream Format"));
return E_FAIL;
}


结果运行到 AVIStreamSetFormat 时,总是返回 0x80044068 AVIERR_INTERNAL错误,各位老大有没有知道是怎么回事的?
...全文
273 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yjgx007 2012-07-16
  • 打赏
  • 举报
回复
http://forum.doom9.org/archive/index.php/t-110524.html

see last reply,

the X and Y sizes of the AVI are multiples of 2. Its a real pain that the XVID codec now enforces this, but it can be dealt with.
dengzikun 2010-09-15
  • 打赏
  • 举报
回复
建议放弃VFW接口,可以考虑DSHOW.

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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