From 84057782d4b07acc20b297e2d3a653ad9608dee6 Mon Sep 17 00:00:00 2001 From: richardsonjack Date: Thu, 7 Dec 2017 14:03:55 +1030 Subject: [PATCH] Add configurable threshold --- revid/revid.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/revid/revid.go b/revid/revid.go index 3cd715d9..fb77acc3 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -75,7 +75,7 @@ const ( bufferSize = 1000/clipDuration bitrateOutputDelay = 60 // s httpTimeOut = 5 // s - motionThreshold = 0 + motionThreshold = "0.0025" ) // flag values @@ -173,7 +173,7 @@ func main() { case err := <-inputErrChan: fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, "Trying again in 10s") - //time.Sleep(10 * time.Second) + time.Sleep(10 * time.Second) go input(*inputURL, *outputURL) case err := <-outputErrChan: fmt.Fprintln(os.Stderr, err) @@ -247,7 +247,7 @@ func input(input string, output string) { if *flags&filterMotionDetect != 0{ args := []string{ "-i", input, - "-vf", "select=gt(scene\\,0.0025),setpts=N/(FRAME_RATE*TB)", + "-vf", "select=gt(scene\\,"+motionThreshold+"),setpts=N/(FRAME_RATE*TB)", "-f", "mpegts", "-", } @@ -337,12 +337,6 @@ func clipStore(br *bufio.Reader, input string){ _, err := io.ReadFull(br, clip[clipSize:upperBound]) - for err != nil && err.Error() == "EOF"{ - fmt.Println("EOF") - fmt.Println(br.Buffered()) - time.Sleep(time.Second) - _, err = io.ReadFull(br, clip[clipSize:upperBound]) - } if err != nil { inputErrChan <- err @@ -420,7 +414,6 @@ func output(output string) { now := time.Now() err := sendClip(clip, output, conn) - sendClipToStdout(clip, output, conn) for err != nil { outputErrChan <- err err = sendClip(clip, output, conn)