IWMEncProfile2::GetCodecIndexFromFourCC
![]() |
The GetCodecIndexFromFourCC method retrieves the audio or video codec index for a specific FOURCC value.
Syntax
HRESULT GetCodecIndexFromFourCC(
WMENC_SOURCE_TYPE enumSrcType,
long lFourCC,
long* plIndex
);
Parameters
enumSrcType
[in] Specifies a member of the WMENC_SOURCE_TYPE enumeration type.
lFourCC
[in] long that represents an ASCII version of the FOURCC value.
To get the lFourCC value, determine the hexadecimal values of the four characters, combine them in reverse order, and then convert this value to a decimal.
For example, for the FOURCC value WMV3: W = 57, M = 4D, V = 56, and 3 = 33. Combined in reverse, the entire hexadecimal value is 33564D57. When converted to decimal (lFourCC), this value is 861293911.
plIndex
[out] Pointer to a long containing the audio or video codec index.
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 codec index is NULL. |
Remarks
Four-Character Codes (FOURCC) is a set of codes used to identify data stream formats. FOURCC values are stored in file headers to describe the software technology and data format that was used to produce the multimedia data.
Use this method to find a particular codec if you know its FOURCC value.
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);
}
// Retrieve the video codec index from its FOURCC value.
long lVid4CC = 1234; // REPLACE WITH A FOURCC VALUE
long lVidCodecIndex;
if ( SUCCEEDED( hr ) )
{
hr = pPro2->GetCodecIndexFromFourCC(WMENC_VIDEO, lVid4cc, &lVidCodecIndex);
}
// Release pointers.
if ( pPro2 )
{
pPro2->Release();
pPro2 = NULL;
}
Requirements
Header: wmencode.h
Library: wmenc.exe
See Also
.gif)