一直执行添加Filter的操作都是成功的,但不知道为什么到了添加ffdshow Video Decoder时就出错了,即添加不成功!希望高手帮忙解决下!
- C/C++ code
//添加Capture Filter hr = AddFilterByName(mGraph,CLSID_VideoInputDeviceCategory,wt,L"USB 视频设备",&pCap); if (FAILED(hr)) { AfxMessageBox("Can not add Capture Filter!"); return false; } //添加Infinite Pin Tee Filter IBaseFilter *pInfinitePinTee; hr = AddFilterByName(mGraph,CLSID_LegacyAmFilterCategory,L"Infinite Pin Tee Filter",L"Infinite Pin Tee Filter",&pInfinitePinTee); if (FAILED(hr)) { AfxMessageBox("Can not add Infinite Pin Tee Filter!"); return false; } //连接Capture Filter和Infinite Pin Tee Filter //获取Capture Filter的捕获引脚 IPin *pCaptureOut = NULL; pCaptureOut = GetOutPin(pCap,0); if (FAILED(hr)) { AfxMessageBox("Can not get Capture Filter capture Output pin!"); return false; } hr = ConnectFilters(mGraph,pCaptureOut,pInfinitePinTee); if (FAILED(hr)) { AfxMessageBox("Can not connect Capture Filter with Infinite Pin Tee Filter!"); return false; } //添加ffdshow Video Decoder Filter IBaseFilter *pffdshowVdeoDecoder; hr = AddFilterByName(mGraph,CLSID_LegacyAmFilterCategory,L"ffdshow Video Decoder",L"ffdshow Video Decoder",&pffdshowVdeoDecoder); if (FAILED(hr)) { AfxMessageBox("Can not add ffdshow Video Decoder Filter!"); return false; }
------解决方案--------------------------------------------------------
换成这样定义试试:
EXTERN_GUID(CLSID_FFDshowDecoder, { 0x04FE9017, 0xF873, 0x410E, 0x87, 0x1E, 0xAB, 0x91, 0x66, 0x1A, 0x4E, 0xF7);
另外,你贴出的地址里有答案连接:
http://forum.doom9.org/showthread.php?p=1019696#post1019696
EDIT : never mind, I found why. This is because visual studio (or my executable) is not in the supported applications inside FFDShow configuration
如果换了定义还是添加不成功,试着在FFDShow的配置里把使用的应用程序范围更改下。