[FFmpeg-user] ffmpeg cpu loading

Dennis Mungai dmngaie at gmail.com
Fri Nov 12 17:08:59 EET 2021


On Fri, 12 Nov 2021 at 18:01, LianCheng <tanlccc at gmail.com> wrote:

> Hi,
>
> I tried to run several ffmpeg processes with different input mp4 files and
> to different outputs within my PC (having Intel Core i7). The mp4 video
> resolution is full HD format.
>
> ffmpeg -re -stream_loop -1 -i 1.mp4 -c:v libx264 -preset ultrafast -tune
> zerolatency -maxrate 2M -bufsize 2M -r 20 -g 60 -an -c:a copy -f rtsp
> rtsp://<ip_addr>:1935/cam-1
> ffmpeg -re -stream_loop -1 -i 2.mp4 -c:v libx264 -preset ultrafast -tune
> zerolatency -maxrate 2M -bufsize 2M -r 20 -g 60 -an -c:a copy -f rtsp
> rtsp://<ip_addr>:1935/cam-2
> ffmpeg -re -stream_loop -1 -i 3.mp4 -c:v libx264 -preset ultrafast -tune
> zerolatency -maxrate 2M -bufsize 2M -r 20 -g 60 -an -c:a copy -f rtsp
> rtsp://<ip_addr>:1935/cam-3
>   :
>   :
> ffmpeg -re -stream_loop -1 -i N.mp4 -c:v libx264 -preset ultrafast -tune
> zerolatency -maxrate 2M -bufsize 2M -r 20 -g 60 -an -c:a copy -f rtsp
> rtsp://<ip_addr>:1935/cam-N
>
> If I run 6 of the above ffmpeg processes, the CPU hits 100%.
>
> Are the parameters used optimized? I need to keep the CPU below 80%.
>
> Will having GPU (like nvidia)  help to increase the number of ffmpeg
> processes that can be run?
>
>
Hello there,

You  could try to reduce threads (set via threads  -n, where n is lower
than the number of total CPUs on your system).
I'd typically recommend a thread setting of no more than 4, especially for
hardware-based encoders such as Intel's QSV & VAAPI, and NVIDIA's NVENC.

A GPU-based encoder wrapper (depending on the platform you're on and the
implementation in use) *can* somewhat overcome that limitation, with
caveats:

1. NVIDIA's NVENC consumer GPUs are limited to 2 encode sessions per GPU.
This can be somewhat overcome with Keylase's patcher, see
https://github.com/keylase/nvidia-patch
2. Only very  specific codecs (and codec features) may be supported by the
hardware-accelerated encoder wrapper in use, and as such, outpuit may not
always be directly comparable to a software-based implementation.
Please see FFmpeg's HWAccel wiki on the same:
https://trac.ffmpeg.org/wiki/HWAccelIntro

Warm regards,

Dennis.


More information about the ffmpeg-user mailing list