如何在Windows Media Foundation中使用硬件H.264编码器 [英] How to use hardware H.264 encoder in Windows Media Foundation
问题描述
我正在使用H.264编码器MFT编写程序来进行视频编码.
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);
现在,在我的计算机上,调用MFTEnum后nCount将被设置为1.我只想知道,如果我的机器上有经过认证的硬件编码器,nCount会设置为2吗?然后我就可以选择我想要的那个了?
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/zh-CN/library/windows/desktop/aa965264(v=vs.85).aspx#create_mft
如果我可以枚举并选择硬件编码器MFT,是否可以使用相同的代码逻辑进行编码?
If I could enum and select a hardware encoder MFT, may I use the same code logic to do the encoding?
非常感谢
推荐答案
did you check this flag : MFT_ENUM_FLAG_HARDWARE
MFT使用AVStream驱动程序或基于GPU的代理MFT执行基于硬件的数据处理.此类别中的MFT总是异步处理数据.
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.
您需要使用: MFTEnumEx
由于硬件编码器应异步处理,因此您需要更改MSDN示例中的逻辑.
Because hardware encoder should process asynchronously, you will need to change the logic from the MSDN example.
这篇关于如何在Windows Media Foundation中使用硬件H.264编码器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!