Capture a Type-2 DV File

 
Microsoft DirectShow 9.0

Capture a Type-2 DV File

A type-2 DV AVI file has two streams, one that contains DV video and another that contains audio. To capture a type-2 file while previewing, use the filter graph shown in the following diagram.

Type-2 Capture with Preview

This graph is almost the same as the graph for type-1 capture (see Capture a Type-1 DV File). However, the capture stream goes through the DV Splitter filter before reaching the AVI Mux filter. The AVI Mux therefore receives two streams, an audio stream and a DV-encoded video stream.

Build this graph as follows:

ICaptureGraphBuilder2 *pBuilder;  // Capture graph builder.
IBaseFilter           *pDV;       // DV capture filter (MSDV)
IBaseFilter           *pAviMux    // Avi Mux filter.
IBaseFilter           *pDVSplit;  // DV Splitter

// Initialize pDV (not shown). 
// Create and initialize the Capture Graph Builder (not shown).

// Create the DV Splitter and add it to the filter graph.
hr = CoCreateInstance(CLSID_DVSplitter, 0, CLSCTX_INPROC_SERVER,
    IID_IBaseFilter, reinterpret_cast<void**>)(&pDVSplit));
hr = pGraph->AddFilter(pDVSplit, L"DV Splitter");

// Create the file-writing section of the graph.
hr = pBuilder->SetOutputFileName(&MEDIASUBTYPE_Avi,
    OLESTR("C:\\Example2.avi"), &pAviMux, 0);

// Connect the capture pin to the DV Splitter, and render one stream from
// the DV Splitter to the AVI Mux. 
hr = pBuilder->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Interleaved, 
    pDV, pDVSplit, pAviMux);

// Render the other stream from the DV splitter to the AVI Mux.
hr = pBuilder->RenderStream(0, 0, pDVSplit, 0, pAviMux);

// Render the preview stream.
hr = pBuilder->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Interleaved, 
    pDV, 0, 0);

// Remember to release all interfaces.
  1. Create the DV Splitter and add it to the filter graph.
  2. Call ICaptureGraphBuilder2::SetOutputFileName to connect the AVI Mux filter to the File Writer filter.
  3. Call ICaptureGraphBuilder2::RenderStream to connect the MSDV capture filter to the DV Splitter. This call also connects one of the DV Splitter's output pins to the AVI Mux.
  4. Call RenderStream again to connect the DV Splitter's other pin to the AVI Mux.
  5. Call RenderStream a third time to render the preview stream. Skip this step if do not want to preview the video.

See Also