Capturing Video to a Windows Media File (Windows Embedded CE 6.0)

1/6/2010

To capture video and encode it to a Windows Media Video (WMV) file, connect the capture pin to the WM ASF Writer filter:

Ee496744.259e1c1e-94f7-4fd1-a934-0180c5f3f9d8(en-US,WinEmbedded.60).gif

You can build the above graph by specifying MEDIASUBTYPE_Asf in the ICaptureGraphBuilder2::SetOutputFileName method, as demonstrated in the following code.

IBaseFilter* pASFWriter = 0;
hr = pBuild->SetOutputFileName(
    &MEDIASUBTYPE_Asf,   // Create a Windows Media file.
    L"\\My Documents\VidCap.wmv",   // File name.
    &pASFWriter,         // Receives a pointer to the filter.
    NULL);  // Receives an IFileSinkFilter interface pointer (optional).

The value MEDIASUBTYPE_Asf tells the Capture Graph Builder to use the WM ASF Writer filter as the file sink. The Capture Graph Builder creates the filter, adds it to the graph, and calls IFileSinkFilter::SetFileName to set the name of the output file. It returns a pointer to the filter as an outgoing parameter (pASFWriter in the previous code example).

Call ICaptureGraphBuilder2::RenderStream to connect the capture filter to the ASF Writer:

hr = pBuild->RenderStream(
    &PIN_CATEGORY_CAPTURE,   // Capture pin.
    &MEDIATYPE_Video,        // Video. Use MEDIATYPE_Audio for audio.
    pCap,                    // Pointer to the capture filter. 
    0, 
    pASFWriter);             // Pointer to the sink filter (ASF Writer).

Each input pin on the WM ASF Writer filter corresponds to a stream in the Windows Media profile. You must connect every pin, so that the file content matches the profile.

See Also

Concepts

Capturing Video to a File