From 2b8aea87971c6840288fe09ea367cce22372bac0 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Wed, 21 Oct 2020 21:47:42 -0700 Subject: [PATCH] Support a local working directory copy of ffmpeg. Closes #276 --- config/defaults.go | 8 ++++++++ {core/ffmpeg => config}/verifyInstall.go | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) rename {core/ffmpeg => config}/verifyInstall.go (80%) diff --git a/config/defaults.go b/config/defaults.go index eb7545a7d..32b451d06 100644 --- a/config/defaults.go +++ b/config/defaults.go @@ -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 { diff --git a/core/ffmpeg/verifyInstall.go b/config/verifyInstall.go similarity index 80% rename from core/ffmpeg/verifyInstall.go rename to config/verifyInstall.go index 1b8e212a9..4c045ba92 100644 --- a/core/ffmpeg/verifyInstall.go +++ b/config/verifyInstall.go @@ -1,4 +1,4 @@ -package ffmpeg +package config import ( "errors" @@ -6,8 +6,8 @@ import ( "os" ) -//VerifyFFMpegPath verifies that the path exists, is a file, and is executable -func VerifyFFMpegPath(path string) error { +//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) {