Reputation: 767
I'm using H.264 encoder MFT to do video encoding in my program. Everything works correctly until I found a file on which the H.264 encoder couldn't set output type successfully.
The code I used to set up encoder is here
ciEncoder.CreateObject(pCLSIDs[0], IID_IMFTransform);
// H.264 Encoder MFT needs to set output first
LComObject<IMFMediaType> ciOutputType; // Output media type of the encoder
hr = fpMFCreateMediaType((IMFMediaType**)(ciOutputType.GetAssignablePtrRef()));
hr = ciOutputType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
hr = ciOutputType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_H264);
hr = ciOutputType->SetUINT32(MF_MT_AVG_BITRATE, 768 * 1000);
hr = ciOutputType->SetUINT32(MF_MT_INTERLACE_MODE, 2);
hr = ciOutputType->SetUINT32(MF_MT_MPEG2_PROFILE, eAVEncH264VProfile_Base);
hr = MFSetAttributeRatio(ciOutputType.get(), MF_MT_FRAME_RATE, 10, 1);
hr = MFSetAttributeSize(ciOutputType.get(), MF_MT_FRAME_SIZE, vf.iWidth, vf.iHeight);
hr = MFSetAttributeRatio(ciOutputType.get(), MF_MT_PIXEL_ASPECT_RATIO, 1, 1);
hr = ciEncoder->SetOutputType(0, ciOutputType.get(), 0);
The input video (an swf video) resolution is 76x12 and with above code SetOutputType returns MF_E_INVALIDMEDIATYPE.
If I keep width 76 but change height to 70 for example, then SetOutputType can succeed. I also tried other values like 24, 38 but both failed.
Could anyone help to check this?
Thanks
Upvotes: 0
Views: 573
Reputation: 1515
I don't really know the answer. But perhaps the answer can be found in the way where the encoder processes macroblocks. They can be 4*4 or 8*8, and so on. So perhaps a minimal height is needed for the encoding.
Upvotes: 1