Centralize default values into an instance of config. For #64
This commit is contained in:
40
config/defaults.go
Normal file
40
config/defaults.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func getDefaults() config {
|
||||
defaults := config{}
|
||||
defaults.WebServerPort = 8080
|
||||
defaults.FFMpegPath = getDefaultFFMpegPath()
|
||||
defaults.VideoSettings.ChunkLengthInSeconds = 4
|
||||
defaults.Files.MaxNumberInPlaylist = 5
|
||||
defaults.PublicHLSPath = "webroot/hls"
|
||||
defaults.PrivateHLSPath = "hls"
|
||||
defaults.VideoSettings.OfflineContent = "static/offline.m4v"
|
||||
defaults.InstanceDetails.ExtraInfoFile = "/static/content.md"
|
||||
|
||||
defaultQuality := StreamQuality{
|
||||
IsAudioPassthrough: true,
|
||||
VideoBitrate: 1200,
|
||||
EncoderPreset: "veryfast",
|
||||
}
|
||||
defaults.VideoSettings.StreamQualities = []StreamQuality{defaultQuality}
|
||||
|
||||
return defaults
|
||||
}
|
||||
|
||||
func getDefaultFFMpegPath() string {
|
||||
cmd := exec.Command("which", "ffmpeg")
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
log.Panicln("Unable to determine path to ffmpeg. Please specify it in the config file.")
|
||||
}
|
||||
|
||||
path := strings.TrimSpace(string(out))
|
||||
|
||||
return path
|
||||
}
|
||||
Reference in New Issue
Block a user