Skip to content

Add object detection, tracking, mobile notifications, and search to any security camera.

new loop that should work for new backend delete thing

roryclear51962137a95f
diff --git a/clearcam/player.html b/clearcam/player.html
index 816cef4..15413f4 100644
--- a/clearcam/player.html
+++ b/clearcam/player.html
@@ -687,9 +687,21 @@
const oldTotalDuration = totalDuration;
let cumulativeStart = totalDuration;
- for (let i = 0; i < newSegments.length - 1; i++) {
+ let i = 0;
+ let next_i = 1;
+ while(next_i < newSegments.length) {
+ if(newSegments[i].timeStamp == 0.0){
+ i=next_i;
+ next_i+=1;
+ }
+ while(newSegments[next_i].timeStamp == 0.0 && next_i < newSegments.length){
+ next_i += 1;
+ }
+ if(next_i >= newSegments.length){
+ break;
+ }
const segment = newSegments[i];
- const timeDifference = newSegments[i+1].timeStamp - newSegments[i].timeStamp;
+ const timeDifference = newSegments[next_i].timeStamp - newSegments[i].timeStamp;
const lostFrames = timeDifference - segment.duration;
const currentCumulativeStart = cumulativeStart;
cumulativeStart += timeDifference;
@@ -698,11 +710,13 @@
cumulativeStart: currentCumulativeStart,
lostFrames: lostFrames > 0 ? lostFrames : 0,
});
- n_segments += 1;
if(lostFrames > 60){ //todo why 60
gaps.push([currentCumulativeStart + segment.duration,lostFrames]);
}
+ i=next_i;
+ next_i+=1;
}
+ n_segments += i;
totalDuration = segments[segments.length-1].duration + (segments[segments.length - 1].timeStamp - segments[0].timeStamp);
if (totalDuration !== oldTotalDuration) {
updateTimeline();
@@ -1078,3 +1092,4 @@
</html>
+