Small fixes and simplifications

This commit is contained in:
Scott 2019-12-27 13:51:50 +10:30
parent 9876b0cd35
commit 5286ded51f
2 changed files with 7 additions and 7 deletions

View File

@ -41,9 +41,9 @@ type VariableFps struct {
}
// NewVariableFps returns a pointer to a new VariableFps filter.
func NewVariableFps(dst io.WriteCloser, fps float64) *VariableFps {
frames := uint(25 / fps)
mf := NewMOGFilter(dst, 25, 20, 500, 3, true)
func NewVariableFps(dst io.WriteCloser, minFPS float64, debug bool) *VariableFps {
frames := uint(25 / minFPS)
mf := NewMOGFilter(dst, 25, 20, 500, 3, debug)
return &VariableFps{mf, dst, frames, 0}
}
@ -52,9 +52,9 @@ func NewVariableFps(dst io.WriteCloser, fps float64) *VariableFps {
// at a reduced frame rate, except when motion is detected, then all frames
// with motion are sent.
func (v *VariableFps) Write(f []byte) (int, error) {
v.count++
if v.count > v.frames {
v.count = 0
v.count = (v.count + 1) % v.frames
if v.count == 0 {
return v.dst.Write(f)
}

View File

@ -334,7 +334,7 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io.
case config.FilterMOG:
r.filter = filter.NewMOGFilter(r.encoders, 25, 20, 500, 3, true)
case config.FilterVariableFPS:
r.filter = filter.NewVariableFps(r.encoders, 1.0)
r.filter = filter.NewVariableFps(r.encoders, 1.0, true)
default:
panic("Undefined Filter")
}