octicon-rss(16/)
You've already forked owncast
mirror of
https://github.com/owncast/owncast.git
synced 2025-11-10 00:39:22 +08:00
Do not perform ffmpeg location logic in defaults
This commit is contained in:
octicon-git-branch(16/)
octicon-tag(16/)
octicon-diff(16/tw-mr-1) 2 changed files with 19 additions and 27 deletions
@@ -3,6 +3,8 @@ package config
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
@@ -184,7 +186,23 @@ func (c *config) GetFFMpegPath() string {
|
|||||||
return c.FFMpegPath
|
return c.FFMpegPath
|
||||||
}
|
}
|
||||||
|
|
||||||
return _default.FFMpegPath
|
// 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
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd := exec.Command("which", "ffmpeg")
|
||||||
|
out, err := cmd.CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
log.Debugln("Unable to determine path to ffmpeg. Please specify it in the config file.")
|
||||||
|
}
|
||||||
|
|
||||||
|
path := strings.TrimSpace(string(out))
|
||||||
|
|
||||||
|
return path
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *config) GetYPServiceHost() string {
|
func (c *config) GetYPServiceHost() string {
|
||||||
|
|||||||
@@ -1,14 +1,8 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
|
||||||
"os/exec"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
func getDefaults() config {
|
func getDefaults() config {
|
||||||
defaults := config{}
|
defaults := config{}
|
||||||
defaults.WebServerPort = 8080
|
defaults.WebServerPort = 8080
|
||||||
defaults.FFMpegPath = getDefaultFFMpegPath()
|
|
||||||
defaults.VideoSettings.ChunkLengthInSeconds = 4
|
defaults.VideoSettings.ChunkLengthInSeconds = 4
|
||||||
defaults.Files.MaxNumberInPlaylist = 5
|
defaults.Files.MaxNumberInPlaylist = 5
|
||||||
defaults.YP.Enabled = false
|
defaults.YP.Enabled = false
|
||||||
@@ -25,23 +19,3 @@ func getDefaults() config {
|
|||||||
|
|
||||||
return defaults
|
return defaults
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDefaultFFMpegPath() string {
|
|
||||||
// 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
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd := exec.Command("which", "ffmpeg")
|
|
||||||
out, err := cmd.CombinedOutput()
|
|
||||||
if err != nil {
|
|
||||||
panic("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