0

我正在尝试从我的相机解码 h264 视频我已将解码器配置如下。我无法弄清楚为什么 GetOutputAvailableType() 函数返回 MF_E_TRANSFORM_TYPE_NOT_SET。我还注意到 GetStreamIDs() 返回 E_NOTIMPL。我已经在 msdn 中检查了它给出的“MFT 具有固定数量的流,并且 \n 流标识符是从零开始的连续的。”。有人还可以解释这意味着什么吗?

HRESULT CH264_decodingDlg::ConfugureDecoder(IMFTransform *pDecoder)
{

HRESULT hr = S_OK;
IMFMediaType* pMediaTypeInput = NULL;


//Creating Input Media Type
hr  = MFCreateMediaType(&pMediaTypeInput);
if (FAILED(hr)) return hr;



DWORD dwIn = 0,dwOut = 0;
hr = pDecoder->GetStreamCount(&dwIn,&dwOut);
if (FAILED(hr)) return hr;
if (dwIn)
{
    DWORD dwInputID[2] ={0} ;
    DWORD dwOutputID[2]= {0};

            hr = pDecoder->GetStreamIDs(dwIn,dwInputID,dwOut,dwOutputID);

    //if (FAILED(hr)) return hr;
    GUID guidCurrent;
    GUID guidMajor;
    for (int i = 0; i< 8; i++)
    {

        hr = pDecoder->GetInputAvailableType(0,i,&pMediaTypeInput);
        hr  = pMediaTypeInput->GetGUID(MF_MT_MAJOR_TYPE, &guidMajor);
        if (guidMajor == MFMediaType_Video)    //safety check
        {
            if (hr == MF_E_NO_MORE_TYPES)
            {
                break;
            }

            hr  = pMediaTypeInput->GetGUID( MF_MT_SUBTYPE, &guidCurrent );

            if ( guidCurrent == MFVideoFormat_H264 )        //m_pVideoSubtype = MEDIASUBTYPE_WVC1
            {
                break;
            }
        }
    }
    // Set MF_MT_MAJOR_TYPE
    hr = pMediaTypeInput->SetGUID(MF_MT_MAJOR_TYPE ,MFMediaType_Video);
    if (FAILED(hr)) return hr;

    // Set MF_MT_SUBTYPE
    hr = pMediaTypeInput->SetGUID(MF_MT_SUBTYPE ,MFVideoFormat_H264);
    if (FAILED(hr)) return hr;

    // Set MF_MT_FRAME_RATE
    UINT32 nNumerator = 30;
    UINT32 nDenominator = 1;
    hr  = MFSetAttributeRatio(pMediaTypeInput,MF_MT_FRAME_RATE ,nNumerator,nDenominator);
    if (FAILED(hr)) return hr;

    // Set MF_MT_FRAME_SIZE
    UINT32 nWidth = 640 ;
    UINT32 nHeight = 480;
    hr = MFSetAttributeSize(pMediaTypeInput, MF_MT_FRAME_SIZE, nWidth, nHeight);
    if (FAILED(hr)) return hr;

    // Set MF_MT_MPEG2_PROFILE
    hr = pMediaTypeInput->SetUINT32(MF_MT_MPEG2_PROFILE, eAVEncH264VProfile_Base);
    if (FAILED(hr)) return hr;

    // Set MF_MT_INTERLACE_MODE
    hr = pMediaTypeInput->SetUINT32(MF_MT_INTERLACE_MODE ,MFVideoInterlace_Progressive);
    if (FAILED(hr)) return hr;

    // Set MF_MT_PIXEL_ASPECT_RATIO 
    hr = MFSetAttributeRatio(pMediaTypeInput,MF_MT_PIXEL_ASPECT_RATIO,1,1);
    if (FAILED(hr)) return hr;

    //Set Input Media Type
    hr = pDecoder->SetInputType(0,pMediaTypeInput,MFT_SET_TYPE_TEST_ONLY);
    if (FAILED(hr)) return hr;

    //Creating Output Media Type
    IMFMediaType* pMediaTypeOutput = NULL;
    hr  = MFCreateMediaType(&pMediaTypeOutput);
    if (FAILED(hr)) return hr;

    hr = pDecoder->GetOutputAvailableType(0,0,&pMediaTypeOutput);
    if (FAILED(hr)) return hr;`
4

1 回答 1

0

在获得输出媒体类型之前,您必须设置输入媒体类型。我没有看到你在做这个(SetInputType被称为MFT_SET_TYPE_TEST_ONLY)。

于 2013-01-11T08:37:16.663 回答