From 81e35d46b8918c6472e110b21f3d65dc438e8586 Mon Sep 17 00:00:00 2001 From: Steven Polley Date: Thu, 29 Oct 2020 19:13:12 +0000 Subject: [PATCH] fix incompatible file names (android wtf?) --- main.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index a8b4521..424f356 100644 --- a/main.go +++ b/main.go @@ -28,7 +28,6 @@ var ( ) func init() { - log.Print("storage-security starting") img = gocv.NewMat() imgDelta = gocv.NewMat() @@ -48,8 +47,8 @@ func main() { log.Fatalf("error opening log file: %v", err) } defer f.Close() - log.SetOutput(f) + log.Print("storage-security starting") webcam, err := gocv.OpenVideoCapture(deviceID) if err != nil { @@ -84,8 +83,8 @@ func main() { if frameCount >= motionDetectInterval { if detectMotion(img) { // Determine if a new recording needs to start - if time.Now().After(lastMotionDetectedTime.Add(time.Second * recordLengthAfterMotion)) { - fileName := fmt.Sprintf("%s/storage-security-%s.avi", syncFolder, time.Now().Format(time.RFC3339)) + if time.Now().After(lastMotionDetectedTime.Add(time.Second * recordLengthAfterMotion)) { // + fileName := fmt.Sprintf("%s/storage-security-%s.avi", syncFolder, time.Now().Format("2006-01-02-15-04-05")) log.Printf("motion detected, started recording to file named %s", fileName) currentRecording, err = gocv.VideoWriterFile(fileName, "MJPG", 25, img.Cols(), img.Rows(), true) if err != nil {