guysoft / OctoPi

Scripts to build OctoPi, a Raspberry PI distro for controlling 3D printers over the web
GNU General Public License v3.0
2.48k stars 367 forks source link

[Improvement] When using HLS camera streamer, generate frame snapshot only once a second #755

Closed rastapasta closed 2 years ago

rastapasta commented 2 years ago

When using the experimental HLS camera streamer, an image snapshot is being generated for each frame, encoded to JPG and atomically written to the filesystem.

This creates a huge CPU cycle and IO burden at the configured 30 fps - when running on a Raspberry 3B, the current setup consumes over ~70% CPU.

With this PR, ffmpeg is configured to only generate a snapshot once a second, reducing the resulting CPU load to ~20% on a RP 3B.

guysoft commented 2 years ago

Related to #650 @chudsaviet any comments on this?

chudsaviet commented 2 years ago

Looks good! Never thought thats the JPEG stream consuming most of CPU.

rastapasta commented 2 years ago

Never thought thats the JPEG stream consuming most of CPU.

Was surprised as well.. initially was just wondering why the hardware accelerated h264_omx would use so many CPU cycles until priming in on the non-accelerated MJPEG encoding.

Btw, thanks for this amazing project & your folks' work!

guysoft commented 2 years ago

Thank you for your contribution!