revid & cmd/revid-cli: InputFPS field now FileFPS and added check so that only used with File input

This commit is contained in:
Saxon 2020-01-25 09:39:42 +10:30
parent 64754f7e0f
commit f82ab42246
3 changed files with 9 additions and 10 deletions

View File

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

View File

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

View File

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