IWMEncContentAnalyzer::Property
The Property method retrieves a value indicating the recommended video optimization to apply.
Syntax
HRESULT Property(
WMENC_SOURCE_TYPE enumType,
short iIndex,
BSTR bstrProperty,
VARIANT* pvarValue
);
Parameters
enumType
[in] Specifies a member of the WMENC_SOURCE_TYPE enumeration type.
iIndex
[in] short containing the stream index.
bstrProperty
[in] BSTR containing the property to analyze. At this time, "Optimization" is the only supported property.
pvarValue
[out] A pointer to a VARIANT that indicates the type of video optimization to apply. This value corresponds to a WMENC_VIDEO_OPTIMIZATION enumeration type.
Return Values
If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.
Return code | Number | Description |
E_POINTER | 0x80004003 | The pointer to the optimization value is NULL. |
NS_E_INVALID_REQUEST | 0xC00D002BL | The request is invalid in the current state. |
Remarks
Use the put_SourceGroup method to specify the video content to analyze. Use the Start method to begin analyzing content.
If the Property method is called too soon after starting the content analysis process, an error is returned indicating that no frames have been submitted. To avoid this, a pause is required.
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