Add configurable threshold

This commit is contained in:
richardsonjack 2017-12-07 14:03:55 +10:30
parent d3b67e26c3
commit 84057782d4
1 changed files with 3 additions and 10 deletions

View File

@ -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)