Cannot set MFT H264 decoder resolution to value other than 1920x1080

Ling_2008 1 Reputation point
2022-04-05T05:57:00.493+00:00

Here's my code snippet, on Windows 10. If the <width, height> is set to other resolution such as 1280x760, 640x480, the pDecoderTransform_->SetOutputType() would fail with such error.

E [....] Failed to set output media type on H.264 decoder MFT.
Reason: The data specified for the media type is invalid, inconsistent, or not supported by this object. (Code: C00D36B4)

Please help.

  hr = CoCreateInstance(CLSID_CMSH264DecoderMFT, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (void**) &pTransformUnk);
  CHECK_HR_RET_BOOL(hr, "Failed to create H264 decoder MFT.");

  hr = pTransformUnk->QueryInterface(IID_PPV_ARGS(&pDecoderTransform_));
  CHECK_HR_RET_BOOL(hr, "Failed to get IMFTransform interface from H264 decoder MFT object.");

  IMFAttributes* decoderAttributes;
  hr = pDecoderTransform_->GetAttributes(&decoderAttributes);
  CHECK_HR_RET_BOOL(hr, "Failed to get attributes.");

  hr = decoderAttributes->SetUINT32(CODECAPI_AVDecVideoAcceleration_H264, TRUE);
  CHECK_HR_RET_BOOL(hr, "Failed to enable CODECAPI_AVDecVideoAcceleration_H264");

  MFCreateMediaType (&pInputMediaType);
  pInputMediaType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
  pInputMediaType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_H264);

  hr = pDecoderTransform_->SetInputType(0, pInputMediaType, 0);
  CHECK_HR_RET_BOOL(hr, "Failed to set input media type on decoder MFT.");

  MFCreateMediaType (&pOutputMediaType);
  pOutputMediaType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
  pOutputMediaType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_IYUV);

  // In the following lines, if other resolution is specified, e.g. 1280x760, 640x480,
  // "pDecoderTransform_->SetOutputType()" would fail.
  width = 1920;
  height = 1080;
  hr = MFSetAttributeSize(pOutputMediaType, MF_MT_FRAME_SIZE, width, height);
  CHECK_HR_RET_BOOL(hr, "Failed to set frame size on H264 MFT out type.");

  hr = pDecoderTransform_->SetOutputType(0, pOutputMediaType, 0);
  CHECK_HR_RET_BOOL(hr, "Failed to set output media type on H.264 decoder MFT.");
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,422 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Jeanine Zhang-MSFT 9,181 Reputation points Microsoft Vendor
    2022-04-05T09:41:15.73+00:00

    Hi,

    Welcome to Microsoft Q&A!

    0xC00D36B4 MF_E_INVALIDMEDIATYPE tells that you are trying to write a feed that requires conversion, and there is no suitable codec available. That is, the problem is with your media type which is not accepted by H264 decoder.

    I guess the limit of the H264 decoder has been reached.

    I suggest you could try to change the average bit rate value. And you could also try to use the other decoder, for example: MPEG-4 File Sink has no resolution restrictions.

    Best Regards,

    Jeanine


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Ling_2008 1 Reputation point
    2022-05-12T16:29:18.297+00:00

    Hello, could any one help ?


  3. Ling_2008 1 Reputation point
    2022-05-27T14:34:58.19+00:00

    Hi Jeanine, repost this in case you missed it.

    "Sorry I missed your replies because the page hides them by default and I have to click on the "Show more comments" to see them. I didn't realize that until today :(

    Anyway, here's the ZIP file. Please see if you can access it.
    https://1drv.ms/u/s!Aqh3rhN3GkAwdZ4Q6cPIPr1UvI0

    Thanks !"

    0 comments No comments

  4. Ling_2008 1 Reputation point
    2022-06-06T16:33:29.883+00:00

    Hi Jeanine, could you help ?

    0 comments No comments