From f82ab422463dcc7db3fccc335011bc0b0754212c Mon Sep 17 00:00:00 2001 From: Saxon Date: Sat, 25 Jan 2020 09:39:42 +1030 Subject: [PATCH] revid & cmd/revid-cli: InputFPS field now FileFPS and added check so that only used with File input --- cmd/revid-cli/main.go | 2 +- revid/config/config.go | 15 +++++++-------- revid/revid.go | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cmd/revid-cli/main.go b/cmd/revid-cli/main.go index 3d03916b..5db8e9a1 100644 --- a/cmd/revid-cli/main.go +++ b/cmd/revid-cli/main.go @@ -133,7 +133,7 @@ func handleFlags() config.Config { saturationPtr = flag.Int("Saturation", 0, "Set Saturation. (100-100)") exposurePtr = flag.String("Exposure", "auto", "Set exposure mode. ("+strings.Join(raspivid.ExposureModes[:], ",")+")") autoWhiteBalancePtr = flag.String("Awb", "auto", "Set automatic white balance mode. ("+strings.Join(raspivid.AutoWhiteBalanceModes[:], ",")+")") - inputFPSPtr = flag.Int("InputFPS", 0, "Input source processing FPS") + fileFPSPtr = flag.Int("FileFPS", 0, "File source frame processing FPS") // Audio specific flags. sampleRatePtr = flag.Int("SampleRate", 48000, "Sample rate of recorded audio") diff --git a/revid/config/config.go b/revid/config/config.go index 8ee31ee5..b70a01b3 100644 --- a/revid/config/config.go +++ b/revid/config/config.go @@ -86,7 +86,7 @@ const ( defaultAudioInputCodec = codecutil.ADPCM defaultPSITime = 2 defaultMotionInterval = 5 - defaultInputFPS = 0 + defaultFileFPS = 0 // Ring buffer defaults. defaultRBMaxElements = 10000 @@ -302,9 +302,8 @@ type Config struct { // If true will restart reading of input after an io.EOF. Loop bool - // Defines the rate at which an input source is processed. If reading - // from a realtime source, InputFPS is not necessary and should be 0 (default). - InputFPS int + // Defines the rate at which frames from a file source are processed. + FileFPS int } // TypeData contains information about all of the variables that @@ -319,6 +318,7 @@ var TypeData = map[string]string{ "CBR": "bool", "ClipDuration": "uint", "Exposure": "enum:auto,night,nightpreview,backlight,spotlight,sports,snow,beach,verylong,fixedfps,antishake,fireworks", + "FileFPS": "int", "Filters": "enums:NoOp,MOG,VariableFPS,KNN", "FrameRate": "uint", "Height": "uint", @@ -326,7 +326,6 @@ var TypeData = map[string]string{ "HTTPAddress": "string", "Input": "enum:raspivid,rtsp,v4l,file", "InputCodec": "enum:H264,MJPEG", - "InputFPS": "int", "InputPath": "string", "KNNHistory": "uint", "KNNKernel": "float", @@ -531,9 +530,9 @@ func (c *Config) Validate() error { } } - if c.InputFPS <= 0 { - c.Logger.Log(logger.Info, pkg+"InputFPS bad or unset, defaulting", "InputFPS", defaultInputFPS) - c.InputFPS = defaultInputFPS + if c.FileFPS <= 0 || (c.FileFPS > 0 && c.Input != InputFile) { + c.Logger.Log(logger.Info, pkg+"FileFPS bad or unset, defaulting", "FileFPS", defaultFileFPS) + c.FileFPS = defaultFileFPS } return nil diff --git a/revid/revid.go b/revid/revid.go index 3d9d26c5..5d8c81d0 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -429,7 +429,7 @@ func (r *Revid) Start() error { } // Calculate delay between frames based on InputFPS. - d := time.Duration(1000/r.cfg.InputFPS) * time.Millisecond + d := time.Duration(1000/r.cfg.FileFPS) * time.Millisecond r.wg.Add(1) go r.processFrom(r.input, d)