B
B
Barmunk2020-02-03 17:22:26
Video
Barmunk, 2020-02-03 17:22:26

How to reduce cpu load with ffmpeg libx264?

There is a simple vps with one core, it is transcoding the stream from rtsp to rtmp. If you drive the stream one to one 1920 * 1080, the processor load is about 2-5%.

ffmpeg 
-i rtsp://localhost/$app/$name
-c copy 
-f flv rtmp://localhost:1935/show_decode/$name_src


but as soon as I try to reduce the video resolution to hd720 using libx264 codec, the load immediately increases to 20-30%, which hits performance very hard

- disabling audio does not help
- preset ultrafast \ superfast \ veryfast ... works, but the maximum decreases to 20%
- crf 23, almost does not help, maximum 1-2% with maximum deterioration

ffmpeg 
-i rtsp://localhost/$app/$name
-c:v libx264 
-c:a aac 
-b:v 1920k 
-b:a 128k 
-vf "scale=1280:trunc(ow/a/2)*2" 
-tune zerolatency 
-preset ultrafast 
-crf 23 
-f flv rtmp://localhost:1935/show_decode/$name_hd720


How can I reduce the CPU load even more?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Efimov, 2020-02-03
@A_M

Logically, ffmpeg starts to shovel the video stream. Maybe it's better to take the second 720p stream from the camera to another ffmpeg?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question