The following code is good at rendering an MPG file without audio:
IBaseFilter *pRenderer;
CoCreateInstance(CLSID_VideoRenderer, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pRenderer)));
IFileSourceFilter *pSourceFilter;
IBaseFilter *pBaseFilter;
CoCreateInstance(CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pSourceFilter));
pSourceFilter->QueryInterface(IID_PPV_ARGS(&pBaseFilter));
pGraphBuilder->AddFilter(pRenderer, L"Renderer Filter");
pSourceFilter->Load(filename, NULL);
pGraphBuilder->AddFilter(pBaseFilter, L"File Source Filter");
But fails with an WMV file with audio. The failure happens at the following call, when I connect the only output of the video source with the only input of the video renderer.
pGraphBuilder->Connect(pOutPin[0], pInPin[0])
Which returns -2147220969. If I replace the code above with the following:
IBaseFilter *pRenderer;
CoCreateInstance(CLSID_VideoRenderer, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pRenderer));
IBaseFilter *pBaseFilter;
pGraphBuilder->AddSourceFilter(filename, L"Renderer Filter", &pBaseFilter);
pGraphBuilder->AddFilter(pRenderer, L"Renderer Filter");
then the MPG plays fine with:
pGraphBuilder->Connect(pOutPin[0], pInPin[0])
while the WMV results in the same error as above, but instead it plays upside down with:
pGraphBuilder->Connect(pOutPin[1], pInPin[0])
All of this means that the second coding style creates a source with two output pins, and probably audio is mapped to the first one. Or, maybe, an A/V splitter is inserted automatically by DirectShow.
- My understanding is that AddSourceFilter can create a splitter transparently. Is it correct?
- If I want to do it manually, which component should I use?
- Why the WMV video renders upside-down?
Which is
0x80040217VFW_E_CANNOT_CONNECT"No combination of intermediate filters could be found to make the connection."which is the result of your manual adding
CLSID_AsyncReader: Windows Media files are typically rendered through another source filter (use GraphEdit from Windows SDK to render a file and you will be able to inspect the topology).Yes if splitter is compatible with Async Reader, which is not the case.
Use GraphEdit to create topologies interactively and you will have an idea what to do on code.
Because of the topology. Most likely you have a weird combination of filters on the pipeline, including third party ones. Inspecting effective topology is the key to resolve the problem.