[问题] directshow GetFormat SetFormat

楼主: liang168 (小强)   2015-02-22 20:57:17
开发平台(Platform): (Ex: VC++, GCC, Linux, ...)
vc6 windowsXP
额外使用到的函数库(Library Used): (Ex: OpenGL, ...)
Directshow
问题(Question):
设定输出usb camera分辨率正确流程?
己知先用 GetFormat 读入目前 usb camera 设定分辨率
修改过后再用SetFormat 写入设定
但是测试发现分辨率变成最小,不知问题在那里
只要求改默认输出分辨率
程式码(Code):(请善用置底文网页, 记得排版)
IAMStreamConfig *pVSC;
hr =
g_pCapture->FindInterface(&PIN_CATEGORY_CAPTURE,&MEDIATYPE_Video,m_pVidDeviceFilter,IID_IAMStreamConfig,(void
**)&pVSC);
if(FAILED(hr))
{
printf("Findinterface error \n");
return -1;
}
AM_MEDIA_TYPE *aMediaType ;
pVSC->GetFormat(&aMediaType);
VIDEOINFOHEADER *vih = (VIDEOINFOHEADER*)aMediaType->pbFormat;
AM_MEDIA_TYPE *out_set = aMediaType ;
VIDEOINFOHEADER *pOut_set =(VIDEOINFOHEADER*)out_set->pbFormat;
pOut_set->bmiHeader.biWidth = 1280;
pOut_set->bmiHeader.biHeight = 720;
out_set->pbFormat = (unsigned char *)pOut_set;
pVSC->SetFormat(out_set);
补充说明(Supplement):
作者: LiloHuang (十年一刻)   2015-02-24 20:31:00
HRESULT hr = pVSC->SetFormat(...) 请看一下 hr 的值
楼主: liang168 (小强)   2015-02-25 21:26:00
测试过回传值是正常
作者: LiloHuang (十年一刻)   2015-02-25 22:17:00
你是在 filter pin 脚接起来前设定的,还是之后设定的?
作者: lf5471 (lf)   2015-02-26 00:23:00
在 SetFormat 前使用 GetStreamCaps ?改 GetStreamCaps 回传的 W&H, 再丢到 SetFormat ?
楼主: liang168 (小强)   2015-02-27 18:25:00
在getdevice之后addfilter之前加入这段程式getstreamcaps 没用过正在看如何使用 谢谢
作者: LiloHuang (十年一刻)   2015-02-28 22:10:00
应该在 AddFilter 之后,接起 Output Pin 之前设定。

Links booklink

Contact Us: admin [ a t ] ucptt.com