mirror of https://bitbucket.org/ausocean/av.git
PR changes #1
This commit is contained in:
parent
5286ded51f
commit
62af00ff4f
|
@ -8,7 +8,7 @@ AUTHORS
|
|||
Scott Barnard <scott@ausocean.org>
|
||||
|
||||
LICENSE
|
||||
variable_fps.go is Copyright (C) 2019 the Australian Ocean Lab (AusOcean)
|
||||
vfps.go is Copyright (C) 2019 the Australian Ocean Lab (AusOcean)
|
||||
|
||||
It is free software: you can redistribute it and/or modify them
|
||||
under the terms of the GNU General Public License as published by the
|
||||
|
@ -30,39 +30,38 @@ import (
|
|||
"io"
|
||||
)
|
||||
|
||||
// VariableFps is a filter that has a variable frame rate. When motion is
|
||||
// VariableFPSFilter is a filter that has a variable frame rate. When motion is
|
||||
// detected, the filter sends all frames and when it is not, the filter
|
||||
// sends frames at a reduced framerate.
|
||||
type VariableFps struct {
|
||||
motionFilter Filter
|
||||
dst io.WriteCloser
|
||||
frames uint
|
||||
count uint
|
||||
type VariableFPSFilter struct {
|
||||
filter Filter
|
||||
dst io.WriteCloser
|
||||
frames uint
|
||||
count uint
|
||||
}
|
||||
|
||||
// NewVariableFps returns a pointer to a new VariableFps filter.
|
||||
func NewVariableFps(dst io.WriteCloser, minFPS float64, debug bool) *VariableFps {
|
||||
// NewVariableFPSFilter returns a pointer to a new VariableFPSFilter struct.
|
||||
func NewVariableFPSFilter(dst io.WriteCloser, minFPS float64, filter Filter) *VariableFPSFilter {
|
||||
frames := uint(25 / minFPS)
|
||||
mf := NewMOGFilter(dst, 25, 20, 500, 3, debug)
|
||||
return &VariableFps{mf, dst, frames, 0}
|
||||
return &VariableFPSFilter{filter, dst, frames, 0}
|
||||
}
|
||||
|
||||
// Implements io.Writer.
|
||||
// Write applies the motion filter to the video stream. Frames are sent
|
||||
// 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) {
|
||||
func (v *VariableFPSFilter) Write(f []byte) (int, error) {
|
||||
v.count = (v.count + 1) % v.frames
|
||||
|
||||
if v.count == 0 {
|
||||
return v.dst.Write(f)
|
||||
}
|
||||
|
||||
return v.motionFilter.Write(f)
|
||||
return v.filter.Write(f)
|
||||
}
|
||||
|
||||
// Implements io.Closer.
|
||||
// Close calls the motion filter's Close method.
|
||||
func (v *VariableFps) Close() error {
|
||||
return v.motionFilter.Close()
|
||||
func (v *VariableFPSFilter) Close() error {
|
||||
return v.filter.Close()
|
||||
}
|
|
@ -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, true)
|
||||
r.filter = filter.NewVariableFPSFilter(r.encoders, 1.0, filter.NewMOGFilter(r.encoders, 25, 20, 500, 3, true))
|
||||
default:
|
||||
panic("Undefined Filter")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue