Click here to Skip to main content
15,844,387 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C++
hr = MFCreateMediaType(&mediaTypeIn);
hr = mediaTypeIn->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
hr = mediaTypeIn->SetGUID(MF_MT_SUBTYPE,  MFVideoFormat_AYUV);
hr = mediaTypeIn->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive);
hr = MFSetAttributeSize(mediaTypeIn, MF_MT_FRAME_SIZE, width, height);
hr = MFSetAttributeRatio(mediaTypeIn, MF_MT_FRAME_RATE, fps_num, fps_den);
hr = MFSetAttributeRatio(mediaTypeIn, MF_MT_PIXEL_ASPECT_RATIO, 1, 1);

hr = MFCreateMediaType(&mediaTypeOut);
hr = mediaTypeOut->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video); 
hr = mediaTypeOut->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_H264);
hr = mediaTypeOut->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive);
hr = mediaTypeOut->SetUINT32(MF_MT_AVG_BITRATE, bit_rate);
hr = mediaTypeOut->SetUINT32(MF_MT_MPEG2_PROFILE, eAVEncH264VProfile_Main)
hr = MFSetAttributeSize(mediaTypeOut, MF_MT_FRAME_SIZE, width, height);
hr = MFSetAttributeRatio(mediaTypeOut, MF_MT_FRAME_RATE, fps_num, fps_den);
hr = MFSetAttributeRatio(mediaTypeOut, MF_MT_PIXEL_ASPECT_RATIO, 1, 1);

hr = vx->sinkWriter->AddStream(mediaTypeOut, &vx->streamIndex);
hr = vx->sinkWriter->SetInputMediaType(vx->streamIndex, mediaTypeIn, NULL);

SetInputMediaTyp () failed and returns with error 'MF_E_INVALIDMEDIATYPE'

What I have tried:

This code works fine in windows 7 and failed in windows 10.

SetInputMediaType() failed and returns MF_E_INVALIDMEDIATYPE?

In case of VBR ('eAVEncCommonRateControlMode_Quality'), MF_MT_AVG_BITRATE' value is required?
Posted
Updated 27-Oct-16 23:01pm
v4

1 solution

The error message is clear that there is something not properly in configured in IMFSinkWriter.

You better read the Microsoft documentation about
encoding H.264. Take a deeper dive into the Video Type GUIDs.

Often arent all conversions supported. So try some variations.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900