16,470
社区成员
发帖
与我相关
我的任务
分享
HRESULT ret =NULL;
IPin * pSourceOut = NULL;
IPin* pCompressIn,* pCompressOut;
pCompressIn = FindPin(pCompress,PINDIR_INPUT) ;
pCompressOut = FindPin(pCompress,PINDIR_OUTPUT);
IAMVideoCompression * pAMCompress = NULL;
IAMStreamConfig *pStreamConfig = NULL;
AM_MEDIA_TYPE *pmt;
m_pCapture->FindInterface(NULL,NULL,m_pBF,IID_IAMStreamConfig,(void**)&pStreamConfig);
pStreamConfig-> GetFormat(&pmt);
if (pmt-> formattype == FORMAT_VideoInfo)
{
((VIDEOINFOHEADER *)(pmt-> pbFormat))-> dwBitRate = 20000;
pStreamConfig-> SetFormat(pmt);
}
FreeMediaType(*pmt);
pStreamConfig-> QueryInterface(IID_IAMVideoCompression, (void **)&pAMCompress);
pCompressOut->QueryInterface(IID_IAMVideoCompression,(void**)&pAMCompress);
HRESULT hret;
hret = pAMCompress->put_KeyFrameRate(10);
// hret = pAMCompress->put_Quality(1.0);
pStreamConfig-> Release();
pAMCompress->Release();
IAMVideoCompression * pAMCompress = NULL; //压缩参数设置
IAMStreamConfig *pStreamConfig = NULL; //压缩参数设置
AM_MEDIA_TYPE mt;
ZeroMemory(&mt, sizeof(AM_MEDIA_TYPE));
mt.majortype = MEDIATYPE_Video;
mt.subtype = MEDIASUBTYPE_RGB24;
hr = m_pGrabber->SetMediaType(&mt);
m_pCapture->FindInterface(&PIN_CATEGORY_CAPTURE,&MEDIATYPE_Video,m_pBF,IID_IAMStreamConfig,(void**)&pStreamConfig);
//设置自己的视频格式
AM_MEDIA_TYPE * pMediaType = NULL;
hr = pStreamConfig->GetFormat(&pMediaType);
VIDEOINFOHEADER * pvih = (VIDEOINFOHEADER*) pMediaType->pbFormat;//这个视频好像是16位的
pvih->bmiHeader.biBitCount = 24;
pvih->bmiHeader.biWidth= IMAGE_WIDTH ; //修改采集视频的宽为176
pvih->bmiHeader.biHeight= IMAGE_HEIGHT ; //修改采集视频的高为144
pvih->bmiHeader.biSizeImage = IMAGE_WIDTH * IMAGE_HEIGHT *3 ;
pMediaType->lSampleSize = pvih->bmiHeader.biSizeImage;
pMediaType->pbFormat = (BYTE*) pvih;
pStreamConfig->SetFormat(pMediaType); //重新设置参数
pCompressIn = FindPin(pCompress,PINDIR_INPUT) ; //查找输入引脚
pCompressOut = FindPin(pCompress,PINDIR_OUTPUT); //查找输出引脚
pStreamConfig-> QueryInterface(IID_IAMVideoCompression, (void **)&pAMCompress);
pCompressOut->QueryInterface(IID_IAMVideoCompression,(void**)&pAMCompress);
HRESULT hret;
hret = pAMCompress->put_KeyFrameRate(10);
// hret = pAMCompress->put_Quality(1.0);
pStreamConfig-> Release();
pAMCompress->Release();
pEnumCat->Release();
pMoniker->Release();
m_pGB->AddFilter(pCompress,L"Compressor"); //添加过滤器
HRESULT ret =NULL;
IPin * pSourceOut = NULL;
IPin* pCompressIn,* pCompressOut;
IAMVideoCompression * pAMCompress = NULL; //压缩参数设置
IAMStreamConfig *pStreamConfig = NULL; //压缩参数设置
AM_MEDIA_TYPE *pmt;
m_pCapture->FindInterface(NULL,NULL,m_pBF,IID_IAMStreamConfig,(void**)&pStreamConfig);
pStreamConfig-> GetFormat(&pmt);
if (pmt-> formattype == FORMAT_VideoInfo)
{
((VIDEOINFOHEADER *)(pmt-> pbFormat))-> dwBitRate = 9000000;
pStreamConfig-> SetFormat(pmt);
}
pCompressIn = FindPin(pCompress,PINDIR_INPUT) ; //查找输入引脚
pCompressOut = FindPin(pCompress,PINDIR_OUTPUT); //查找输出引脚
FreeMediaType(*pmt);
pStreamConfig-> QueryInterface(IID_IAMVideoCompression, (void **)&pAMCompress);
pCompressOut->QueryInterface(IID_IAMVideoCompression,(void**)&pAMCompress);
HRESULT hret;
hret = pAMCompress->put_KeyFrameRate(10);
// hret = pAMCompress->put_Quality(1.0);
pStreamConfig-> Release();
pAMCompress->Release();