Browse Source

Support default path of ffmpeg and not needing to specify it in the config

pull/68/head
Gabe Kangas 5 years ago
parent
commit
51e2e68017
  1. 1
      config-example.yaml
  2. 28
      config/config.go
  3. 2
      core/ffmpeg/thumbnailGenerator.go
  4. 2
      core/ffmpeg/transcoder.go

1
config-example.yaml

@ -1,6 +1,5 @@ @@ -1,6 +1,5 @@
publicHLSPath: webroot/hls
privateHLSPath: hls
ffmpegPath: /usr/bin/ffmpeg
webServerPort: 8080
instanceDetails:

28
config/config.go

@ -2,8 +2,9 @@ package config @@ -2,8 +2,9 @@ package config
import (
"errors"
"fmt"
"io/ioutil"
"os/exec"
"strings"
"github.com/gabek/owncast/utils"
log "github.com/sirupsen/logrus"
@ -132,19 +133,26 @@ func (c *config) verifySettings() error { @@ -132,19 +133,26 @@ func (c *config) verifySettings() error {
}
}
// if !fileExists(config.PrivateHLSPath) {
// os.MkdirAll(path.Join(config.PrivateHLSPath, strconv.Itoa(0)), 0777)
// }
return nil
}
// if !fileExists(config.PublicHLSPath) {
// os.MkdirAll(path.Join(config.PublicHLSPath, strconv.Itoa(0)), 0777)
// }
func (c *config) GetFFMpegPath() string {
if c.FFMpegPath != "" {
return c.FFMpegPath
}
if !utils.DoesFileExists(c.FFMpegPath) {
return fmt.Errorf("ffmpeg does not exist at: %s", c.FFMpegPath)
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.")
}
return nil
path := strings.TrimSpace(string(out))
// Memoize it for future access
c.FFMpegPath = path
return path
}
//Load tries to load the configuration file

2
core/ffmpeg/thumbnailGenerator.go

@ -72,7 +72,7 @@ func fireThumbnailGenerator(chunkPath string, variantIndex int) error { @@ -72,7 +72,7 @@ func fireThumbnailGenerator(chunkPath string, variantIndex int) error {
mostRecentFile := path.Join(framePath, names[0])
thumbnailCmdFlags := []string{
config.Config.FFMpegPath,
config.Config.GetFFMpegPath(),
"-y", // Overwrite file
"-threads 1", // Low priority processing
"-t 1", // Pull from frame 1

2
core/ffmpeg/transcoder.go

@ -104,7 +104,7 @@ func (t *Transcoder) getString() string { @@ -104,7 +104,7 @@ func (t *Transcoder) getString() string {
ffmpegFlags := []string{
"cat", t.input, "|",
config.Config.FFMpegPath,
config.Config.GetFFMpegPath(),
"-hide_banner",
"-i pipe:",
t.getVariantsString(),

Loading…
Cancel
Save