Skip to content

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

start checking space again

roryclear47b0b6eb537c
diff --git a/clearcam/ViewController.m b/clearcam/ViewController.m
index 3b8ccfb..caf6eab 100644
--- a/clearcam/ViewController.m
+++ b/clearcam/ViewController.m
@@ -28,7 +28,7 @@
@property (nonatomic, strong) NSMutableArray *current_segment_squares;
@property (nonatomic, strong) NSLock *segmentLock;
-#define MIN_FREE_SPACE_MB 200 //threshold to start deleting
+#define MIN_FREE_SPACE_MB 21200 //threshold to start deleting
@end
@@ -488,10 +488,12 @@ NSMutableDictionary *classColorMap;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
double freeSpace = (double)[[[[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:nil] objectForKey:NSFileSystemFreeSize] unsignedLongLongValue] / (1024.0 * 1024.0 * 1024.0);
NSLog(@"Current free space: %.2f GB", freeSpace);
+ if(freeSpace < MIN_FREE_SPACE_MB){
+ NSLog(@"NOT ENOUGH SPACE!");
+ }
});
}
-
- (void)captureOutput:(AVCaptureOutput *)output didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
@try {
if (self.isRecording && self.assetWriter.status == AVAssetWriterStatusWriting) {
diff --git a/clearcam/player.html b/clearcam/player.html
index bd05014..cdd471a 100644
--- a/clearcam/player.html
+++ b/clearcam/player.html
@@ -687,20 +687,39 @@
const oldTotalDuration = totalDuration;
let cumulativeStart = totalDuration;
- for (let i = 0; i < newSegments.length - 1; i++) {
+ let i = 0;
+ while (i < newSegments.length - 1) {
+ // Find the next valid segment with a timeStamp
+ while (i < newSegments.length - 1 && newSegments[i].timeStamp == null) {
+ i++; // Skip this segment
+ }
+ if (i >= newSegments.length - 1) break; // Stop if no valid segment is found
+
const segment = newSegments[i];
- const timeDifference = newSegments[i+1].timeStamp - newSegments[i].timeStamp;
+
+ // Find the next valid segment with a timeStamp
+ let nextIndex = i + 1;
+ while (nextIndex < newSegments.length && newSegments[nextIndex].timeStamp == null) {
+ nextIndex++; // Skip invalid segments
+ }
+ if (nextIndex >= newSegments.length) break; // No more valid segments
+
+ const timeDifference = newSegments[nextIndex].timeStamp - segment.timeStamp;
const lostFrames = timeDifference - segment.duration;
const currentCumulativeStart = cumulativeStart;
cumulativeStart += timeDifference;
+
segments.push({
...segment,
cumulativeStart: currentCumulativeStart,
lostFrames: lostFrames > 0 ? lostFrames : 0,
});
- if(lostFrames > 60){ //todo why 60
- gaps.push([currentCumulativeStart + segment.duration,lostFrames]);
+
+ if (lostFrames > 60) { // TODO: Why 60?
+ gaps.push([currentCumulativeStart + segment.duration, lostFrames]);
}
+
+ i = nextIndex; //
}
totalDuration = segments[segments.length-1].duration + (segments[segments.length - 1].timeStamp - segments[0].timeStamp);
if (totalDuration !== oldTotalDuration) {