[FFmpeg-user] How can I reduce the cpu usage of ffmpeg?

voip at gmx.ca voip at gmx.ca
Sat Jan 10 10:41:07 CET 2015


I am using ffmpeg to reduce the bitrate and size of high-bitrate videos via a bash shell script that would eventually be run from a cron job.  The line that is called looks something like this:

/usr/bin/ionice -c 3 /usr/bin/nice -n 20 /usr/local/bin/ffmpeg -y -i "original_video" -c:v libx264 -b:v 16711680 -pix_fmt yuv420p -c:a copy -c:s copy "converted_video"

Note that I am running both ionice and nice to give ffmpeg the lowest possible priority, yet it still maxes out my CPU.  The problem with that is that my CPU temperature rather quickly rises from a rather tepid 28 degrees Celsius to a blistering 58 degrees Celsius rather quickly (yes, that is a full 30 Celsius degrees higher!).  If it only took a minute or two to do the conversion I would not be so worried about it, but it looked like it was going to take a bit less than 2 hours to complete. and I really don't want the cpu baking at that temperature for any length of time.

Keeping in mind that I'm trying to come up with something that can be run as a cron job, so I need a solution that doesn't require any input from me.  Given that, how can I force ffmpeg to use less CPU time?  It won't matter to me if it takes four hours to do a conversion instead of two, but it will bother me greatly if the CPU fails prematurely.  The use of the threads=1 option doesn't help, and apparently neither do nice or ionice.

How can I force ffmpeg to really be nicer to my CPU?  This is running on Debian Wheezy, if that makes any difference.


More information about the ffmpeg-user mailing list