2020-07-18 03:27:00 +02:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os/exec"
|
|
|
|
"strings"
|
2020-10-14 23:07:38 +02:00
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
2020-07-18 03:27:00 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func getDefaults() config {
|
|
|
|
defaults := config{}
|
|
|
|
defaults.WebServerPort = 8080
|
|
|
|
defaults.FFMpegPath = getDefaultFFMpegPath()
|
|
|
|
defaults.VideoSettings.ChunkLengthInSeconds = 4
|
|
|
|
defaults.Files.MaxNumberInPlaylist = 5
|
2020-10-02 08:55:38 +02:00
|
|
|
defaults.YP.Enabled = false
|
|
|
|
defaults.YP.YPServiceURL = "https://yp.owncast.online"
|
2020-10-26 16:55:31 +01:00
|
|
|
defaults.DatabaseFilePath = "data/owncast.db"
|
2020-07-18 03:27:00 +02:00
|
|
|
|
|
|
|
defaultQuality := StreamQuality{
|
|
|
|
IsAudioPassthrough: true,
|
|
|
|
VideoBitrate: 1200,
|
|
|
|
EncoderPreset: "veryfast",
|
2020-08-06 21:19:35 +02:00
|
|
|
Framerate: 24,
|
2020-07-18 03:27:00 +02:00
|
|
|
}
|
|
|
|
defaults.VideoSettings.StreamQualities = []StreamQuality{defaultQuality}
|
|
|
|
|
|
|
|
return defaults
|
|
|
|
}
|
|
|
|
|
|
|
|
func getDefaultFFMpegPath() string {
|
2020-10-22 06:47:42 +02:00
|
|
|
// First look to see if ffmpeg is in the current working directory
|
|
|
|
localCopy := "./ffmpeg"
|
|
|
|
hasLocalCopyError := verifyFFMpegPath(localCopy)
|
|
|
|
if hasLocalCopyError == nil {
|
|
|
|
// No error, so all is good. Use the local copy.
|
|
|
|
return localCopy
|
|
|
|
}
|
|
|
|
|
2020-07-18 03:27:00 +02:00
|
|
|
cmd := exec.Command("which", "ffmpeg")
|
|
|
|
out, err := cmd.CombinedOutput()
|
|
|
|
if err != nil {
|
2020-10-27 02:58:54 +01:00
|
|
|
log.Debugln("Unable to determine path to ffmpeg. Please specify it in the config file.")
|
2020-07-18 03:27:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
path := strings.TrimSpace(string(out))
|
|
|
|
|
|
|
|
return path
|
|
|
|
}
|