How to restrict CPU load of FFmpeg call?

Viewed 31

As described here, for example, I'm using FFmpeg to check video file integrity like this:

ffmpeg -v error -i input.mp4 -f null -

Since I plan to run this in the background, I want to limit the CPU load. I already tried -threads 1, -filter_threads 1, -filter_complex_threads 1. Nothing helps and FFmpeg still uses as many cores as it can get. Which parameter am I overlooking?

1 Answers

I'm not sure you can limit this via FFmpeg but if you are using a Linux operating system you can use the nice command to control the CPU priority. It will still use maximum available CPU but will deprioritise the ffmpeg command if you set a higher nice value.

You can run a command like this:

nice -n 10 ffmpeg -v error -i input.mp4 -f null -

See more about nice settings here if you are not familiar: https://www.nixtutor.com/linux/changing-priority-on-linux-processes/

Bear in mind that if you are trying to do this at scale or on a server you might be better off with some kind of queue system and multi-server setup. Video processing is generally computationally expensive and you are best dedicating a whole machine to each task rather than trying to run several tasks at once on the same machine.

Related