连接 IMPEG2DEMULTIPLEXER 和 ffdshow Directshow Filter
本质上我正在构建一个 HDV 捕获图。我的图表在图表生成器中运行并且运行良好。可以在此处查看图形生成器图形。在代码中,到目前为止的图表应该是 HDV Camera ->解复用器-> FFD秀。但我得到一个 VFW_E_NO_ACCEPTABLE_TYPES “这些引脚之间没有通用的媒体类型。”错误。我尝试在 mt 结构中使用不同的子媒体类型,但没有成功。
编辑以澄清: 错误在于连接多路复用器和 ffdshow 解码器。
相关代码(getPin枚举一个对象上的引脚并返回名为IPin的LPCOLESTR)
HRESULT hr = S_OK;
//graph builder
CComPtr<ICaptureGraphBuilder2> pBuilder;
hr = pBuilder.CoCreateInstance(CLSID_CaptureGraphBuilder2);
CHECK_HR(hr, "Can't Create Capture Graph Builder");
hr = pBuilder->SetFiltergraph(pGraph);
//add Canon XH A1S
CComPtr<IBaseFilter> pCanonXHA1S = GetCaptureDevice(CLSID_VideoInputDeviceCategory, L"Canon XH A1S");
hr = pGraph->AddFilter(pCanonXHA1S, L"Canon XH A1S");
CHECK_HR(hr, "Can't add Canon XH A1 to Graph");
//add MPEG-2 Demultiplexer
CComPtr<IBaseFilter> pMPEG2Demultiplexer;
hr = pMPEG2Demultiplexer.CoCreateInstance(CLSID_MPEG2Demultiplexer);
CHECK_HR(hr, "Can't create MPEG-2 Demultiplexer");
hr = pGraph->AddFilter(pMPEG2Demultiplexer, L"MPEG-2 Demultiplexer");
CHECK_HR(hr, "Can't add MPEG-2 Demultiplexer to graph");
//connect Canon XH A1S and MPEG-2 Demultiplexer
hr = pGraph->ConnectDirect(GetPin(pCanonXHA1S, L"MPEG2TS Out"), GetPin(pMPEG2Demultiplexer, L"MPEG-2 Stream"), NULL);
CHECK_HR(hr, "Can't connect Canon XH A1S and MPEG-2 Demultiplexer");
//This block configures the demultiplexer
IMpeg2Demultiplexer *pDemux;
IPin *pDemuxPin;
IMPEG2PIDMap *pPidMap;
AM_MEDIA_TYPE mt;
ZeroMemory(&mt, sizeof(AM_MEDIA_TYPE));
mt.majortype = MEDIATYPE_Video;
pMPEG2Demultiplexer->QueryInterface(IID_IMpeg2Demultiplexer, (void**)&pDemux);
if(hrcheck(hr, "Can't find MPEG2 Demux interface"))
return E_FAIL;
hr = pDemux->CreateOutputPin(&mt, L"MPEG2 Out", &pDemuxPin);
if(hrcheck(hr, "Can't create Output Pin on MPEG2 Demux"))
return E_FAIL;
hr = pDemuxPin->QueryInterface(IID_IMPEG2PIDMap, (void**)&pPidMap);
if(hrcheck(hr, "Can't create PIDMap"))
return E_FAIL;
// Assign PID 0x31 to pin 0. Set the type to "PES payload."
ULONG Pid = 0x30;
hr = pPidMap->MapPID(1, &Pid, MEDIA_ELEMENTARY_STREAM);
if(hrcheck(hr, "Problem mapping PID pins"))
return E_FAIL;
CComPtr<IBaseFilter> pFFDshowVideoDecoder;
hr = pFFDshowVideoDecoder.CoCreateInstance(CLSID_FFDshowVideoDecoder);
CHECK_HR(hr, "Can't create ffdshow Video Decoder");
hr = pGraph->AddFilter(pFFDshowVideoDecoder, L"ffdshow Video Decoder");
CHECK_HR(hr, "ffdshow Video Decoder");
hr = pGraph->ConnectDirect(pDemuxPin, GetPin(pFFDshowVideoDecoder, L"In"), &mt);
if(hrcheck(hr, "Problem with renderstream"))
return E_FAIL;
Essentially I am building a HDV capture graph. I have the graph functioning in graph builder and it works well. The graph builder graph can be seen here. In code the graph so far should go HDV Camera -> Demultiplexer -> FFDshow. But I get a VFW_E_NO_ACCEPTABLE_TYPES "There is no common media type between these pins." error. I have tried using different submedia types in the mt structure but no luck.
Edit to clarify:
the error is connecting the multiplexer and the ffdshow decoder.
Relevant code (getPin enumerates the pins on an object and returns the LPCOLESTR named IPin)
HRESULT hr = S_OK;
//graph builder
CComPtr<ICaptureGraphBuilder2> pBuilder;
hr = pBuilder.CoCreateInstance(CLSID_CaptureGraphBuilder2);
CHECK_HR(hr, "Can't Create Capture Graph Builder");
hr = pBuilder->SetFiltergraph(pGraph);
//add Canon XH A1S
CComPtr<IBaseFilter> pCanonXHA1S = GetCaptureDevice(CLSID_VideoInputDeviceCategory, L"Canon XH A1S");
hr = pGraph->AddFilter(pCanonXHA1S, L"Canon XH A1S");
CHECK_HR(hr, "Can't add Canon XH A1 to Graph");
//add MPEG-2 Demultiplexer
CComPtr<IBaseFilter> pMPEG2Demultiplexer;
hr = pMPEG2Demultiplexer.CoCreateInstance(CLSID_MPEG2Demultiplexer);
CHECK_HR(hr, "Can't create MPEG-2 Demultiplexer");
hr = pGraph->AddFilter(pMPEG2Demultiplexer, L"MPEG-2 Demultiplexer");
CHECK_HR(hr, "Can't add MPEG-2 Demultiplexer to graph");
//connect Canon XH A1S and MPEG-2 Demultiplexer
hr = pGraph->ConnectDirect(GetPin(pCanonXHA1S, L"MPEG2TS Out"), GetPin(pMPEG2Demultiplexer, L"MPEG-2 Stream"), NULL);
CHECK_HR(hr, "Can't connect Canon XH A1S and MPEG-2 Demultiplexer");
//This block configures the demultiplexer
IMpeg2Demultiplexer *pDemux;
IPin *pDemuxPin;
IMPEG2PIDMap *pPidMap;
AM_MEDIA_TYPE mt;
ZeroMemory(&mt, sizeof(AM_MEDIA_TYPE));
mt.majortype = MEDIATYPE_Video;
pMPEG2Demultiplexer->QueryInterface(IID_IMpeg2Demultiplexer, (void**)&pDemux);
if(hrcheck(hr, "Can't find MPEG2 Demux interface"))
return E_FAIL;
hr = pDemux->CreateOutputPin(&mt, L"MPEG2 Out", &pDemuxPin);
if(hrcheck(hr, "Can't create Output Pin on MPEG2 Demux"))
return E_FAIL;
hr = pDemuxPin->QueryInterface(IID_IMPEG2PIDMap, (void**)&pPidMap);
if(hrcheck(hr, "Can't create PIDMap"))
return E_FAIL;
// Assign PID 0x31 to pin 0. Set the type to "PES payload."
ULONG Pid = 0x30;
hr = pPidMap->MapPID(1, &Pid, MEDIA_ELEMENTARY_STREAM);
if(hrcheck(hr, "Problem mapping PID pins"))
return E_FAIL;
CComPtr<IBaseFilter> pFFDshowVideoDecoder;
hr = pFFDshowVideoDecoder.CoCreateInstance(CLSID_FFDshowVideoDecoder);
CHECK_HR(hr, "Can't create ffdshow Video Decoder");
hr = pGraph->AddFilter(pFFDshowVideoDecoder, L"ffdshow Video Decoder");
CHECK_HR(hr, "ffdshow Video Decoder");
hr = pGraph->ConnectDirect(pDemuxPin, GetPin(pFFDshowVideoDecoder, L"In"), &mt);
if(hrcheck(hr, "Problem with renderstream"))
return E_FAIL;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
发现问题出在创建时传递到输出引脚的 AM_MEDIA_TYPE 结构的声明中。我使用的结构:
The problem was found to be in the declaration of the AM_MEDIA_TYPE structure passed to the output pin on creation. The structure I used: