Support a local working directory copy of ffmpeg. Closes #276
This commit is contained in:
@@ -28,6 +28,14 @@ func getDefaults() config {
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
32
config/verifyInstall.go
Normal file
32
config/verifyInstall.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
//verifyFFMpegPath verifies that the path exists, is a file, and is executable
|
||||
func verifyFFMpegPath(path string) error {
|
||||
stat, err := os.Stat(path)
|
||||
|
||||
if os.IsNotExist(err) {
|
||||
return errors.New("ffmpeg path does not exist")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("error while verifying the ffmpeg path: %s", err.Error())
|
||||
}
|
||||
|
||||
if stat.IsDir() {
|
||||
return errors.New("ffmpeg path can not be a folder")
|
||||
}
|
||||
|
||||
mode := stat.Mode()
|
||||
//source: https://stackoverflow.com/a/60128480
|
||||
if mode&0111 == 0 {
|
||||
return errors.New("ffmpeg path is not executable")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user