IWMEncProfile2::put_CompatibilityMode

Windows Media Encoder SDK banner art

The put_CompatibilityMode method specifies the Windows Media version that you want the profile to support.

Syntax

HRESULT put_CompatibilityMode(
  WMENC_PROFILE_COMPATIBILITY  enumCompat
);

Parameters

enumCompat

[in]  Specifies a member of the WMENC_PROFILE_COMPATIBILITY enumeration type indicating compatibility.

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_CompatibilityMode method to specify the version of Windows Media-based content that you want the current profile to support. Then, use the Validate method to return detailed errors indicating which settings must be changed for the profile to be compatible with the Windows Media version you specified. The following items are enforced for version 8 and earlier content:

  • Audio and video streams must use a constant bit rate (CBR).
  • All audio streams must have the same audio format.
  • All video streams must have the same output image size.

Use the DetectCompatibility method to indicate which Windows Media version the profile supports according to the current settings. Use the put_ValidateMode method to indicate whether you want validation errors returned immediately.

Example Code

// Include libraries.
#include <windows.h>
#include <atlbase.h>
#include <comdef.h>
#include "C:\WMSDK\WMEncSDK9\include\wmencode.h"

    // Declare variables.
    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    IWMEncProfile2* pPro2;

    // 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_IWMEncoder,
            (void**) &pEncoder);
    }

    // Retrieve a specific profile.
    if ( SUCCEEDED( hr ) )
    {
        hr = pEncoder->get_ProfileCollection(&pProColl);
    }
    if ( SUCCEEDED( hr ) )
    {
        hr = pProColl->Item(11, &pPro);
    }

    if ( SUCCEEDED( hr ) )
    {
        hr = CoCreateInstance(CLSID_WMEncProfile2,
            NULL,
            CLSCTX_INPROC_SERVER,
            IID_IWMEncProfile2,
            (void**) &pPro2);
    }

    if ( SUCCEEDED( hr ) )
    {
        hr = pPro2->LoadFromIWMProfile(pPro);
    }

    // Retrieves a value indicating the Windows Media version that
    // the profile is compatible with.
    WMENC_PROFILE_COMPATIBILITY eCompat;
    if ( SUCCEEDED( hr ) )
    {
        hr = pPro2->DetectCompatibility(&eCompat);
    }

    // Set the compatibility mode.
    if ( SUCCEEDED( hr ) )
    {
        hr = pPro2->put_CompatibilityMode(WMENC_ENCODER_V9); // v9
    }

    // Release pointers.
    if ( pPro2 )
    {
        pPro2->Release();
        pPro2 = NULL;
    }

Requirements

Header: wmencode.h

Library: wmenc.exe

See Also