fix incompatible file names (android wtf?)

This commit is contained in:
Steven Polley 2020-10-29 19:13:12 +00:00
parent 1dd43417c7
commit 81e35d46b8
1 changed files with 3 additions and 4 deletions

View File

@ -28,7 +28,6 @@ var (
) )
func init() { func init() {
log.Print("storage-security starting")
img = gocv.NewMat() img = gocv.NewMat()
imgDelta = gocv.NewMat() imgDelta = gocv.NewMat()
@ -48,8 +47,8 @@ func main() {
log.Fatalf("error opening log file: %v", err) log.Fatalf("error opening log file: %v", err)
} }
defer f.Close() defer f.Close()
log.SetOutput(f) log.SetOutput(f)
log.Print("storage-security starting")
webcam, err := gocv.OpenVideoCapture(deviceID) webcam, err := gocv.OpenVideoCapture(deviceID)
if err != nil { if err != nil {
@ -84,8 +83,8 @@ func main() {
if frameCount >= motionDetectInterval { if frameCount >= motionDetectInterval {
if detectMotion(img) { if detectMotion(img) {
// Determine if a new recording needs to start // Determine if a new recording needs to start
if time.Now().After(lastMotionDetectedTime.Add(time.Second * recordLengthAfterMotion)) { if time.Now().After(lastMotionDetectedTime.Add(time.Second * recordLengthAfterMotion)) { //
fileName := fmt.Sprintf("%s/storage-security-%s.avi", syncFolder, time.Now().Format(time.RFC3339)) 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) log.Printf("motion detected, started recording to file named %s", fileName)
currentRecording, err = gocv.VideoWriterFile(fileName, "MJPG", 25, img.Cols(), img.Rows(), true) currentRecording, err = gocv.VideoWriterFile(fileName, "MJPG", 25, img.Cols(), img.Rows(), true)
if err != nil { if err != nil {