Browse Source

Tame down encoding performance alerts. Closes #338

pull/371/head
Gabe Kangas 5 years ago
parent
commit
a24dbc418b
  1. 2
      core/ffmpeg/fileWriterReceiverService.go
  2. 2
      core/stats.go
  3. 12
      utils/performanceTimer.go

2
core/ffmpeg/fileWriterReceiverService.go

@ -89,7 +89,7 @@ func (s *FileWriterReceiverService) fileWritten(path string) {
utils.StartPerformanceMonitor(performanceMonitorKey) utils.StartPerformanceMonitor(performanceMonitorKey)
s.callbacks.SegmentWritten(path) s.callbacks.SegmentWritten(path)
if averagePerformance != 0 && averagePerformance > float64(config.Config.GetVideoSegmentSecondsLength()) { if averagePerformance != 0 && averagePerformance > float64(config.Config.GetVideoSegmentSecondsLength())*1.1 {
if !_inWarningState { if !_inWarningState {
log.Warnln("slow encoding for variant", index, "if this continues you may see buffering or errors. troubleshoot this issue by visiting https://owncast.online/docs/troubleshooting/") log.Warnln("slow encoding for variant", index, "if this continues you may see buffering or errors. troubleshoot this issue by visiting https://owncast.online/docs/troubleshooting/")
_inWarningState = true _inWarningState = true

2
core/stats.go

@ -48,7 +48,7 @@ func IsStreamConnected() bool {
// Kind of a hack. It takes a handful of seconds between a RTMP connection and when HLS data is available. // Kind of a hack. It takes a handful of seconds between a RTMP connection and when HLS data is available.
// So account for that with an artificial buffer of four segments. // So account for that with an artificial buffer of four segments.
timeSinceLastConnected := time.Since(_stats.LastConnectTime.Time).Seconds() timeSinceLastConnected := time.Since(_stats.LastConnectTime.Time).Seconds()
if timeSinceLastConnected < float64(config.Config.GetVideoSegmentSecondsLength())*2.0 { if timeSinceLastConnected < float64(config.Config.GetVideoSegmentSecondsLength())*2.3 {
return false return false
} }

12
utils/performanceTimer.go

@ -13,8 +13,8 @@ var _durationStorage = make(map[string][]float64)
// StartPerformanceMonitor will keep track of the start time of this event. // StartPerformanceMonitor will keep track of the start time of this event.
func StartPerformanceMonitor(key string) { func StartPerformanceMonitor(key string) {
if len(_durationStorage[key]) > 30 { if len(_durationStorage[key]) > 20 {
_durationStorage[key] = removeHighAndLow(_durationStorage[key]) _durationStorage[key] = removeHighValue(_durationStorage[key])
} }
_pointsInTime[key] = time.Now() _pointsInTime[key] = time.Now()
} }
@ -28,16 +28,16 @@ func GetAveragePerformance(key string) float64 {
delta := time.Since(timestamp).Seconds() delta := time.Since(timestamp).Seconds()
_durationStorage[key] = append(_durationStorage[key], delta) _durationStorage[key] = append(_durationStorage[key], delta)
if len(_durationStorage[key]) < 10 { if len(_durationStorage[key]) < 8 {
return 0 return 0
} }
_durationStorage[key] = removeHighAndLow(_durationStorage[key]) _durationStorage[key] = removeHighValue(_durationStorage[key])
return avg(_durationStorage[key]) return avg(_durationStorage[key])
} }
func removeHighAndLow(values []float64) []float64 { func removeHighValue(values []float64) []float64 {
sort.Float64s(values) sort.Float64s(values)
return values[1 : len(values)-1] return values[:len(values)-1]
} }
func avg(values []float64) float64 { func avg(values []float64) float64 {

Loading…
Cancel
Save