Search code examples
c++winapivideoms-media-foundation

Handling MF_E_TRANSFORM_STREAM_CHANGE from video decoder MFT


I am trying to decode even just a single H264 frame with the H264 Decoder MFT, but I've been having problems with ProcessOutput(). I've reduced the bad HRESULT's as much as I can, but I'm currently stuck on dealing with MF_E_TRANSFORM_STREAM_CHANGE. This occurs after I set the pSample equal to my allocated output_sample and call ProcessOutput(), since this decoder requires you allocate your own sample. I tried resetting the output type using SetOutputType() to what I had in my configure_decoder() function, but alas I get a bad HRESULT. Not sure what to do next.

enter image description here


Solution

  • You just need to follow this at Handling Stream Changes:

    1. The client calls IMFTransform::GetOutputAvailableType. This method returns an updated set of output types.
    2. The client calls SetOutputType to set a new output type.
    3. The client resumes calling ProcessInput/ProcessOutput.

    In the question body above you are trying to do 3 without doing 2. Most likely your media type is somewhat different from MFT's so it is likely to reject it and it blocks the processing until this is resolved.