Hi folks,
I am trying to set up the SinkWriter to use the Windows Media Video Screen Encoder 9. I registered the MFT before my actual setup, but I am having trouble when setting the input type. It gave me 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? This is the setup code for input and output (note that I have omitted all the checking for hr at each step to make the code nice and clean):
// Trying to register screen codec MFT_REGISTER_TYPE_INFO infoInput = { MFMediaType_Video, MFVideoFormat_RGB24 }; MFT_REGISTER_TYPE_INFO infoOutput = { MFMediaType_Video, MFVideoFormat_MSS2 }; hr = MFTRegisterLocalByCLSID(CLSID_CMSSCEncMediaObject2, MFT_CATEGORY_VIDEO_ENCODER, L"ScreenEncoder", 0, 1, &infoInput, 1, &infoOutput); // Configure the input media type here hr = MFCreateMediaType(&mediaTypeIn); hr = mediaTypeIn->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video); hr = mediaTypeIn->SetGUID(MF_MT_SUBTYPE, useH264 ? MFVideoFormat_YUY2 : 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); // Configure the output media type here hr = MFCreateMediaType(&mediaTypeOut); hr = mediaTypeOut->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video); hr = mediaTypeOut->SetGUID(MF_MT_SUBTYPE, useH264 ? MFVideoFormat_H264 : MFVideoFormat_MSS2); hr = mediaTypeOut->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive); hr = mediaTypeOut->SetUINT32(MF_MT_AVG_BITRATE, VIDEO_BITRATE); 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); // It fails at this point hr = vx->sinkWriter->SetInputMediaType(vx->streamIndex, mediaTypeIn, NULL);
Thanks!