From ed9f6f5336fa8be76805f12ac5b0439595476fad Mon Sep 17 00:00:00 2001 From: Saxon Date: Fri, 22 Nov 2019 13:46:56 +1030 Subject: [PATCH] fixed typo and also defaulting to CBR for RTMP with geovision --- device/geovision/geovision.go | 15 +++++++++++++++ device/raspivid/raspivid.go | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/device/geovision/geovision.go b/device/geovision/geovision.go index 6f2a262a..646d0f62 100644 --- a/device/geovision/geovision.go +++ b/device/geovision/geovision.go @@ -140,6 +140,11 @@ func (g *GeoVision) Set(c avconfig.Config) error { c.MinFrames = defaultMinFrames } + // If we're using RTMP then we should default to constant bitrate. + if containsUint8(avconfig.OutputRTMP, c.Outputs) { + c.CBR = true + } + switch c.VBRQuality { case avconfig.QualityStandard, avconfig.QualityFair, avconfig.QualityGood, avconfig.QualityGreat, avconfig.QualityExcellent: default: @@ -332,3 +337,13 @@ func parseSvrRTCPPort(resp rtsp.Response) (int, error) { } return 0, errors.New("SETUP response did not provide RTCP port") } + +// containsUint8 checks if a []uint8 slice contains want. +func containsUint8(want uint8, s []uint8) bool { + for _, v := range s { + if v == want { + return true + } + } + return false +} diff --git a/device/raspivid/raspivid.go b/device/raspivid/raspivid.go index 0e533420..6c3cb6a7 100644 --- a/device/raspivid/raspivid.go +++ b/device/raspivid/raspivid.go @@ -152,7 +152,7 @@ func (r *Raspivid) Set(c config.Config) error { errs = append(errs, errBadFrameRate) } - if c.CBR || containsUint8(config.OutputHTTP, c.Outputs) { + if c.CBR || containsUint8(config.OutputRTMP, c.Outputs) { c.Quantization = 0 if c.Bitrate <= 0 { errs = append(errs, errBadBitrate)