From 76d4376476b176ed76a759741d531babb5fe72ee Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Thu, 14 Apr 2022 15:29:41 +0200 Subject: [PATCH] hls muxer: fix crash in case of null SPS --- internal/hls/muxer_primary_playlist.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/hls/muxer_primary_playlist.go b/internal/hls/muxer_primary_playlist.go index a84cb26b..28a3f601 100644 --- a/internal/hls/muxer_primary_playlist.go +++ b/internal/hls/muxer_primary_playlist.go @@ -29,7 +29,10 @@ func newMuxerPrimaryPlaylist( var codecs []string if p.videoTrack != nil { - codecs = append(codecs, "avc1."+hex.EncodeToString(p.videoTrack.SPS()[1:4])) + sps := p.videoTrack.SPS() + if len(sps) >= 4 { + codecs = append(codecs, "avc1."+hex.EncodeToString(sps[1:4])) + } } // https://developer.mozilla.org/en-US/docs/Web/Media/Formats/codecs_parameter