How to use hardware H.264 encoder in Windows Media Foundation

我的未来我决定 提交于 2019-12-12 22:01:34

问题


I'm writing a program using H.264 encoder MFT to do video encoding.

The way I'm using to select/create the encoder is like:

MFT_REGISTER_TYPE_INFO encoderInfo;
encoderInfo.guidMajorType = MFMediaType_Video;
encoderInfo.guidSubtype = MFVideoFormat_H264;
// H.264 Encoder class id is not exposed, so we have to enumerate
HRESULT hr = MFTEnum(MFT_CATEGORY_VIDEO_ENCODER, 0, NULL, &encoderInfo, NULL, &pCLSIDs, &nCount);
if (nCount == 0) {
   break;
}
//Create H.264 Encoder MFT instance
ciEncoder.CreateObject(pCLSIDs[0], IID_IMFTransform);

Now on my machine the nCount will be set to 1 after MFTEnum is called. I just want to know, if there's a certified hardware encoder available on my machine, will nCount be set to 2? and then I'll be able to select the one I want?

Another question is, I'm using the synchronous processing mode to encode frames as described in

https://msdn.microsoft.com/en-us/library/windows/desktop/aa965264(v=vs.85).aspx#create_mft

If I could enum and select a hardware encoder MFT, may I use the same code logic to do the encoding?

Great thanks


回答1:


did you check this flag : MFT_ENUM_FLAG_HARDWARE

The MFT performs hardware-based data processing, using either the AVStream driver or a GPU-based proxy MFT. MFTs in this category always process data asynchronously.

You need to use : MFTEnumEx

Because hardware encoder should process asynchronously, you will need to change the logic from the MSDN example.



来源:https://stackoverflow.com/questions/31236646/how-to-use-hardware-h-264-encoder-in-windows-media-foundation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!