The only other question that posts this particular problem shouldn't be an issue- I avoid setting MF_MT_MPEG2_LEVEL on the output node. When I Call SetOutputType on my Transform Object (H264 TRansform Object), it returns E_FAIL as the return code. I'm not entirely sure what I am doing wrong, though I suspect that it may have something to do with what I am setting the output node to:
// Create Transform- H264 Encoder
IUnknown* pUnk;
CLSID *pMFTCLSIDs = NULL; // Pointer to an array of CLISDs.
DWORD dwStreamID = 0;
IMFMediaType* pInputType = NULL;
IMFMediaType* pOutputType = NULL;
ICodecAPI* pCodec = NULL;
UINT32 cCLSID = 0; // Size of the array.
UINT32 cBitrate = 10000;
IMFMediaTypeHandler* pVideoTypeHandler;
CHECK_HR(pSD->GetStreamIdentifier(&dwStreamID));
CHECK_HR(pSD->GetMediaTypeHandler(&pVideoTypeHandler));
CHECK_HR(pVideoTypeHandler->GetCurrentMediaType(&pInputType));
SafeRelease(&pVideoTypeHandler);
IMFTransform* pTransformer;
// Set the Transform type
MFT_REGISTER_TYPE_INFO tinfo = {MFMediaType_Video , MFVideoFormat_H264};
// Look for an encoder.
CHECK_HR( MFTEnum(
MFT_CATEGORY_VIDEO_ENCODER,
0, // Reserved
NULL, // Input type to match. None.
&tinfo, // H264 encoded type.
NULL, // Attributes to match. (None.)
&pMFTCLSIDs, // Receives a pointer to an array of CLSIDs.
&cCLSID // Receives the size of the array.
));
//Create the MFT decoder
CHECK_HR(CoCreateInstance(pMFTCLSIDs[0], NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pTransformer)));
// H264 encoder requires Output first, then input.
//Set Output Type
//Get the first output type
//You can loop through the available output types to choose
//the one that meets your target requirements
CHECK_HR( pTransformer->GetOutputAvailableType(0, 0, &pOutputType));
// Bitrate
CHECK_HR( pOutputType->SetUINT32(MF_MT_AVG_BITRATE, cBitrate));
//,
//Interlace Mode:
CHECK_HR(CopySingleAttribute(pInputType,pOutputType,MF_MT_INTERLACE_MODE)); // just coping from the input, shouldn't be interlaced though.
CHECK_HR(pOutputType->SetGUID(MF_MT_MAJOR_TYPE,MFMediaType_Video));
CHECK_HR(pOutputType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_H264));
CHECK_HR(pOutputType->SetUINT32(MF_MT_AVG_BITRATE,14000 * 1024)); //14000k
CHECK_HR(MFSetAttributeRatio(pOutputType,MF_MT_FRAME_RATE,30, 1)); // 30 Frames/ second
CHECK_HR(MFSetAttributeRatio(pOutputType,MF_MT_FRAME_SIZE,1280,720)); // 720p input
CHECK_HR(pOutputType->SetUINT32(MF_MT_MPEG2_PROFILE, eAVEncH264VProfile_Main));
// Output Type
CHECK_HR(pTransformer->SetOutputType(dwStreamID,pOutputType,0)); // Returns E_FAIL at the moment.