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

Nicholas Robbins nickrobbins at yahoo.com
Sat Jan 10 19:44:07 CET 2015



On Saturday, January 10, 2015 1:26 PM, "voip at gmx.ca" <voip at gmx.ca> wrote:
>
>
>> Apart from that, Andy's mentioned cpufreq approach seems correct.
>
>Of the two approaches, "cpulimit" seemed the easiest to implement although it confuses me.  According to the documentation, if I run this:
>
>cpulimit -z -e ffmpeg -l 95
>
>It should limit CPU usage to 95%, which one would not think is a significant drop from 100%, yet just reducing it that much makes a huge difference.  Running that, the CPU temperature stays at a much more reasonable 40 - 41 degrees Celsius.
>
>Of course that comes at the expense of much longer running time, but my plan was to run ffmpeg from a shell script in the middle of the night anyway.  And therein lies the problem.  In order to work, cpulimit must be started AFTER ffmpeg, and when the shell script gets to ffmpeg it doesn't move on to the next command until ffmpeg is finished.  And I would not really want it to, because the shell script will also do a file move/replace that can only be done after ffmpeg is finished.
>

>So basically I would need to start ffmpeg, then without moving along in the shell script, start cpulimit a second or two later (just long enough to make sure ffmpeg has started).  I can't really wrap my head around how to do that right now.

Put something like the following line in your bash script right before the ffmpeg invocation:

( sleep 10s ; cpulimit -z -e ffmpeg -l 95 ) &

That should start and not wait to finish (a timer of 10 seconds and then run the cuplimit command) and then continue on with your script.

Does that make sense?

Nick


More information about the ffmpeg-user mailing list