IWMEncAudienceObj::put_VideoHeight

Windows Media Encoder SDK banner art

The put_VideoHeight method specifies the output height of the video image.

Syntax

HRESULT put_VideoHeight(
  short  iRenderSiteIndex,
  long  lHeight
);

Parameters

iRenderSiteIndex

[in]  short containing the audience stream index. Because an audience can only contain one stream of each type, iRenderSiteIndex must be zero.

lHeight

[in]  long indicating the output height of the video image, ranging from 16 to 2000 pixels. To use the same height as the input, specify 0. (However, when using this profile with the Writer object in the Windows Media Format SDK, a 0 value does not match the size to the input.)

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Example Code

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

    HRESULT hr;
    IWMEncProfile2* pPro2;
    IWMEncAudienceObj* pAudnc;
    long lAudCount;
    int i;

    // Initialize the COM library and retrieve a pointer to an IWMEncProfile2 interface.
    hr = CoInitialize(NULL);

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

    // Verify profile settings immediately as they are set.
    if ( SUCCEEDED( hr ) )
    {
        hr = pPro2->put_ValidateMode(VARIANT_TRUE);
    }

    // Provide a name and description.
    if ( SUCCEEDED( hr ) )
    {
        hr = pPro2->put_ProfileName(CComBSTR("Sample MBR Profile"));
    }
    if ( SUCCEEDED( hr ) )
    {
        hr = pPro2->put_ProfileDescription(CComBSTR("A video profile with three audiences"));
    }

    // Specify video content.
    if ( SUCCEEDED( hr ) )
    {
        hr = pPro2->put_ContentType(16);
    }

    // Specify constant bit rate (CBR) mode.
    if ( SUCCEEDED( hr ) )
    {
        hr = pPro2->put_VBRMode(WMENC_VIDEO, 0, WMENC_PVM_NONE);
    }

    // Add audiences for 200, 400, and 600 Kbps.
    if ( SUCCEEDED( hr ) )
    {
        hr = pPro2->AddAudience(200000, &pAudnc);
    }
    if ( SUCCEEDED( hr ) )
    {
        hr = pPro2->AddAudience(400000, &pAudnc);
    }
    if ( SUCCEEDED( hr ) )
    {
        hr = pPro2->AddAudience(600000, &pAudnc);
    }
    if ( SUCCEEDED( hr ) )
    {
        hr = pPro2->get_AudienceCount(&lAudCount);
    }

    // Create an audience object then loop through all of the audiences
    // in the current profile, making the same changes to each audience.
    for (i = 0; i < lAudCount; i++)
    {
        if ( SUCCEEDED( hr ) )
        {
            hr = pPro2->get_Audience(i, &pAudnc);
        }
        // The Windows Media 9 codec is used by default, but you can change
        // it as follows. Be sure to make this change for each audience.
        if ( SUCCEEDED( hr ) )
        {
            hr = pAudnc->put_VideoCodec(0, 2);
        }

        // Make the video output size match the input size by setting the height and width to 0.
        if ( SUCCEEDED( hr ) )
        {
            hr = pAudnc->put_VideoHeight(0, 0);
        }
        if ( SUCCEEDED( hr ) )
        {
            hr = pAudnc->put_VideoWidth(0, 0);
        }

        // Change the buffer size to 5 seconds. By default, the end user's default setting is used.
        if ( SUCCEEDED( hr ) )
        {
            hr = pAudnc->put_VideoBufferSize(0, 5000);
        }
    }

    // Change the video image sharpness for the first audience only.
    if ( SUCCEEDED( hr ) )
    {
        hr = pPro2->get_Audience(0, &pAudnc);
    }
    if ( SUCCEEDED( hr ) )
    {
        hr = pAudnc->put_VideoImageSharpness(0, 70);
    }

    // Validate the settings to make sure the profile has no errors.
    if ( SUCCEEDED( hr ) )
    {
        hr = pPro2->Validate();
    }

    // Save the profile to a .prx file.
    if ( SUCCEEDED( hr ) )
    {
        hr = pPro2->SaveToFile(CComBSTR("C:\\Program Files\\Windows Media Components\\Encoder\\Profiles\\CPPprofile.prx"));
    }

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

Requirements

Header: wmencode.h

Library: wmenc.exe

See Also