MFCreateTranscodeProfile 함수(mfidl.h)

빈 코드 변환 프로필 개체를 만듭니다.

코드 변환 프로필은 출력 파일에 대한 구성 설정을 저장합니다. 이러한 구성 설정은 호출자에 의해 지정되며 오디오 및 비디오 스트림 속성, 인코더 설정 및 컨테이너 설정을 포함합니다. 이러한 속성을 설정하려면 호출자가 적절한 IMFTranscodeProfile 메서드를 호출해야 합니다.

구성된 트랜스코드 프로필은 MFCreateTranscodeTopology 함수에 전달됩니다. 기본 토폴로지 작성기에서는 이러한 설정을 사용하여 트랜스코드 토폴로지를 빌드합니다.

구문

HRESULT MFCreateTranscodeProfile(
  [out] IMFTranscodeProfile **ppTranscodeProfile
);

매개 변수

[out] ppTranscodeProfile

트랜스코드 프로필 개체의 IMFTranscodeProfile 인터페이스에 대한 포인터를 받습니다. 호출자는 인터페이스를 해제해야 합니다.

반환 값

이 함수가 성공하면 S_OK 반환합니다. 그러지 않으면 HRESULT 오류 코드를 반환합니다.

설명

MFCreateTranscodeProfile 함수는 빈 트랜스코드 프로필을 만듭니다. 미디어 형식 및 컨테이너 속성을 정의하는 코드 변환 프로필 설정 특성을 구성해야 합니다. 다음 메서드를 사용하여 프로필을 구성합니다.

이 함수를 사용하는 예제 코드는 다음 topics 참조하세요.

예제

다음 예제에서는 WMA(Windows Media Audio)에 대한 트랜스코드 프로필을 만듭니다.

template <class Q>
HRESULT GetCollectionObject(IMFCollection *pCollection, DWORD index, Q **ppObj)
{
    IUnknown *pUnk;
    HRESULT hr = pCollection->GetElement(index, &pUnk);
    if (SUCCEEDED(hr))
    {
        hr = pUnk->QueryInterface(IID_PPV_ARGS(ppObj));
        pUnk->Release();
    }
    return hr;
}

HRESULT CreateTranscodeProfile(IMFTranscodeProfile **ppProfile)
{
    IMFTranscodeProfile *pProfile = NULL;     // Transcode profile.
    IMFCollection   *pAvailableTypes = NULL;  // List of audio media types.
    IMFMediaType    *pAudioType = NULL;       // Audio media type.
    IMFAttributes   *pAudioAttrs = NULL;      // Copy of the audio media type.
    IMFAttributes   *pContainer = NULL;       // Container attributes.

    DWORD dwMTCount = 0;
    
    // Create an empty transcode profile.
    HRESULT hr = MFCreateTranscodeProfile(&pProfile);
    if (FAILED(hr))
    {
        goto done;
    }

    // Get output media types for the Windows Media audio encoder.

    // Enumerate all codecs except for codecs with field-of-use restrictions.
    // Sort the results.

    DWORD dwFlags = 
        (MFT_ENUM_FLAG_ALL & (~MFT_ENUM_FLAG_FIELDOFUSE)) | 
        MFT_ENUM_FLAG_SORTANDFILTER;

    hr = MFTranscodeGetAudioOutputAvailableTypes(MFAudioFormat_WMAudioV9, 
        dwFlags, NULL, &pAvailableTypes);
    if (FAILED(hr))
    {
        goto done;
    }

    hr = pAvailableTypes->GetElementCount(&dwMTCount);
    if (FAILED(hr))
    {
        goto done;
    }
    if (dwMTCount == 0)
    {
        hr = E_FAIL;
        goto done;
    }

    // Get the first audio type in the collection and make a copy.
    hr = GetCollectionObject(pAvailableTypes, 0, &pAudioType);
    if (FAILED(hr))
    {
        goto done;
    }

    hr = MFCreateAttributes(&pAudioAttrs, 0);       
    if (FAILED(hr))
    {
        goto done;
    }

    hr = pAudioType->CopyAllItems(pAudioAttrs);
    if (FAILED(hr))
    {
        goto done;
    }

    // Set the audio attributes on the profile.
    hr = pProfile->SetAudioAttributes(pAudioAttrs);
    if (FAILED(hr))
    {
        goto done;
    }

    // Set the container attributes.
    hr = MFCreateAttributes(&pContainer, 1);
    if (FAILED(hr))
    {
        goto done;
    }

    hr = pContainer->SetGUID(MF_TRANSCODE_CONTAINERTYPE, MFTranscodeContainerType_ASF);
    if (FAILED(hr))
    {
        goto done;
    }

    hr = pProfile->SetContainerAttributes(pContainer);
    if (FAILED(hr))
    {
        goto done;
    }

    *ppProfile = pProfile;
    (*ppProfile)->AddRef();

done:
    SafeRelease(&pProfile);
    SafeRelease(&pAvailableTypes);
    SafeRelease(&pAudioType);
    SafeRelease(&pAudioAttrs);
    SafeRelease(&pContainer);
    return hr;
}

요구 사항

   
지원되는 최소 클라이언트 Windows 7 [데스크톱 앱만 해당]
지원되는 최소 서버 Windows Server 2008 R2 [데스크톱 앱만 해당]
대상 플랫폼 Windows
헤더 mfidl.h
라이브러리 Mf.lib
DLL Mf.dll

참고 항목

IMFTranscodeProfile

MFTranscodeGetAudioOutputAvailableTypes

미디어 파운데이션 함수

API 코드 변환