mirror of
https://github.com/owncast/owncast.git
synced 2024-11-24 21:59:43 +03:00
Make setting save location paths optional
This commit is contained in:
parent
d51901e191
commit
44806d1a8e
6 changed files with 34 additions and 22 deletions
|
@ -1,5 +1,3 @@
|
||||||
publicHLSPath: webroot/hls
|
|
||||||
privateHLSPath: hls
|
|
||||||
webServerPort: 8080
|
webServerPort: 8080
|
||||||
|
|
||||||
instanceDetails:
|
instanceDetails:
|
||||||
|
|
|
@ -164,6 +164,22 @@ func (c *config) GetVideoSegmentSecondsLength() int {
|
||||||
return 4
|
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 file
|
//Load tries to load the configuration file
|
||||||
func Load(filePath string, versionInfo string) error {
|
func Load(filePath string, versionInfo string) error {
|
||||||
Config = new(config)
|
Config = new(config)
|
||||||
|
|
16
core/core.go
16
core/core.go
|
@ -60,10 +60,10 @@ func resetDirectories() {
|
||||||
log.Trace("Resetting file directories to a clean slate.")
|
log.Trace("Resetting file directories to a clean slate.")
|
||||||
|
|
||||||
// Wipe the public, web-accessible hls data directory
|
// Wipe the public, web-accessible hls data directory
|
||||||
os.RemoveAll(config.Config.PublicHLSPath)
|
os.RemoveAll(config.Config.GetPublicHLSSavePath())
|
||||||
os.RemoveAll(config.Config.PrivateHLSPath)
|
os.RemoveAll(config.Config.GetPrivateHLSSavePath())
|
||||||
os.MkdirAll(config.Config.PublicHLSPath, 0777)
|
os.MkdirAll(config.Config.GetPublicHLSSavePath(), 0777)
|
||||||
os.MkdirAll(config.Config.PrivateHLSPath, 0777)
|
os.MkdirAll(config.Config.GetPrivateHLSSavePath(), 0777)
|
||||||
|
|
||||||
// Remove the previous thumbnail
|
// Remove the previous thumbnail
|
||||||
os.Remove("webroot/thumbnail.jpg")
|
os.Remove("webroot/thumbnail.jpg")
|
||||||
|
@ -71,11 +71,11 @@ func resetDirectories() {
|
||||||
// Create private hls data dirs
|
// Create private hls data dirs
|
||||||
if len(config.Config.VideoSettings.StreamQualities) != 0 {
|
if len(config.Config.VideoSettings.StreamQualities) != 0 {
|
||||||
for index := range config.Config.VideoSettings.StreamQualities {
|
for index := range config.Config.VideoSettings.StreamQualities {
|
||||||
os.MkdirAll(path.Join(config.Config.PrivateHLSPath, strconv.Itoa(index)), 0777)
|
os.MkdirAll(path.Join(config.Config.GetPrivateHLSSavePath(), strconv.Itoa(index)), 0777)
|
||||||
os.MkdirAll(path.Join(config.Config.PublicHLSPath, strconv.Itoa(index)), 0777)
|
os.MkdirAll(path.Join(config.Config.GetPublicHLSSavePath(), strconv.Itoa(index)), 0777)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
os.MkdirAll(path.Join(config.Config.PrivateHLSPath, strconv.Itoa(0)), 0777)
|
os.MkdirAll(path.Join(config.Config.GetPrivateHLSSavePath(), strconv.Itoa(0)), 0777)
|
||||||
os.MkdirAll(path.Join(config.Config.PublicHLSPath, strconv.Itoa(0)), 0777)
|
os.MkdirAll(path.Join(config.Config.GetPublicHLSSavePath(), strconv.Itoa(0)), 0777)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,15 +179,15 @@ func NewTranscoder() Transcoder {
|
||||||
var outputPath string
|
var outputPath string
|
||||||
if config.Config.S3.Enabled || config.Config.IPFS.Enabled {
|
if config.Config.S3.Enabled || config.Config.IPFS.Enabled {
|
||||||
// Segments are not available via the local HTTP server
|
// Segments are not available via the local HTTP server
|
||||||
outputPath = config.Config.PrivateHLSPath
|
outputPath = config.Config.GetPrivateHLSSavePath()
|
||||||
} else {
|
} else {
|
||||||
// Segments are available via the local HTTP server
|
// Segments are available via the local HTTP server
|
||||||
outputPath = config.Config.PublicHLSPath
|
outputPath = config.Config.GetPublicHLSSavePath()
|
||||||
}
|
}
|
||||||
|
|
||||||
transcoder.segmentOutputPath = outputPath
|
transcoder.segmentOutputPath = outputPath
|
||||||
// Playlists are available via the local HTTP server
|
// Playlists are available via the local HTTP server
|
||||||
transcoder.playlistOutputPath = config.Config.PublicHLSPath
|
transcoder.playlistOutputPath = config.Config.GetPublicHLSSavePath()
|
||||||
|
|
||||||
transcoder.input = utils.GetTemporaryPipePath()
|
transcoder.input = utils.GetTemporaryPipePath()
|
||||||
transcoder.segmentLengthSeconds = config.Config.GetVideoSegmentSecondsLength()
|
transcoder.segmentLengthSeconds = config.Config.GetVideoSegmentSecondsLength()
|
||||||
|
|
|
@ -26,7 +26,7 @@ var (
|
||||||
func StartVideoContentMonitor(storage models.ChunkStorageProvider) error {
|
func StartVideoContentMonitor(storage models.ChunkStorageProvider) error {
|
||||||
_storage = storage
|
_storage = storage
|
||||||
|
|
||||||
pathToMonitor := config.Config.PrivateHLSPath
|
pathToMonitor := config.Config.GetPrivateHLSSavePath()
|
||||||
|
|
||||||
// Create at least one structure to store the segments for the different stream variants
|
// Create at least one structure to store the segments for the different stream variants
|
||||||
variants = make([]models.Variant, len(config.Config.VideoSettings.StreamQualities))
|
variants = make([]models.Variant, len(config.Config.VideoSettings.StreamQualities))
|
||||||
|
@ -66,8 +66,8 @@ func StartVideoContentMonitor(storage models.ChunkStorageProvider) error {
|
||||||
// fmt.Println(event.Op, relativePath)
|
// fmt.Println(event.Op, relativePath)
|
||||||
|
|
||||||
// Handle updates to the master playlist by copying it to webroot
|
// Handle updates to the master playlist by copying it to webroot
|
||||||
if relativePath == path.Join(config.Config.PrivateHLSPath, "stream.m3u8") {
|
if relativePath == path.Join(config.Config.GetPrivateHLSSavePath(), "stream.m3u8") {
|
||||||
utils.Copy(event.Path, path.Join(config.Config.PublicHLSPath, "stream.m3u8"))
|
utils.Copy(event.Path, path.Join(config.Config.GetPublicHLSSavePath(), "stream.m3u8"))
|
||||||
|
|
||||||
} else if filepath.Ext(event.Path) == ".m3u8" {
|
} else if filepath.Ext(event.Path) == ".m3u8" {
|
||||||
// Handle updates to playlists, but not the master playlist
|
// Handle updates to playlists, but not the master playlist
|
||||||
|
@ -82,7 +82,7 @@ func StartVideoContentMonitor(storage models.ChunkStorageProvider) error {
|
||||||
|
|
||||||
newObjectPathChannel := make(chan string, 1)
|
newObjectPathChannel := make(chan string, 1)
|
||||||
go func() {
|
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 {
|
if err != nil {
|
||||||
log.Errorln("failed to save the file to the chunk storage.", err)
|
log.Errorln("failed to save the file to the chunk storage.", err)
|
||||||
}
|
}
|
||||||
|
@ -153,9 +153,7 @@ func updateVariantPlaylist(fullPath string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
playlistString := string(playlistBytes)
|
playlistString := string(playlistBytes)
|
||||||
// fmt.Println("Rewriting playlist", relativePath, "to", path.Join(config.Config.PublicHLSPath, relativePath))
|
|
||||||
|
|
||||||
playlistString = _storage.GenerateRemotePlaylist(playlistString, variant)
|
playlistString = _storage.GenerateRemotePlaylist(playlistString, variant)
|
||||||
|
|
||||||
return WritePlaylist(playlistString, path.Join(config.Config.PublicHLSPath, relativePath))
|
return WritePlaylist(playlistString, path.Join(config.Config.GetPublicHLSSavePath(), relativePath))
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,9 @@ func SetStreamAsConnected() {
|
||||||
_stats.SessionMaxViewerCount = 0
|
_stats.SessionMaxViewerCount = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
chunkPath := config.Config.PublicHLSPath
|
chunkPath := config.Config.GetPublicHLSSavePath()
|
||||||
if usingExternalStorage {
|
if usingExternalStorage {
|
||||||
chunkPath = config.Config.PrivateHLSPath
|
chunkPath = config.Config.GetPrivateHLSSavePath()
|
||||||
}
|
}
|
||||||
|
|
||||||
ffmpeg.StartThumbnailGenerator(chunkPath, config.Config.VideoSettings.HighestQualityStreamIndex)
|
ffmpeg.StartThumbnailGenerator(chunkPath, config.Config.VideoSettings.HighestQualityStreamIndex)
|
||||||
|
|
Loading…
Reference in a new issue