question

Ling2008-0391 avatar image
0 Votes"
Ling2008-0391 asked Ling2008-0391 answered

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

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JeanineZhang-MSFT avatar image
0 Votes"
JeanineZhang-MSFT answered JeanineZhang-MSFT commented

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.



· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Jeanine,

Thanks for your reply. But my code works fine when the [width, height] is set to [1920, 1080]. It fails when I set the resolution to any smaller values.

So I'm pretty sure this "I guess the limit of the H264 decoder has been reached" should not apply.

0 Votes 0 ·

@Ling2008-0391

I'm so sorry, I misunderstood what you meant earlier. Could you please show a minimal, reproducible sample without private information, and some detailed steps to help us reproduce the issue?

0 Votes 0 ·
Ling2008-0391 avatar image Ling2008-0391 JeanineZhang-MSFT ·

Hi Jeanine,

I'd like to attach a very small zip file of a VS2019 project. Unfortunately your forum does not allow me to attach a zip file. Neither does it allow me to copy-paste code here as only 1500 characters are allowed in a comment.
So is there a way for me to attach a zip file ?

0 Votes 0 ·
Show more comments
Ling2008-0391 avatar image Ling2008-0391 JeanineZhang-MSFT ·

Hi Jeanine, have you seen my reply ?

0 Votes 0 ·
Show more comments
Ling2008-0391 avatar image
0 Votes"
Ling2008-0391 answered Ling2008-0391 commented

Hello, could any one help ?

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Jeanine,

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 Votes 0 ·
Ling2008-0391 avatar image
0 Votes"
Ling2008-0391 answered

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 !"

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Ling2008-0391 avatar image
0 Votes"
Ling2008-0391 answered

Hi Jeanine, could you help ?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.