How to change ffmpeg process priority?

I'm trying to find a way to set ffmpeg process priority. Server converts incoming videos to different resolutions, new videos should have higher priority and be converted faster, than existing processes.

It should work similar to SJF (Shortest Job First) or LIFO (Last In First Out) algorithms.

Is there any way to do it with ffmpeg?

I spawn processes this likeffmpeg -i "${video_path}" -strict experimental -movflags faststart -vf "${resolution}" "${output_path}" >> "${ffmpeg_log}" 2>&1

Note:

I have already tested nice based solution. It looks like it doesn't work. I spawned 2 ffmpeg process with priority 10 and -10, and that which was spawned earlier was completed earlier

1

1 Answer

You simply call nice before calling the process, along with the niceness value.

The man pages for nice will show you how to figure out exactly how 'nice' a process is, i.e. lower values == less nice, higher priority.

nice --5 "ffmpeg -i...." would launch ffmpeg with a nice value of -5, making it higher priority than something with a nice value of -1.

0 is normally the default, a higher value than this means you'd have less than default priority.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like