For smooth switching between sources, you can use transitions between frames.
You can do it with the MFTransition method. This method mixes 2 source frames according to given parameters and returns you a mixed frame. You can control the position of a transition and its type.
The method has the parameters:
- _pFrameFrom - a frame from which the transition is used.
- _ppFrameRes - result mixed frame.
- _dblPos - position of a transition.
- _bsTransition - transition type.
- _bsPropsList - additional properties. This property is reserved for future usage.
- _bsConverterID - converter ID. This property is reserved for future usage.
To make a transition you need 2 MFFrame objects. You can receive them from sources or create new ones.
In common case transition between frames looks like:
// get a frame from 1st source MFFrame frameFrom; myFirstSource.SourceFrameGet(-1, out frameFrom, ""); // get a frame from 2nd source MFFrame frameTo; mySecondSource.SourceFrameGet(-1, out frameTo, ""); string transitionType="wheel"; double transitionPos = 0.5; MFFrame frameResult; frameTo.MFTransition(frameFrom, out frameResult, transitionPos, transitionType, "", "");
You can use a frameResult object for preview or to output, or whatever you like :)
The effect depends on a transition position (transitionPos):
- if it is 0.0 the frameResult is equal to frameFrom,
- if it is 1.0 - the frameResult is equal to frameTo
So you can vary a speed of transition by changing transition position parameter. To make transition slower you should set step for transitionPos smaller (for example, 0.01 - in this case a complete transition from 1st source to 2nd one takes 100 frames), and to make it faster you should increase the step (e.g. 0.1 - in this case transition takes only 10 frames).
You can use any transition type that is supported in MFormats SDK. A full list of available transitions types is here.