Windows Dev Center

Building a VMR-9 Filter Graph

Because the Video Mixing Renderer 9 Filter (VMR-9) is not the default video renderer, an application that uses the VMR-9 must explicitly add it to the graph and connect it. This section presents two different approaches to building filter graphs with the VMR-9.

Using the Capture Graph Builder

The Capture Graph Builder is a helper object for building custom filter graphs. You can use it to build VMR-9 graphs as follows:

  1. Create and initialize the Capture Graph Builder, as described in the topic About the Capture Graph Builder.
  2. Call CoCreateInstance to create the VMR-9:
    
    
    IBaseFilter *pVmr = NULL;
    hr = CoCreateInstance(CLSID_VideoMixingRenderer9, 0, 
        CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pVmr);
    
    
    
  3. Call IFilterGraph::AddFilter on the Filter Graph Manager to add the VMR-9 to the filter graph:
    
    
    hr = pGraph->AddFilter(pVmr, L"VMR9");
    
    
    
  4. Call IGraphBuilder::AddSourceFilter to add a source filter for the video file:
    
    
    IBaseFilter *pSource;
    hr = pGraph->AddSourceFilter(L"C:\\Example.avi", L"Source1", &pSource);
    
    
    
  5. Call the ICaptureGraphBuilder2::RenderStream method to render the video stream to the VMR:
    
    
    hr = pBuild->RenderStream(0, 0, pSource, 0, pVmr);  
    
    
    
  6. Optionally, call RenderStream again to render the audio stream:
    
    
    hr = pBuild->RenderStream(0, &MEDIATYPE_Audio, pSource, 0, NULL);
    
    
    

You can mix several video streams by calling AddSourceFilter and RenderStream for each source file.

Using the Filter Graph Manager

If you prefer not to use the Capture Graph Builder, you can build a VMR-9 graph simply using methods on the Filter Graph Manager, as follows:

  1. Create the VMR-9 and add it to the graph, as shown in the previous procedure.
  2. Use AddSourceFilter to add a source filter for the video file, as shown in the previous procedure.
  3. If you want to render the audio, create an instance of the DirectSound Renderer filter and add it to the filter graph.
  4. Use the IBaseFilter::EnumPins method to find an output pin on the source filter. See Enumerating Pins for details.
  5. Query the Filter Graph Manager for the IFilterGraph2 interface.
  6. Call IFilterGraph2::RenderEx with the AM_RENDEREX_RENDERTOEXISTINGRENDERERS flag. This call renders the output pin, using only the renderer filters already in the graph — in this case, the VMR-9 and the DirectSound Renderer. This prevents the Intelligent Connect logic from adding the default video renderer to the graph, which would leave the VMR-9 unconnected.

Related topics

Building Graphs with the Capture Graph Builder

 

 

Community Additions

ADD
Show:
© 2015 Microsoft