Share via


MFCreateTranscodeProfile 関数 (mfidl.h)

空のトランスコード プロファイル オブジェクトを作成します。

トランスコード プロファイルには、出力ファイルの構成設定が格納されます。 これらの構成設定は呼び出し元によって指定され、オーディオ ストリームとビデオ ストリームのプロパティ、エンコーダー設定、コンテナー設定が含まれます。 これらのプロパティを設定するには、呼び出し元が適切な IMFTranscodeProfile メソッドを呼び出す必要があります。

構成されたトランスコード プロファイルは 、MFCreateTranscodeTopology 関数に渡されます。 基になるトポロジ ビルダーは、これらの設定を使用してトランスコード トポロジを構築します。

構文

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

パラメーター

[out] ppTranscodeProfile

トランスコード プロファイル オブジェクトの IMFTranscodeProfile インターフェイスへのポインターを受け取ります。 呼び出し元は、インターフェイスを解放する必要があります。

戻り値

この関数が成功すると、 S_OKが返されます。 そうでない場合は、HRESULT エラー コードを返します。

解説

MFCreateTranscodeProfile 関数は、空のトランスコード プロファイルを作成します。 メディアの種類とコンテナーのプロパティを定義するトランスコード プロファイル設定属性を構成する必要があります。 プロファイルを構成するには、次の方法を使用します。

この関数を使用するコード例については、次のトピックを参照してください。

次の例では、Windows Media Audio (WMA) のトランスコード プロファイルを作成します。

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
Library Mf.lib
[DLL] Mf.dll

関連項目

IMFTranscodeProfile

MFTranscodeGetAudioOutputAvailableTypes

メディア ファンデーション機能

トランスコード API