Hi,
I'm using a Nvidia QUADRO P400 graphics card to do h.264 hardware encoding. Windows Media Foundation can find the encoder and set up/encode frames correctly. But I found there's no way to get SPS/PPS which are needed by muxer.
My sample code is here
HRESULT hr = MFStartup(MF_VERSION, 0);
UINT32 nCount = 0;
MFT_REGISTER_TYPE_INFO encoderInfo;
encoderInfo.guidMajorType = MFMediaType_Video;
encoderInfo.guidSubtype = MFVideoFormat_H264;
IMFActivate **ppActivate = NULL;
UINT32 nFlags = MFT_ENUM_FLAG_HARDWARE;
hr = MFTEnumEx(MFT_CATEGORY_VIDEO_ENCODER, nFlags, NULL, &encoderInfo, &ppActivate, &nCount);
WCHAR TempBuf[200];
for (UINT32 i = 0; i < nCount; i++) {
ppActivate[i]->GetString(MFT_FRIENDLY_NAME_Attribute, TempBuf, sizeof(TempBuf) / sizeof(TempBuf[0]), NULL);
// nCount == 1 and TempBuf == L"NVIDIA H.264 Encoder MFT"
}
IMFTransform* pEncoder = nullptr;
hr = ppActivate[0]->ActivateObject(IID_IMFTransform, (void**)&pEncoder);
IMFMediaType* ciOutputType = nullptr; // Output media type of the encoder
hr = MFCreateMediaType((IMFMediaType**)&ciOutputType);
hr = ciOutputType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
hr = ciOutputType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_H264);
hr = ciOutputType->SetUINT32(MF_MT_INTERLACE_MODE, 2); // Non-interlace 2 == MFVideoInterlace_Progressive
hr = ciOutputType->SetUINT32(MF_MT_MPEG2_PROFILE, 77); // Main profile
hr = ciOutputType->SetUINT32(MF_MT_MPEG2_PROFILE, 51); // Level 5.1
hr = MFSetAttributeRatio(ciOutputType, MF_MT_FRAME_RATE, 30, 1); // Frame rate
hr = MFSetAttributeSize(ciOutputType, MF_MT_FRAME_SIZE, 1920, 1080); // Resolution
hr = MFSetAttributeRatio(ciOutputType, MF_MT_PIXEL_ASPECT_RATIO, 1, 1);
hr = pEncoder->SetOutputType(0, ciOutputType, 0); size_t iExtraDataSize = 0;
// here returned hr == 0xc00d36e6 : The requested attribute was not found.
hr = ciOutputType->GetBlobSize(MF_MT_MPEG_SEQUENCE_HEADER, &iExtraDataSize);
return 0;
Anyone know how to get SPS/PPS?
Thanks