I am using Microsoft Media Foundation to encode a H.264 video file.
I am using the SinkWriter to create the video file. The input is a buffer (MFVideoFormat_RGB32
) where I draw the frames and the output is a MFVideoFormat_H264
.
The encoding works and it creates a video file with my frames in it. But I want to set the quality for that video file. More specifically, I want to set the CODECAPI_AVEncCommonQuality
property on the H.264 encoder.
In order to get a handle to the H.264 encoder, I call GetServiceForStream on the SinkWriter. Then I set the CODECAPI_AVEncCommonQuality
property.
The problem is that my property change is ignored. As stated in the documentation:
To set this parameter in Windows 7, set the property before calling IMFTransform::SetOutputType. The encoder ignores changes after the output type is set.
The problem is that I don't create the H.264 encoder manually. I set the input and the output type on the SinkWriter, and the SinkWriter creates the H.264 encoder automatically. As soon as it creates the encoder, it calls the IMFTransform::SetOutputType
method, and I can't change the CODECAPI_AVEncCommonQuality
property anymore. The documentation also says that the property change isn't ignored in Windows 8, but I need this to run on Windows 7.
Do you know how I can change the quality for the encoded file while using SinkWriter on Windows 7?
PS: Someone asked the same question on the msdn forums, and he didn't seem to get an answer.