roleoroleo / sonoff-hack

Custom firmware for Sonoff GK-200MP2B camera
GNU General Public License v3.0
203 stars 48 forks source link

Snapshot on ptz page makes CPU usage to 85% #129

Closed korskantevin closed 1 year ago

korskantevin commented 1 year ago

There is setTimeout function set to interval=1000 in all.js. in my case snapshot answer is only after 3 seconds. And "top" command via SSH says 85% user CPU usage on camera. So I think more accurate is to call on next snapshot only after receiving previous or get an error of previous call.

That is why in my case PTZ is not working оn web interface, but working fine via SSH "ptz -a right" which is ptz_h by default

darkxst commented 1 year ago

You could try something like this (not tested though):

        interval = 1000;

        (function p() {
            jQuery.get('cgi-bin/snapshot.sh?base64=yes', function(data) {
                image = document.getElementById('imgSnap');
                image.src = 'data:image/jpeg;base64,' + data;
            }).always(function() {
                setTimeout(p, interval);
           });

        })();
korskantevin commented 1 year ago

Works great! Thank you!

roleoroleo commented 1 year ago

Added to the master. Thank you.