Microsoft DirectX 8.1 (C++) |
To perform file capture, add a file-writing section to the filter graph. (If you just want preview functionality, skip this step.) Use the ICaptureGraphBuilder2::SetOutputFileName method. This method adds the required mux and file-writing filters to the graph. It takes input parameters that specify the name and format of the output file. For the format, you can use any of the following values:
The third option is for using third-party filters. For example, some capture devices deliver MPEG data. DirectShow does not include an MPEG writer filter, so you would need a third-party filter to write an MPEG file.
The following example sets the output file name to Example.avi and sets the format to AVI:
IBaseFilter *ppf = NULL;
IFileSinkFilter *pSink = NULL;
pBuilder->SetOutputFileName(&MEDIASUBTYPE_Avi, L"C:\\Example.avi", &ppf, &pSink);
When the method returns, it sets the ppf parameter to the multiplexer's IBaseFilter interface, and it sets the pSink parameter to the file writer's IFileSinkFilter interface. These might be the same filter. For example, the ASF Writer filter does both file writing and multiplexing.
The following diagram shows the filters used to write an AVI file (left) and an ASF file (right).
The AVI Mux filter exposes the IConfigAviMux and IConfigInterleaving interfaces, and the ASF Writer filter exposes the IConfigAsfWriter interface. You can use these interfaces to configure the output file format. For ASF files, you must also provide a software certificate. For more information, see Creating ASF Files in DirectShow.
Note It is recommended that you preallocate your capture file using the ICaptureGraphBuilder2::AllocCapFile method. Capturing to a large preallocated file can improve capture performance.