Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I limit FFMpeg CPU usage?

Tags:

c#

ffmpeg

I am calling FFMpeg inside a C# Windows Forms application. Since it uses so much CPU (always above 90%), none of my threads can continue working. Is there a way to limit this CPU usage?

I've tried to set Process.PriorityClass to PriorityClass.BelowNormal but this totally blocked the ffmpeg process.

I am sure there is a way to do this since I see a lot of programs that utilize ffmpeg.

Please help.

like image 354
Mert Sevinc Avatar asked Dec 30 '10 19:12

Mert Sevinc


People also ask

How to reduce CPU usage of FFMpeg?

FFMpeg has an option -threads . You can define there, if it's going to be auto (default) or you can limit the number of used threads (CPU cores). Recommended that you set your number based on the amount of available threads minus 1, or 2. So if you have 8 threads, setting to -threads 6 would be great.


1 Answers

You can't limit FFMpeg to a percentage of CPU use, but you can set the -threads parameter on your FFMpeg call, if you have 4 cores try set it to -threads 2 that should limit you to around 50% CPU.

Another solution might be to lower the priority on your FFMpeg process, to something lower than your applications.

like image 157
Jesper Fyhr Knudsen Avatar answered Sep 19 '22 18:09

Jesper Fyhr Knudsen