Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
Make setting save location paths optional
Gabe Kangasf3b9401015de
diff --git a/config-example.yaml b/config-example.yamlindex 026befb473..a01af771a2 100644--- a/config-example.yaml+++ b/config-example.yaml@@ -1,5 +1,3 @@-publicHLSPath: webroot/hls-privateHLSPath: hlswebServerPort: 8080instanceDetails:diff --git a/config/config.go b/config/config.goindex 71910b3ea4..6658020524 100644--- a/config/config.go+++ b/config/config.go@@ -164,6 +164,22 @@ func (c *config) GetVideoSegmentSecondsLength() int {return 4}+func (c *config) GetPublicHLSSavePath() string {+ if c.PublicHLSPath != "" {+ return c.PublicHLSPath+ }++ return "webroot/hls"+}++func (c *config) GetPrivateHLSSavePath() string {+ if c.PrivateHLSPath != "" {+ return c.PrivateHLSPath+ }++ return "hls"+}+//Load tries to load the configuration filefunc Load(filePath string, versionInfo string) error {Config = new(config)diff --git a/core/core.go b/core/core.goindex 3469f06271..1047a9dd63 100644--- a/core/core.go+++ b/core/core.go@@ -60,10 +60,10 @@ func resetDirectories() {log.Trace("Resetting file directories to a clean slate.")// Wipe the public, web-accessible hls data directory- os.RemoveAll(config.Config.PublicHLSPath)- os.RemoveAll(config.Config.PrivateHLSPath)- os.MkdirAll(config.Config.PublicHLSPath, 0777)- os.MkdirAll(config.Config.PrivateHLSPath, 0777)+ os.RemoveAll(config.Config.GetPublicHLSSavePath())+ os.RemoveAll(config.Config.GetPrivateHLSSavePath())+ os.MkdirAll(config.Config.GetPublicHLSSavePath(), 0777)+ os.MkdirAll(config.Config.GetPrivateHLSSavePath(), 0777)// Remove the previous thumbnailos.Remove("webroot/thumbnail.jpg")@@ -71,11 +71,11 @@ func resetDirectories() {// Create private hls data dirsif len(config.Config.VideoSettings.StreamQualities) != 0 {for index := range config.Config.VideoSettings.StreamQualities {- os.MkdirAll(path.Join(config.Config.PrivateHLSPath, strconv.Itoa(index)), 0777)- os.MkdirAll(path.Join(config.Config.PublicHLSPath, strconv.Itoa(index)), 0777)+ os.MkdirAll(path.Join(config.Config.GetPrivateHLSSavePath(), strconv.Itoa(index)), 0777)+ os.MkdirAll(path.Join(config.Config.GetPublicHLSSavePath(), strconv.Itoa(index)), 0777)}} else {- os.MkdirAll(path.Join(config.Config.PrivateHLSPath, strconv.Itoa(0)), 0777)- os.MkdirAll(path.Join(config.Config.PublicHLSPath, strconv.Itoa(0)), 0777)+ os.MkdirAll(path.Join(config.Config.GetPrivateHLSSavePath(), strconv.Itoa(0)), 0777)+ os.MkdirAll(path.Join(config.Config.GetPublicHLSSavePath(), strconv.Itoa(0)), 0777)}}diff --git a/core/ffmpeg/transcoder.go b/core/ffmpeg/transcoder.goindex c7bb649f09..fd4643fd05 100644--- a/core/ffmpeg/transcoder.go+++ b/core/ffmpeg/transcoder.go@@ -179,15 +179,15 @@ func NewTranscoder() Transcoder {var outputPath stringif config.Config.S3.Enabled || config.Config.IPFS.Enabled {// Segments are not available via the local HTTP server- outputPath = config.Config.PrivateHLSPath+ outputPath = config.Config.GetPrivateHLSSavePath()} else {// Segments are available via the local HTTP server- outputPath = config.Config.PublicHLSPath+ outputPath = config.Config.GetPublicHLSSavePath()}transcoder.segmentOutputPath = outputPath// Playlists are available via the local HTTP server- transcoder.playlistOutputPath = config.Config.PublicHLSPath+ transcoder.playlistOutputPath = config.Config.GetPublicHLSSavePath()transcoder.input = utils.GetTemporaryPipePath()transcoder.segmentLengthSeconds = config.Config.GetVideoSegmentSecondsLength()diff --git a/core/playlist/monitor.go b/core/playlist/monitor.goindex a010ba420e..cba85dc89e 100644--- a/core/playlist/monitor.go+++ b/core/playlist/monitor.go@@ -26,7 +26,7 @@ var (func StartVideoContentMonitor(storage models.ChunkStorageProvider) error {_storage = storage- pathToMonitor := config.Config.PrivateHLSPath+ pathToMonitor := config.Config.GetPrivateHLSSavePath()// Create at least one structure to store the segments for the different stream variantsvariants = make([]models.Variant, len(config.Config.VideoSettings.StreamQualities))@@ -66,8 +66,8 @@ func StartVideoContentMonitor(storage models.ChunkStorageProvider) error {// fmt.Println(event.Op, relativePath)// Handle updates to the master playlist by copying it to webroot- if relativePath == path.Join(config.Config.PrivateHLSPath, "stream.m3u8") {- utils.Copy(event.Path, path.Join(config.Config.PublicHLSPath, "stream.m3u8"))+ if relativePath == path.Join(config.Config.GetPrivateHLSSavePath(), "stream.m3u8") {+ utils.Copy(event.Path, path.Join(config.Config.GetPublicHLSSavePath(), "stream.m3u8"))} else if filepath.Ext(event.Path) == ".m3u8" {// Handle updates to playlists, but not the master playlist@@ -82,7 +82,7 @@ func StartVideoContentMonitor(storage models.ChunkStorageProvider) error {newObjectPathChannel := make(chan string, 1)go func() {- newObjectPath, err := storage.Save(path.Join(config.Config.PrivateHLSPath, segment.RelativeUploadPath), 0)+ newObjectPath, err := storage.Save(path.Join(config.Config.GetPrivateHLSSavePath(), segment.RelativeUploadPath), 0)if err != nil {log.Errorln("failed to save the file to the chunk storage.", err)}@@ -153,9 +153,7 @@ func updateVariantPlaylist(fullPath string) error {}playlistString := string(playlistBytes)- // fmt.Println("Rewriting playlist", relativePath, "to", path.Join(config.Config.PublicHLSPath, relativePath))-playlistString = _storage.GenerateRemotePlaylist(playlistString, variant)- return WritePlaylist(playlistString, path.Join(config.Config.PublicHLSPath, relativePath))+ return WritePlaylist(playlistString, path.Join(config.Config.GetPublicHLSSavePath(), relativePath))}diff --git a/core/status.go b/core/status.goindex d7c1c535b8..2eaebb15bb 100644--- a/core/status.go+++ b/core/status.go@@ -34,9 +34,9 @@ func SetStreamAsConnected() {_stats.SessionMaxViewerCount = 0}- chunkPath := config.Config.PublicHLSPath+ chunkPath := config.Config.GetPublicHLSSavePath()if usingExternalStorage {- chunkPath = config.Config.PrivateHLSPath+ chunkPath = config.Config.GetPrivateHLSSavePath()}ffmpeg.StartThumbnailGenerator(chunkPath, config.Config.VideoSettings.HighestQualityStreamIndex)