locked
How to get ICodecAPI interface on IMFSinkWriter RRS feed

  • Question

  • Hi,

    I am trying to use IMFSinkWriter to encode H.264 format video in mp4 container.

    I can set several attributes, ex: frame rate, interlace mode, profile...etc.

    And the frame can be encoded successful.

    But when I tried to set B picture count or GOP size, I found this needs ICodecAPI interface.

    I tried to get ICodecAPI interface from IMFSinkWriter, but I failed.

    And I see the msdn said "to get a ICodecAPI interface pointer, call QueryInterface on the MFT".

    http://msdn.microsoft.com/en-us/library/windows/desktop/dd797816(v=vs.85).aspx

    Does this mean ICodecAPI interface supported on IMFTransform, not IMFSinkWriter?

    Is there any method to get ICodecAPI interface pointer from IMFSinkWriter?

    Thanks for your help.

    Wednesday, May 23, 2012 9:29 AM

All replies

  • Call IMFSinkWriter::GetServiceForStream, passing GUID_NULL to the guidService parameter to use QueryInterface for that stream.
    • Proposed as answer by _mms_ Monday, October 15, 2012 6:39 AM
    Monday, June 18, 2012 9:39 PM
  • Thank you very much.

    It can work. :)

    Tuesday, July 31, 2012 7:54 AM
  • This works!

    However, to do this for WMV encoder we need to use an IPropertyStore, I'm able to get that interface, however as soon as I set the following properties (after calling SetInputMediaType on the sink writer) :

    MFPKEY_VBRENABLED true
    MFPKEY_PASSESUSED 1
    MFPKEY_VBRQUALITY xx

    I get MF_E_TRANSFORM_TYPE_NOT_SET from sinkwriter.writesample(..). Setting input and output types on the imftransform interface dosn't seem to help. Any ideas how to get the sink write to pickup these values and set on the encoder?

    Also any help with this related question:
    http://social.msdn.microsoft.com/Forums/en/mediafoundationdevelopment/thread/6da521e9-7bb3-4b79-a2b6-b31509224638

    Thank you.

    Monday, October 15, 2012 6:47 AM