IWMEncContentAnalyzer::Stop
The Stop method stops the process of analyzing content for video optimization.
Syntax
HRESULT Stop();
Parameters
This method takes no parameters.
Return Values
If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.
Remarks
Use the put_SourceGroup method to specify the video content to analyze. Use the Property method to retrieve a value indicating the type of video optimization to apply. Use the Start method to begin analyzing content.
Example Code
// Include libraries.
#include <windows.h>
#include <atlbase.h>
#include <comdef.h>
#include "C:\WMSDK\WMEncSDK9\include\wmencode.h"
#include <conio.h> // for kbhit()
// Declare variables.
HRESULT hr;
IWMEncoder2* pEncoder;
IWMEncSourceGroupCollection* pSrcGrpColl;
IWMEncSourceGroup* pSrcGrp;
IWMEncSource* pSrcVid;
IWMEncContentAnalyzer* pAnalyze;
// Initialize the COM library and retrieve a pointer to an IWMEncoder interface.
hr = CoInitialize(NULL);
if ( SUCCEEDED( hr ) )
{
hr = CoCreateInstance(CLSID_WMEncoder,
NULL,
CLSCTX_INPROC_SERVER,
IID_IWMEncoder2,
(void**) &pEncoder);
}
// Configure the profile settings for the encoding session.
// Retrieve the source group collection.
if ( SUCCEEDED( hr ) )
{
hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);
}
// Add a source group to the collection.
if ( SUCCEEDED( hr ) )
{
hr = pSrcGrpColl->Add(CComBSTR("SG_1"), &pSrcGrp);
}
// Add a video source and specify an input file.
if ( SUCCEEDED( hr ) )
{
hr = pSrcGrp->AddSource(WMENC_VIDEO, &pSrcVid);
}
if ( SUCCEEDED( hr ) )
{
hr = pSrcVid->SetInput(CComBSTR("C:\\InputFile.mpg"));
}
// Create an IWMEncContentAnalyzer object.
if ( SUCCEEDED( hr ) )
{
hr = pEncoder->get_ContentAnalyzer(&pAnalyze);
}
// Analyze the first source group.
if ( SUCCEEDED( hr ) )
{
hr = pAnalyze->put_SourceGroup(pSrcGrp);
}
// Start analyzing the video content.
if ( SUCCEEDED( hr ) )
{
hr = pAnalyze->Start();
}
// Keep the console window open.
printf("This pause is required before calling the Property method.");
// Wait for a key press.
while(!kbhit())
_asm nop;
// Retrieve the value indicating the video optimization to apply.
CComVariant vResult;
if ( SUCCEEDED( hr ) )
{
hr = pAnalyze->Property(WMENC_VIDEO, 0, CComBSTR("Optimization"), &vResult) ;
}
// Stop the content analysis process.
if ( SUCCEEDED( hr ) )
{
hr = pAnalyze->Stop();
}
// Release pointers.
if ( pSrcGrpColl )
{
pSrcGrpColl->Release();
pSrcGrpColl = NULL;
}
if ( pSrcVid )
{
pSrcVid->Release();
pSrcVid = NULL;
}
if ( pSrcGrp )
{
pSrcGrp->Release();
pSrcGrp = NULL;
}
if ( pAnalyze )
{
pAnalyze->Release();
pAnalyze = NULL;
}
if ( pEncoder )
{
pEncoder->Release();
pEncoder = NULL;
}
Requirements
Header: wmencode.h
Library: wmenc.exe
See Also