Capturing to Multiple Files
A version of this page is also available for
4/8/2010
After you have captured some video to a file, you can switch to a new file by stopping the graph and setting the file name on the filter the writes the file. Call the IFileSinkFilter::SetFileName method on the filter. You can get a pointer to the IFileSinkFilter Interface when you build the graph, through the pSink parameter of the ICaptureGraphBuilder2::SetOutputFileName method. The following code shows how to do this:
IBaseFilter *pMux;
IFileSinkFilter *pSink
hr = pBuild->SetOutputFileName(&MEDIASUBTYPE_Avi, L"C:\\YourFileName.avi",
&pMux, &pSink);
if (SUCCEEDED(hr))
{
hr = pBuild->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,
pCap, NULL, pMux);
if (SUCCEEDED(hr))
{
pControl->Run();
/* Wait awhile, then stop the graph. */
pControl->Stop();
// Change the file name and run the graph again.
pSink->SetFileName(L"YourFileName02.avi", 0);
pControl->Run();
}
pMux->Release();
pSink->Release();
}