To improve the performance and visual consistency of your mixed scenes, MMixer provides a synchronization mode (Sync Mode) as part of the MPlatform SDK.
In this mode, MMixer synchronizes the preparation of frames from all sources, resulting in smoother video and more stable audio output.
The difference between modes
When the sync mode is disabled, frames arrive to the MMixer object from the sources independently, each one with its own frame rate. If a frame does not arrive at the right time, the previous frame is duplicated. This makes MMixer rather stable, but the mixed picture may not look that good as the input sources are not mixed in sync. The mixed audio can also contain some artifacts.
Please note, you cannot disable sync mode if gpu_pipeline is enabled.
When the sync mode is enabled, MMixer prepare frames from sources to get the best mixed picture. Here's what you gain with sync mode:
It sets the FPS of the sources, so there's a stable frame flow.
It buffers the prepared frames in sync packets ready to be mixed.
It prepares the frames in the same thread where it does the mixing, which ensures that mixing starts only when frames from all sources are received.
The same source can be added to MMixer several times.
A lot less chance of frame drops and audio artifacts.
The mixed stream will be in sync with the input.
Example of the sync mode operation
For example, you have a 720_25p file added to the playlist, but the mixer format is 1080_29.97p, then after you add a playlist to the mixer or change the mixer format, the sync mode will automatically change the playlist format: it will take the file size and frame rate of the mixer:
Recommendations for using the sync mode
Please take the following into account when considering sync mode:
Always specify output resolution for MMixer object. Do not use "Auto" format. It will help MMixer to prepare input frames correctly.
We don't recommend using sync mode with unstable sources (such as DirectShow cameras or network streams), because unstable frame rate of the input source will lead to unstable frame rate of the mixed stream. We recommend mixing sources with stable frame rates to achieve good results.
In sync mode, MMixer sets the frame rate for the sources that are connected to it. If you don't want this to happen, you should add the source stream via mp:// protocol with "sync_mode.direct_mp_links = false".
- Consider disabling sync mode for one of the Mixers when adding one Mixer to another.
Options and registry settings
| Option | Default | Description |
| sync_mode | true | turns the sync mode on |
| sync_mode.async_get | true | "false" means the mixer grabs the frames from sources in sync manner, so if one source is delayed, other sources in the list also will be delayed. "true" - mixer grabs the frames from sources in async manner, so if one source is delayed, that will not delay other sources. |
| sync_mode.direct_mp_links | true | once enabled, forces MMixer to use a source object directly (to get the control over it) instead of mp:// links (which is not controllable). Gives better performance and less frame drops in a resulting stream, but controls the original object, which can make it unusable by other sink objects. |
| sync_mode.external_exclusive | false | once enabled, forces MMixer to control the source objects exclusively to get the best conditions for mixing. Makes source objects unaccessible by other sink objects. |
| sync_mode.external_keepres | false | for keeping specified output format for an external object (connected via mp:// links or via the direct pointer). |
| sync_mode.fixed_buffers | 0 | the number of buffered source frame packets. The source frames in these packets are in sync and ready for mixing, which eases the life for MMixer greatly. While having a fixed delay, it allows overcoming short CPU overloads without any effect on the output. And, in case of long CPU overload, it allows MMixer to drop the video of the buffered pack, but keep and mix the audio which makes such drops much less visible on the output. |
| sync_mode.input_buffers | 0 | set the number of input buffers for objects (Live and File) added to the Mixer. |
| sync_mode.mute_seek | true | mutes audio when seeking to avoid clicking. |