Streamedian / html5_rtsp_player

Play RTSP stream from IP camera in browser in this HTML5 player without plugins
Apache License 2.0
2.61k stars 598 forks source link

CPU load problem #171

Open welanderr opened 3 years ago

welanderr commented 3 years ago

Hi,

I am having a problem that I hope some one can help me with.

Opening a stream in the browser gives me a sustained cpu load of ~9 % tested in time frame of 10min, no problem there.

This is the problem I am having. Using one video canves and using a funcion that loops tro stream sourses (about 30+ streams) every 20sec and replaces the src in the canves, gives me incrementing cpu load on every stream change. Tested in time frame of 10min gives me a cpu load of ~39 %

This is the code I am using. I modifide the file download from her https://github.com/Streamedian/html5_rtsp_player/issues/137

This is the funcoin

(function recurse(counter) { var arrLength = camaraLink.length; var index = counter%arrLength;

    var camaraLinkSrc = camaraLink[index];

    setPlayerSource(camaraLinkSrc, 'test_video');

    setTimeout(function() {
    recurse(counter + 1);
    }, 20000);

})(0);
welanderr commented 3 years ago

I solved the problem with a "hack" using iframe and the video canvas in separate file it's not pretty but it works.

Solution

(function recurse(counter) { var arrLength = camaraLink.length; var index = counter%arrLength;

    var camaraLinkSrc = camaraLink[index];

    document.getElementById('video').src = 'http://192.168.10.50/camaras/iframe.php?link=' + camaraLinkSrc;

    setTimeout(function() {
    recurse(counter + 1);
    }, 30000);

})(0);