c# - 如何限制 FFMpeg CPU 使用率?

标签 c# performance ffmpeg

我在 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 进程。

还有别的出路吗?

最佳答案

此处概述的解决方案

How can I limit FFMpeg CPU usage?

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

根据您的评论,您可以提供 Argument via 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();

关于c# - 如何限制 FFMpeg CPU 使用率?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11357713/

相关文章:

c# - BinaryFormatter 字节顺序

php - 在 laravel 中使用 php-ffmpeg 转换和保存视频时编码失败

c# - 如何更改 Windows 程序中的主机文件?

c++ - 为什么 D 中的并行代码如此糟糕?

java - 锁定缓存键而不锁定整个缓存

c++ - Visual Studio Profiler 不显示源代码位置

带有javaCV的FFMPEG无法打开流

video - 使用 FFMPEG 将视频转换为 PowerPoint 2016 兼容的视频格式

c# - 如何正确地将 JSON 字符串反序列化为包含另一个类的嵌套列表的类

c# - 在 DataGrid 中突出显示 SelectedItem 的行