From 868704e9d425ef694e11843dbc93873e68d819eb Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Fri, 31 Mar 2023 16:46:05 +0200 Subject: [PATCH] hls muxer: make Low Latency-HLS the default variant (#1610) --- go.mod | 3 +-- go.sum | 6 ++---- internal/conf/conf.go | 14 +++----------- rtsp-simple-server.yml | 2 +- 4 files changed, 7 insertions(+), 18 deletions(-) diff --git a/go.mod b/go.mod index 6cb750b7..3fdb9ba0 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/alecthomas/kong v0.7.1 github.com/aler9/gortsplib/v2 v2.2.2 github.com/asticode/go-astits v1.11.0 - github.com/bluenviron/gohlslib v0.0.0-20230319232056-d55d76265613 + github.com/bluenviron/gohlslib v0.0.0-20230331102633-868d71cf3d3b github.com/fsnotify/fsnotify v1.6.0 github.com/gin-gonic/gin v1.9.0 github.com/google/uuid v1.3.0 @@ -36,7 +36,6 @@ require ( github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.11.2 // indirect github.com/goccy/go-json v0.10.0 // indirect - github.com/grafov/m3u8 v0.11.1 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/cpuid/v2 v2.0.9 // indirect github.com/leodido/go-urn v1.2.1 // indirect diff --git a/go.sum b/go.sum index f7afc6ee..a9ffb624 100644 --- a/go.sum +++ b/go.sum @@ -12,8 +12,8 @@ github.com/asticode/go-astikit v0.30.0 h1:DkBkRQRIxYcknlaU7W7ksNfn4gMFsB0tqMJflx github.com/asticode/go-astikit v0.30.0/go.mod h1:h4ly7idim1tNhaVkdVBeXQZEE3L0xblP7fCWbgwipF0= github.com/asticode/go-astits v1.11.0 h1:GTHUXht0ZXAJXsVbsLIcyfHr1Bchi4QQwMARw2ZWAng= github.com/asticode/go-astits v1.11.0/go.mod h1:QSHmknZ51pf6KJdHKZHJTLlMegIrhega3LPWz3ND/iI= -github.com/bluenviron/gohlslib v0.0.0-20230319232056-d55d76265613 h1:cVRJ6kYz8jRZApBnDMSlu7bJ0vKw9pVrkzsaKmCKwSk= -github.com/bluenviron/gohlslib v0.0.0-20230319232056-d55d76265613/go.mod h1:H4tS+00wJHRoeWwykehJ/yrGeHOfQvqc1PSahXKjusk= +github.com/bluenviron/gohlslib v0.0.0-20230331102633-868d71cf3d3b h1:eFmp8pdtZ7GdpdLJnPu9XKpxzbTKaOiUc1zFPCaMc00= +github.com/bluenviron/gohlslib v0.0.0-20230331102633-868d71cf3d3b/go.mod h1:6tKammMhZsSSN5copPcn28MehHxqpaCzfeaKLHahhiQ= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= github.com/bytedance/sonic v1.8.0 h1:ea0Xadu+sHlu7x5O3gKhRpQ1IKiMrSiHttPF0ybECuA= github.com/bytedance/sonic v1.8.0/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= @@ -66,8 +66,6 @@ github.com/gookit/color v1.5.3 h1:twfIhZs4QLCtimkP7MOxlF3A0U/5cDPseRT9M/+2SCE= github.com/gookit/color v1.5.3/go.mod h1:NUzwzeehUfl7GIb36pqId+UGmRfQcU/WiiyTTeNjHtE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/grafov/m3u8 v0.11.1 h1:igZ7EBIB2IAsPPazKwRKdbhxcoBKO3lO1UY57PZDeNA= -github.com/grafov/m3u8 v0.11.1/go.mod h1:nqzOkfBiZJENr52zTVd/Dcl03yzphIMbJqkXGu+u080= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= diff --git a/internal/conf/conf.go b/internal/conf/conf.go index bc6a2197..f04b2d09 100644 --- a/internal/conf/conf.go +++ b/internal/conf/conf.go @@ -393,6 +393,9 @@ func (conf *Conf) CheckAndFillMissing() error { if conf.HLSServerCert == "" { conf.HLSServerCert = "server.crt" } + if conf.HLSVariant == 0 { + conf.HLSVariant = HLSVariant(gohlslib.MuxerVariantLowLatency) + } if conf.HLSSegmentCount == 0 { conf.HLSSegmentCount = 7 } @@ -408,17 +411,6 @@ func (conf *Conf) CheckAndFillMissing() error { if conf.HLSAllowOrigin == "" { conf.HLSAllowOrigin = "*" } - switch conf.HLSVariant { - case HLSVariant(gohlslib.MuxerVariantLowLatency): - if conf.HLSSegmentCount < 7 { - return fmt.Errorf("Low-Latency HLS requires at least 7 segments") - } - - default: - if conf.HLSSegmentCount < 3 { - return fmt.Errorf("The minimum number of HLS segments is 3") - } - } // WebRTC if conf.WebRTCAddress == "" { diff --git a/rtsp-simple-server.yml b/rtsp-simple-server.yml index ebdb09ab..2d1b8deb 100644 --- a/rtsp-simple-server.yml +++ b/rtsp-simple-server.yml @@ -143,7 +143,7 @@ hlsAlwaysRemux: no # * mpegts - uses MPEG-TS segments, for maximum compatibility. # * fmp4 - uses fragmented MP4 segments, more efficient. # * lowLatency - uses Low-Latency HLS. -hlsVariant: mpegts +hlsVariant: lowLatency # Number of HLS segments to keep on the server. # Segments allow to seek through the stream. # Their number doesn't influence latency.