diff --git a/core/data/config.go b/core/data/config.go index 40f6680e7..505f94e02 100644 --- a/core/data/config.go +++ b/core/data/config.go @@ -394,8 +394,10 @@ func SetS3StorageEnabled(enabled bool) error { // GetStreamLatencyLevel will return the stream latency level. func GetStreamLatencyLevel() models.LatencyLevel { level, err := _datastore.GetNumber(videoLatencyLevel) - if err != nil || level == 0 { - level = 4 + if err != nil { + level = 2 // default + } else if level > 4 { + level = 4 // highest } return models.GetLatencyLevel(int(level)) diff --git a/core/data/migrator.go b/core/data/migrator.go index 4ebceb2da..c08f1ab16 100644 --- a/core/data/migrator.go +++ b/core/data/migrator.go @@ -154,21 +154,21 @@ func migrateConfigFile() { _ = SetStreamOutputVariants(variants) // Migrate latency level - level := 4 + level := 2 oldSegmentLength := oldConfig.VideoSettings.ChunkLengthInSeconds oldNumberOfSegments := oldConfig.Files.MaxNumberInPlaylist latencyLevels := models.GetLatencyConfigs() - if oldSegmentLength == latencyLevels[1].SecondsPerSegment && oldNumberOfSegments == latencyLevels[1].SegmentCount { + if oldSegmentLength == latencyLevels[0].SecondsPerSegment && oldNumberOfSegments == latencyLevels[0].SegmentCount { + level = 0 + } else if oldSegmentLength == latencyLevels[1].SecondsPerSegment && oldNumberOfSegments == latencyLevels[2].SegmentCount { level = 1 } else if oldSegmentLength == latencyLevels[2].SecondsPerSegment && oldNumberOfSegments == latencyLevels[2].SegmentCount { level = 2 } else if oldSegmentLength == latencyLevels[3].SecondsPerSegment && oldNumberOfSegments == latencyLevels[3].SegmentCount { level = 3 - } else if oldSegmentLength == latencyLevels[5].SecondsPerSegment && oldNumberOfSegments == latencyLevels[5].SegmentCount { - level = 5 - } else if oldSegmentLength >= latencyLevels[6].SecondsPerSegment && oldNumberOfSegments >= latencyLevels[6].SegmentCount { - level = 6 + } else if oldSegmentLength >= latencyLevels[4].SecondsPerSegment && oldNumberOfSegments >= latencyLevels[4].SegmentCount { + level = 4 } _ = SetStreamLatencyLevel(float64(level)) diff --git a/models/latencyLevels.go b/models/latencyLevels.go index 7e22bedc6..f90dd855c 100644 --- a/models/latencyLevels.go +++ b/models/latencyLevels.go @@ -10,12 +10,11 @@ type LatencyLevel struct { // GetLatencyConfigs will return the available latency level options. func GetLatencyConfigs() map[int]LatencyLevel { return map[int]LatencyLevel{ - 1: {Level: 1, SecondsPerSegment: 1, SegmentCount: 2}, - 2: {Level: 2, SecondsPerSegment: 2, SegmentCount: 2}, - 3: {Level: 3, SecondsPerSegment: 2, SegmentCount: 3}, - 4: {Level: 4, SecondsPerSegment: 3, SegmentCount: 4}, // Default - 5: {Level: 5, SecondsPerSegment: 4, SegmentCount: 5}, - 6: {Level: 6, SecondsPerSegment: 6, SegmentCount: 10}, + 0: {Level: 0, SecondsPerSegment: 1, SegmentCount: 3}, // Approx 5 seconds + 1: {Level: 1, SecondsPerSegment: 2, SegmentCount: 2}, // Approx 7-8 seconds + 2: {Level: 2, SecondsPerSegment: 3, SegmentCount: 3}, // Default Approx 11 seconds + 3: {Level: 3, SecondsPerSegment: 4, SegmentCount: 3}, // Approx 15 seconds + 4: {Level: 4, SecondsPerSegment: 5, SegmentCount: 4}, // Approx 18 seconds } }