0

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?
Roman R.
  • 68,205
  • 6
  • 94
  • 158
damix911
  • 4,165
  • 1
  • 29
  • 44

2 Answers2

2

Which returns -2147220969

Which is 0x80040217 VFW_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).

My understanding is that AddSourceFilter can create a splitter transparently. Is it correct?

Yes if splitter is compatible with Async Reader, which is not the case.

If I want to do it manually, which component should I use?

Use GraphEdit to create topologies interactively and you will have an idea what to do on code.

Why the WMV video renders upside-down?

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.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
1

Use pGraphBuilder->AddSourceFilter() to add the source filter for a specific file. Don't assume that the File Source (Async) is the right source filter (for some formats, the source and demux are combined into a single filter).

Geraint Davies
  • 2,847
  • 15
  • 9