I'm able to successfully encode H264 video using MediaFoundation.
Now I want to export HEVC which is, according to official documentation, is supported.
I am doing everything as described there but whenever I want to set input media type to the writer it ends up with an error:
No suitable transform was found to encode or decode the content.
Here is a short code of what i do:
/* Set output media type */
IMFMediaType* pMediaTypeOut = nullptr;
MFCreateMediaType(&pMediaTypeOut);
pMediaTypeOut->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
pMediaTypeOut->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_HEVC);
MFSetAttributeSize(pMediaTypeOut, MF_MT_FRAME_SIZE, 640, 480);
MFSetAttributeRatio(pMediaTypeOut, MF_MT_FRAME_RATE, 30, 1);
pMediaTypeOut->SetUINT32(MF_MT_MPEG2_PROFILE, eAVEncH265VProfile_Main_420_8);
pMediaTypeOut->SetUINT32(MF_MT_MPEG2_LEVEL, eAVEncH265VLevel1);
// Add it to the sink writer
m_pWriter->AddStream(pMediaTypeOut, &m_streamIndex);
/* Set input media type */
IMFMediaType* pMediaTypeIn = nullptr;
MFCreateMediaType(&pMediaTypeIn);
pMediaTypeIn->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
pMediaTypeIn->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_NV12);
MFSetAttributeSize(pMediaTypeIn, MF_MT_FRAME_SIZE, 640, 480);
MFSetAttributeRatio(pMediaTypeIn, MF_MT_FRAME_RATE, 30, 1),
MFSetAttributeRatio(pMediaTypeIn, MF_MT_PIXEL_ASPECT_RATIO, 1, 1),
// Here it ends up with an error
m_pWriter->SetInputMediaType(m_streamIndex, pMediaTypeIn, nullptr);
Does anyone know if the HEVC encoding is really supported or it is just a documentation. And if it is really supported by Microsoft, then what am I doing wrong?
BTW: I am using latest version of Windows 10. Error checking is omitted for code simplicity