To capture the video stream to an AVI file use the AVI MUX filter as follows.
//specify the output media type, file name and get the resulting MUX
hr = pBuild->SetOutputFileName(&MEDIASUBTYPE_Avi, L"C:\\test.avi",
// Render the capture pin to the multiplexer
hr = pBuild->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,
pCap, NULL, pMux);
// Release the mux filter.
You can encode the video stream by inserting an encoder filter between the capture filter and the AVI Mux filter. Use the System Device Enumerator or the Filter Mapper to select an encoder filter. Specify the encoder filter as the fourth parameter to RenderStream.
If you want to capture a video while you are previewing the video call the RenderStream method successively. The capture graph builder will automatically add a Smart Tee to split the capture stream from the preview stream.