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 like ffmpeg -i "${video_path}" -strict experimental -movflags faststart -vf "${resolution}" "${output_path}" >> "${ffmpeg_log}" 2>&1


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


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.

  • 1
    There's also renice – to affect a process that is already running. May 25 '17 at 16:03
  • 1
    The traditional '-increment' option has been deprecated (found here: nice --5). See man page of nice. Use nice -n -5 ... for a nice value of -5. (Rant: I can not edit the answer since the change would not have the required 6 characters. That stupid policy already caught me a few times when trying to improve answers in the Stack universe. Just not in the mood right now to artificially improve the answer more than necessary.)
    – jox
    Feb 3 '20 at 21:44

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.