How to reduce CPU usage when it reaches 100% while converting video using ffmpeg

5,505

That seems to be a small server with 4 GB RAM and a virtual dual-core CPU that is most likely using shared resources. Obviously, this machine is not going to be able to handle video encoding tasks and serve a website at the same time, unless you make compromises in terms of the time it takes for the video encoding to complete.

Under Linux, you can run nice to reduce the priority of a process.

For example, run:

nice ffmpeg -i <input> <output>

The "niceness" values range from -20 to 19, and the higher, the lower priority a process gets. Without further options, nice adds 10 to the value of the process, which is 0 by default.

That said, I'd encourage you to not run web servers and intensive processing tasks on the same machine unless you can compartmentalize them in such a way that high resource consumption doesn't kill your website.

Share:
5,505

Related videos on Youtube

slhck
Author by

slhck

Updated on September 18, 2022

Comments

  • slhck
    slhck almost 2 years

    We are use ffmpeg for convert video to a specific form. The server is reaching 100% CPU usage, so my site is going down. That means the ffmpeg process has a strong effect on my main server.

    • LPChip
      LPChip about 5 years
      Are you running ffmpeg on the server itself, or does the server only holds the files?
    • Elisa Cha Cha
      Elisa Cha Cha about 5 years
      If you show your actual ffmpeg command and the complete log from the command we may be able to make more suggestions.