From 0027957a33f896779016481c589e701175bfe278 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Mon, 13 Jul 2020 14:55:21 -0700 Subject: [PATCH] Make setting the max # of segments in playlist optional --- config-example.yaml | 3 --- config/config.go | 8 ++++++++ core/ffmpeg/transcoder.go | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/config-example.yaml b/config-example.yaml index b7c4508a9..9bf493cde 100644 --- a/config-example.yaml +++ b/config-example.yaml @@ -36,9 +36,6 @@ videoSettings: videoBitrate: 800 encoderPreset: superfast -files: - maxNumberInPlaylist: 30 - ipfs: enabled: false gateway: https://ipfs.io diff --git a/config/config.go b/config/config.go index 56b23e972..159e9d7bf 100644 --- a/config/config.go +++ b/config/config.go @@ -189,6 +189,14 @@ func (c *config) GetPublicWebServerPort() int { return 8080 } +func (c *config) GetMaxNumberOfReferencedSegmentsInPlaylist() int { + if c.Files.MaxNumberInPlaylist > 0 { + return c.Files.MaxNumberInPlaylist + } + + return 20 +} + //Load tries to load the configuration file func Load(filePath string, versionInfo string) error { Config = new(config) diff --git a/core/ffmpeg/transcoder.go b/core/ffmpeg/transcoder.go index fd4643fd0..f88ecf7ea 100644 --- a/core/ffmpeg/transcoder.go +++ b/core/ffmpeg/transcoder.go @@ -112,7 +112,7 @@ func (t *Transcoder) getString() string { // HLS Output "-f", "hls", "-hls_time", strconv.Itoa(t.segmentLengthSeconds), // Length of each segment - "-hls_list_size", strconv.Itoa(config.Config.Files.MaxNumberInPlaylist), // Max # in variant playlist + "-hls_list_size", strconv.Itoa(config.Config.GetMaxNumberOfReferencedSegmentsInPlaylist()), // Max # in variant playlist "-hls_delete_threshold", "10", // Start deleting files after hls_list_size + 10 "-hls_flags", strings.Join(hlsOptionFlags, "+"), // Specific options in HLS generation