An application built on the SDK usually runs several processes: the application itself and MServer.exe processes. The SDK starts MServer.exe to run some objects outside the application, for example file readers and the FFmpeg writer. When the CPU is busy, Windows shares its time by process priority. A process that handles video and gets too little time drops or stutters video and audio, even at 80–85% CPU load.
MServer processes
The SDK starts every MServer.exe with the Realtime priority. Windows gives Realtime only when the application has the "Increase scheduling priority" privilege, which it normally has when it runs as administrator. Otherwise Windows gives High, and the SDK writes this to its log.
To get Realtime, run the application as administrator. To start MServer processes with another priority, set mserver.priority on the factory before you create SDK objects. The values are normal, above_normal, high and realtime:
// MFormats: MFORMATSLib.MFFactoryClass, MPlatform: MPLATFORMLib.MFFactoryClass
MFFactoryClass factory = new MFFactoryClass();
factory.PropsSet("mserver.priority", "high");
The setting applies to MServer processes that start after it; running ones keep their priority. More details are in Create and manage an object in an external process.
Do not change the priority of MServer.exe in Task Manager or by process name from your code: other applications on the computer can run their own MServer.exe processes.
The application process
The SDK does not change the priority of the application's own process. Raise it in the application, for example to High:
using (Process self = Process.GetCurrentProcess())
{
self.PriorityClass = ProcessPriorityClass.High;
}
Realtime for the whole application is rarely needed: when such a process takes all CPU time, Windows can stop responding to the mouse and keyboard.
To check the result, open Task Manager, go to the Details tab and add the Base priority column (right-click a column header, Select columns).
Still have questions?
Tell us what didn’t work or what you’d like clarified.