Microsoft DirectX 9.0 |
This section describes how to write a Windows Media file using DirectShow Editing Services (DES).
Important Do not use the Smart Render Engine to write Windows Media files. Always use the Basic Render Engine (CLSID_RenderEngine).
To write a Windows Media file, do the following:
The IConfigAsfWriter interface contains a few different methods for setting the profile. For example, the ConfigureFilterUsingProfileGuid method specifies a system profile as a GUID. Or, you can use Windows Media Format methods to get an IWMProfile pointer and then call IConfigAsfWriter::ConfigureFilterUsingProfile. For more information, see Configuring the ASF Writer.
ICaptureGraphBuilder2 *pBuild = 0;
hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, 0, CLSCTX_INPROC_SERVER,
IID_ICaptureGraphBuilder2, (void**)&pBuild);
pBuild->SetFiltergraph(pGraph);
Next, retrieve the output pin for each group by calling the IRenderEngine::GetGroupOutputPin method. Call RenderStream to connect the pin to the ASF Writer:
long cGroups = 0;
hr = pTimeline->GetGroupCount(&cGroups);
for (long i = 0; i < cGroups; i++)
{
IPin *pPin;
hr = pRenderEngine->GetGroupOutputPin(i, &pPin);
if (SUCCEEDED(hr))
{
hr = pBuild->RenderStream(0, 0, pPin, 0, pASF);
}
pPin->Release();
}
pBuild->Release