我正在使用 H.264 编码器 MFT 在我的程序中进行视频编码。一切正常,直到我找到 H.264 编码器无法成功设置输出类型的文件。
我用来设置编码器的代码在这里
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);
输入视频(swf 视频)分辨率为 76x12,使用上述代码 SetOutputType 返回 MF_E_INVALIDMEDIATYPE。
例如,如果我保持宽度 76 但将高度更改为 70,则 SetOutputType 可以成功。我还尝试了其他值,例如 24、38,但都失败了。
谁能帮忙检查一下?
谢谢
最佳答案
我真的不知道答案。但或许可以从编码器处理宏 block 的方式中找到答案。它们可以是 4*4 或 8*8,等等。因此,编码可能需要最小高度。
关于c++ - 由于 Windows Media Foundation 中的解析,SetOutputType 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31238398/