Click here to Skip to main content
13,868,083 members
Rate this:
Please Sign up or sign in to vote.
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?
Updated 27-Oct-16 23:01pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web02 | 2.8.190214.1 | Last Updated 28 Oct 2016
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100