revid: passing delay corresponding to fps into lexTo - fixing quality issue when streaming from raspivid (not sending stuff too fast)

This commit is contained in:
Saxon Milton 2018-09-24 15:57:00 +09:30
parent 9bf4ee4bf0
commit 0cf6014887
1 changed files with 6 additions and 1 deletions

View File

@ -458,6 +458,11 @@ func (r *Revid) startRaspivid() error {
"-fps", r.config.FrameRate,
)
}
d, err := strconv.Atoi(r.config.FrameRate)
if err != nil {
panic("arrgh")
}
delay := time.Second / time.Duration(d)
stdout, err := r.cmd.StdoutPipe()
if err != nil {
return err
@ -469,7 +474,7 @@ func (r *Revid) startRaspivid() error {
r.inputReader = stdout
go func() {
r.config.Logger.Log(smartlogger.Info, pkg+"reading camera data")
r.lexTo(r.encoder, r.inputReader, 0)
r.lexTo(r.encoder, r.inputReader, delay)
r.config.Logger.Log(smartlogger.Info, pkg+"not trying to read from camera anymore")
}()
return nil