Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

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

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

Copy 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::SetFileNameto set the name of the output file. It returns a pointer to the filter as an outgoing parameter ( pASFWriterin the previous code example).

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

Copy Code
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