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

Andy Furniss adf.lists at gmail.com
Sat Jan 10 11:21:16 CET 2015


voip at gmx.ca wrote:
> 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.


I don't think that 58 could be described as blistering, I would call
that normal. If you have it the command sensors should show what high
and critical are for your hardware.

My phenom box says 70/90 for these and running 60 is no worry for me -
as the temps get higher the fans will spin up to control it. I have a
fanless baytrail board where high/crit are 105.

If it didn't always be as high you could blow the dust out of the heatsink.

If you really want to cripple perf you may be able to do it via cpufreq.

I don't know if there is some gui control in debian to help you do that.

On this box if I want to be slow I would do -

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies

which will tell you what's available, for me it says -

3400000 2700000 2200000 800000

so if I want to make my quad core 3.4GHz phenom II into 800MHz I can do

echo 800000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 800000 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq
echo 800000 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq
echo 800000 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq

you could do this then restore your max with a cron job


More information about the ffmpeg-user mailing list