Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
Simplify appending the offline segment to playlist
Gabe Kangasbcd4d1a0a49e
diff --git a/core/offlineState.go b/core/offlineState.goindex 47ff349587..84c823f149 100644--- a/core/offlineState.go+++ b/core/offlineState.go@@ -1,7 +1,6 @@package coreimport (- "bufio""fmt""os""path/filepath"@@ -14,23 +13,12 @@ import ()func appendOfflineToVariantPlaylist(index int, playlistFilePath string) {- f, err := os.OpenFile(playlistFilePath, os.O_CREATE|os.O_RDWR, os.ModePerm) //nolint+ existingPlaylistContents, err := os.ReadFile(playlistFilePath) // nolint: gosecif err != nil {- log.Fatalln(err)- }-- playlist, _, err := m3u8.DecodeFrom(bufio.NewReader(f), true)- if err != nil {- log.Fatalln(err)- }-- if err := f.Close(); err != nil {- log.Errorln("error closing playlist file", err)+ log.Debugln("unable to read existing playlist file", err)+ return}- variantPlaylist := playlist.(*m3u8.MediaPlaylist)- variantPlaylist.MediaType = m3u8.EVENT-tmpFileName := fmt.Sprintf("tmp-stream-%d.m3u8", index)atomicWriteTmpPlaylistFile, err := os.CreateTemp(os.TempDir(), tmpFileName)if err != nil {@@ -38,11 +26,13 @@ func appendOfflineToVariantPlaylist(index int, playlistFilePath string) {return}- if _, err := atomicWriteTmpPlaylistFile.Write(variantPlaylist.Encode().Bytes()); err != nil {- log.Errorln(err)+ // Write the existing playlist contents+ if _, err := atomicWriteTmpPlaylistFile.Write(existingPlaylistContents); err != nil {+ log.Debugln("error writing existing playlist contents to tmp playlist file", err)+ return}- // Manually add the offline clip to the end of the media playlist.+ // Manually append the offline clip to the end of the media playlist._, _ = atomicWriteTmpPlaylistFile.WriteString("#EXT-X-DISCONTINUITY\n")// If "offline" content gets changed then change the duration below_, _ = atomicWriteTmpPlaylistFile.WriteString("#EXTINF:8.000000,\n")