Decrease CPU usage?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Decrease CPU usage?

Diego Patricio Durante
Hello community! I have RTSP streams from cameras, and I'm interested
to save it to a disk and share as MP4. The main problems are the trade
off between disk usage and CPU usage without converting the format nor
scaling the image sizes.

I'm using Ubuntu 18.04 and saving chunk videos directly from RTSP
(h264), resizing the stream without using much more CPU. I'm using
ffmpeg and its dependencies installed directly from repositories.

Actual test:
* I'm using it on Azure, with an Intel Xeon server (for testing
purposes I have instanced two cores: https://pastebin.com/VauHZtLx),
but the idea is to select a good trade off between performance and
cost to get about 70 streams. I have seen that libx264 outputs a
generic flags usage trough ffmpeg:
* * using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
But I have the same outputs and CPU times on my I7 4th generation CPU.
Using the time command, to get
* The input is (full ffprobe on https://pastebin.com/0dT9ttLG):
    Stream #0:0: Video: mpeg4 (Simple Profile), yuv420p, 640x480 [SAR
1:1 DAR 4:3], 30 tbr, 30k tbn, 1k tbc
    Stream #0:1: Audio: amr_nb, 8000 Hz, mono, flt
* With this CPU I have tested to convert 7~10 streams from 30 to 5 fps
and it goes around 100 % without transcoding the input (only
downsizing the bitrate and the FPS).

I'm testing with the command:
time ffmpeg -re -rtsp_transport tcp -i
'rtsp://something:something@fdsfsdfdf' -t 10 -c:v libx264 -b:v 100k
-maxrate 100k -bufsize 50k -r 5 output2.mp4
Time output (full output on https://pastebin.com/VTabvgQS):
real    0m19.527s
user    0m2.510s
sys    0m0.102s


Problems to solve:
* Can I improve the performance of ffmpeg by compiling it?
* They are some guidelines to improve performance?

Thanks for all!
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Decrease CPU usage?

Carl Eugen Hoyos-2
Am Mo., 2. Nov. 2020 um 01:34 Uhr schrieb Diego Patricio Durante
<[hidden email]>:
>
> Hello community! I have RTSP streams from cameras, and I'm interested
> to save it to a disk and share as MP4. The main problems are the trade
> off between disk usage and CPU usage without converting the format nor
> scaling the image sizes.

Please always paste your console output, no external links please.

I don't understand above as you asked for conversion in your command
line (there should be no cpu issue if you are not converting).
In your command line, not FFmpeg but x264 is used for the conversion,
look at the presets (ultrafast, superfast, veryfast, faster etc.) to
reduce cpu usage.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Decrease CPU usage?

Diego Patricio Durante
Hello Carl, thanks for your reply, and sorry for the external links.

I'm only downsampling the video bit rate and the fps, but CPU
consumptions are not as low as I'd like (for a video of 640x480 to
make it of 10fps with as low as 200kbit/s, it consumes about 15~20% of
a core and it increases if I increase the video bit rate).

Do you know if there are compilation tricks that can improve the running speed?

PD: Thanks for the suggestion, I should benchmark it better but in the
first tests, presets worked for extreme cases (preset ultrafast) but
are not producing changes for fast or faster

Thanks for everything. Best regards,
Diego
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Decrease CPU usage?

andrei ka
btw, today on aws it's cheaper+faster to encode on nvidias (mean, not on
elemental,on  ec2+gpu)...
" Gains are variable, and usually quite small."
https://trac.ffmpeg.org/wiki/CompilationGuide -> performance tips...

&rei
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Decrease CPU usage?

Anatoly
In reply to this post by Diego Patricio Durante
On Sun, 1 Nov 2020 21:11:53 -0300
Diego Patricio Durante <[hidden email]> wrote:

> Hello community! I have RTSP streams from cameras, and I'm interested
> to save it to a disk and share as MP4. The main problems are the trade
> off between disk usage and CPU usage without converting the format nor
> scaling the image sizes.
more exact words is "without changing", not "converting" ?

>
> I'm using Ubuntu 18.04 and saving chunk videos directly from RTSP
> (h264), resizing the stream without using much more CPU. I'm using
> ffmpeg and its dependencies installed directly from repositories.
>
> Actual test:
> * I'm using it on Azure, with an Intel Xeon server (for testing
> purposes I have instanced two cores: https://pastebin.com/VauHZtLx),
> but the idea is to select a good trade off between performance and
> cost to get about 70 streams. I have seen that libx264 outputs a
> generic flags usage trough ffmpeg:
> * * using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2
> AVX2 But I have the same outputs and CPU times on my I7 4th
> generation CPU. Using the time command, to get
> * The input is (full ffprobe on https://pastebin.com/0dT9ttLG):
>     Stream #0:0: Video: mpeg4 (Simple Profile), yuv420p, 640x480 [SAR
> 1:1 DAR 4:3], 30 tbr, 30k tbn, 1k tbc
>     Stream #0:1: Audio: amr_nb, 8000 Hz, mono, flt
> * With this CPU I have tested to convert 7~10 streams from 30 to 5 fps
> and it goes around 100 % without transcoding the input (only
> downsizing the bitrate and the FPS).
>
> I'm testing with the command:
> time ffmpeg -re -rtsp_transport tcp -i
> 'rtsp://something:something@fdsfsdfdf' -t 10 -c:v libx264 -b:v 100k
> -maxrate 100k -bufsize 50k -r 5 output2.mp4
> Time output (full output on https://pastebin.com/VTabvgQS):
> real    0m19.527s
> user    0m2.510s
> sys    0m0.102s
>
>
> Problems to solve:
> * Can I improve the performance of ffmpeg by compiling it?
Need to improving performance of encoder library (libx264 in this
case), not ffmpeg itself.
> * They are some guidelines to improve performance?
This may be outdated, because I've tested it several years ago, but
openh264 library (-c:v libopenh264) is about 4x faster than libx264
(with no extra parameters given).
Do you have particular reason to stick with h264 compression?
msmpeg4 (aka divx ?) is about 7x faster.
> Thanks for all!
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
>

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".