mirror of https://bitbucket.org/ausocean/av.git
revid & cmd/revid-cli: added InputFPS config.Config field
The InputFPS field can control rate at which we lex frames from the input source. This has not been a useful feature until now; we now want to simulate realtime input device using file input. This requires firstly the Loop mode, and now also realistic input rate.
This commit is contained in:
parent
99b931f948
commit
0f5aaf6cb5
|
@ -133,6 +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")
|
||||
|
||||
// Audio specific flags.
|
||||
sampleRatePtr = flag.Int("SampleRate", 48000, "Sample rate of recorded audio")
|
||||
|
@ -180,8 +181,6 @@ func handleFlags() config.Config {
|
|||
}
|
||||
}
|
||||
|
||||
cfg.Loop = *loopPtr
|
||||
|
||||
switch *inputPtr {
|
||||
case "Raspivid":
|
||||
cfg.Input = config.InputRaspivid
|
||||
|
@ -238,6 +237,8 @@ func handleFlags() config.Config {
|
|||
netsender.ConfigFile = *configFilePtr
|
||||
}
|
||||
|
||||
cfg.InputFPS = *inputFPSPtr
|
||||
cfg.Loop = *loopPtr
|
||||
cfg.CameraIP = *cameraIPPtr
|
||||
cfg.Rotation = *rotationPtr
|
||||
cfg.HorizontalFlip = *horizontalFlipPtr
|
||||
|
|
|
@ -86,6 +86,7 @@ const (
|
|||
defaultAudioInputCodec = codecutil.ADPCM
|
||||
defaultPSITime = 2
|
||||
defaultMotionInterval = 5
|
||||
defaultInputFPS = 0
|
||||
|
||||
// Ring buffer defaults.
|
||||
defaultRBMaxElements = 10000
|
||||
|
@ -300,6 +301,10 @@ 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
|
||||
}
|
||||
|
||||
// TypeData contains information about all of the variables that
|
||||
|
@ -321,15 +326,17 @@ 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",
|
||||
"KNNMinArea": "float",
|
||||
"KNNThreshold": "float",
|
||||
"logging": "enum:Debug,Info,Warning,Error,Fatal",
|
||||
"Loop": "bool",
|
||||
"MinFPS": "float",
|
||||
"MinFrames": "uint",
|
||||
"mode": "enum:Normal,Paused,Burst",
|
||||
"mode": "enum:Normal,Paused,Burst,Loop",
|
||||
"MOGHistory": "uint",
|
||||
"MOGMinArea": "float",
|
||||
"MOGThreshold": "float",
|
||||
|
@ -524,6 +531,11 @@ 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
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -428,8 +428,11 @@ func (r *Revid) Start() error {
|
|||
return err
|
||||
}
|
||||
|
||||
// Calculate delay between frames based on InputFPS.
|
||||
d := time.Duration(1000/r.cfg.InputFPS) * time.Millisecond
|
||||
|
||||
r.wg.Add(1)
|
||||
go r.processFrom(r.input, (1000/25)*time.Millisecond)
|
||||
go r.processFrom(r.input, d)
|
||||
|
||||
r.running = true
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue