Add object detection, tracking, mobile notifications, and search to any security camera.
send small video too
roryclear692ca8056b05
diff --git a/clearcam/FileServer.h b/clearcam/FileServer.hindex 30dec1b..dc28734 100644--- a/clearcam/FileServer.h+++ b/clearcam/FileServer.h@@ -8,6 +8,10 @@- (void)start;- (NSArray *)fetchEventDataFromCoreData:(NSManagedObjectContext *)context;+- (NSString *)processVideoDownloadWithLowRes:(BOOL)low_res+ startTime:(NSTimeInterval)startTimeStamp+ endTime:(NSTimeInterval)endTimeStamp+ context:(NSManagedObjectContext *)context;@property (nonatomic, assign) NSInteger segment_length;@property (nonatomic, strong) NSDate *last_req_time;@property (nonatomic, strong) PortScanner *scanner;diff --git a/clearcam/FileServer.m b/clearcam/FileServer.mindex a2d2de3..9213ace 100644--- a/clearcam/FileServer.m+++ b/clearcam/FileServer.m@@ -1212,7 +1212,26 @@return nil;}- return outputPath;+ // Rename the output file using timestamps+ NSDateFormatter *renameFormatter = [[NSDateFormatter alloc] init];+ [renameFormatter setDateFormat:@"yyyy-MM-dd_HH-mm-ss"];+ NSString *startTimeStr = [renameFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:startTimeStamp]];+ NSString *endTimeStr = [renameFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:endTimeStamp]];+ NSString *newFileName = [NSString stringWithFormat:@"%s-%s.mp4", startTimeStr.UTF8String, endTimeStr.UTF8String];++ // Get the directory of the original outputPath and construct the new path+ NSString *directory = [outputPath stringByDeletingLastPathComponent];+ NSString *newOutputPath = [directory stringByAppendingPathComponent:newFileName];++ // Rename the file+ NSError *renameError = nil;+ [[NSFileManager defaultManager] moveItemAtPath:outputPath toPath:newOutputPath error:&renameError];+ if (renameError) {+ NSLog(@"Failed to rename file: %@", renameError);+ return outputPath; // Return original path if renaming fails+ }++ return newOutputPath;}@enddiff --git a/clearcam/SceneState.m b/clearcam/SceneState.mindex e653da5..8a3b697 100644--- a/clearcam/SceneState.m+++ b/clearcam/SceneState.m@@ -2,6 +2,7 @@#import "SettingsManager.h"#import "SecretManager.h"#import "AppDelegate.h"+#import "FileServer.h"#import "Email.h"#import <MobileCoreServices/MobileCoreServices.h> // Add this import#import <CommonCrypto/CommonCryptor.h>@@ -99,7 +100,7 @@NSData *lowResImageData = UIImageJPEGRepresentation(resizedImage, 0.7);[lowResImageData writeToFile:filePathSmall atomically:YES];- if (self.last_email_time && [[NSDate date] timeIntervalSinceDate:self.last_email_time] > 60) { // only once per hour? enforce server side!+ if (self.last_email_time && [[NSDate date] timeIntervalSinceDate:self.last_email_time] > 120) { // only once per hour? enforce server side!NSLog(@"sending email");//if ([[NSUserDefaults standardUserDefaults] boolForKey:@"send_email_alerts_enabled"] &&// ([[NSUserDefaults standardUserDefaults] boolForKey:@"isSubscribed"] ||@@ -122,6 +123,14 @@if (currentTime >= startTime && currentTime <= endTime) {[[Email sharedInstance] sendEmailWithImageAtPath:filePath];self.last_email_time = now;+ if([FileServer sharedInstance].segment_length > 3) [FileServer sharedInstance].segment_length = 3;+ NSTimeInterval start = [[NSDate dateWithTimeIntervalSinceNow:-7.5] timeIntervalSince1970];+ NSTimeInterval end = [[NSDate dateWithTimeIntervalSinceNow:7.5] timeIntervalSince1970];+ id context = [FileServer sharedInstance].context;+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_SEC)), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{+ NSString *filePath = [[FileServer sharedInstance] processVideoDownloadWithLowRes:YES startTime:start endTime:end context:context];+ [[Email sharedInstance] sendEmailWithImageAtPath:filePath];+ });NSLog(@"Email sent: Within scheduled time");break;}