A bump of StackOverflow post about Media Foundation design flaw related to video encoding.
Set attributes via ICodecAPI for a H.264 IMFSinkWriter Encoder
I am trying to tweak the attributes of the H.264 encoder created via ActivateObject() by retrieving the ICodecAPI interface to it. Although I do not get errors, my settings are not taken into account. […]
Media Foundation’s Sink Writer is a simplified API with a encoder configuration question slipped away. The fundamental problem here is that you don’t own the encoder MFT and you are accessing it over the writer’s head, then the behavior of encoders around changing settings after everything is set up depends on implementation, which is in encoder’s case a vendor specific implementation and might vary across hardware.
Your more reliable option is to manage encoding MFT directly and supply Sink Writer with already encoded video.
Your potential trick to make things work with less of effort is to retrieve
IMFTransform of the encoder as well and clear and then set back the input/output media types after you finished with
ICodecAPI update. Nudging the media types, you suggest that encoder re-configures the internals and it would do this already having your fine tunings. Note that this, generally speaking, might have side issues.