2

我在 C# Windows 窗体应用程序中调用 FFMpeg。由于它使用了如此多的 CPU(几乎 100%),我的所有线程都无法继续工作。有没有办法限制这种 CPU 使用率?

下面是我的工作代码,

Process ffmpeg = new Process();
ffmpeg.StartInfo.UseShellExecute = false;
ffmpeg.StartInfo.FileName = '..\ffmpeg.exe'
ffmpeg.StartInfo.CreateNoWindow = true;
ffmpeg.Start();

我试图将 Process.PriorityClass 设置为 PriorityClass.BelowNormal 但这完全阻止了 ffmpeg 进程。

有没有其他的出路?

4

1 回答 1

3

此处概述的解决方案

如何限制 FFMpeg CPU 使用率?

是将FFMpeg使用的线程数限制为少于计算机上可用内核的数量。

跟进您的评论,您可以通过 StartInfo 提供参数

Process ffmpeg = new Process();
ffmpeg.StartInfo.UseShellExecute = false;
ffmpeg.StartInfo.FileName = "..\ffmpeg.exe";
ffmpeg.StartInfo.Arguments = "-threads 2";  // <=== Add this line
ffmpeg.StartInfo.CreateNoWindow = true;
ffmpeg.Start();
于 2012-07-06T07:32:20.233 回答