Reputation: 41
Having trouble when setting up the input type. I'm getting this error:
MF_E_INVALIDMEDIATYPE: The data specified for the media type is invalid, inconsistent, or not supported by this object.
Any ideas how to fix it?
The error is returned at SetInputMediaType
.
This is the setup code for input and output:
hr = MFCreateMediaType(&mediaTypeIn);
hr = mediaTypeIn->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
hr = mediaTypeIn->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_RGB24);
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_MSS2);
hr = mediaTypeOut->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive);
hr = mediaTypeOut->SetUINT32(MF_MT_AVG_BITRATE, bit_rate);
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);
// No problems before this point, and the call below returns MF_E_INVALIDMEDIATYPE
hr = vx->sinkWriter->SetInputMediaType(vx->streamIndex, mediaTypeIn, NULL);
Upvotes: 3
Views: 715
Reputation: 1515
You don't tell us what is width, height, fps_num, fps_den, and so on. So, for example, if width is zero, you will receive MF_E_INVALIDMEDIATYPE...
EDIT
Here is the answer : Matt Andrews Microsoft (MSFT)
As noted earlier in this thread, the Microsoft screen encoder is not registered by default. The CLSID for the screen encoder is CLSID_CMSSCEncMediaObject2. If you want to use this in an application, you either need to create it manually using CoCreateInstance and then insert it into a topology, or locally register it using MFTRegisterLocalByCLSID.
MFVideoFormat_MSS2 is not present by default on system.
Upvotes: 1