Hi,
I`m trying to use the IMFSinkWriter API to encode a H264 video file. Starting with the example from
Microsoft Sink Writer Tutorial it was relatively easy to create a first mp4 video file with the expected video stream. Very cool.
Now I want to configurate additional encoder parameters (H264 encoder parameters) using the ICodecAPI interface.
ICodecAPI* pCodecApi;
HRESULT hr = pSinkWriter->GetServiceForStream (streamIndex, GUID_NULL, __uuidof (ICodecAPI), (LPVOID*)&pCodecApi);
Among other things I want to enable CABAC which seems to be disabled by the Microsoft H264 encoder - even if you
specify the high profile parameter (eAVEncH264VProfile_High).
hr |= pMediaTypeOut->SetUINT32 (MF_MT_MPEG2_PROFILE, eAVEncH264VProfile_High);
VARIANT var = {0};
var.vt = VT_BOOL;
var.boolVal = VARIANT_TRUE;
HRESULT hr = codecAPI->SetValue(&CODECAPI_AVEncH264CABACEnable, &var);
The SetValue method returns S_OK.
But the CABAC entropy coding is still not active. I`m using the tool MediaInfo to check the parameters in a video file.
I tried other parameters like the maximum number of reference frames "CODECAPI_AVEncVideoMaxNumRefFrame" which is always 2 - the default value of this parameter - even if I set the parameter to 1 or 0.
VARIANT var = {0};
var.vt = VT_UI4;
var.ulVal = 1;
hr = pCodecApi->SetValue(&CODECAPI_AVEncVideoMaxNumRefFrame, &var);
In another attempt I read out the previously set values again - and the values are the one I set before. Everything as expected.
hr = pCodecApi->GetValue (&CODECAPI_AVEncH264CABACEnable, &var2);
I don`t know where my mistake is to set these additional parameters.
Does anyone of you have a working example setting such additional ICodecAPI parameters for a Microsoft encoder?