From fea5d23fc7a19d8804f4958c62aac122dbd32bbd Mon Sep 17 00:00:00 2001 From: Deluan Date: Tue, 6 Oct 2020 17:24:16 -0400 Subject: [PATCH] Add `ffmpeg` detection at start-up --- core/transcoder/ffmpeg.go | 3 +-- server/initial_setup.go | 13 +++++++++++++ server/server.go | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/core/transcoder/ffmpeg.go b/core/transcoder/ffmpeg.go index b65f78144..4108889f4 100644 --- a/core/transcoder/ffmpeg.go +++ b/core/transcoder/ffmpeg.go @@ -16,11 +16,10 @@ type Transcoder interface { } func New() Transcoder { - path, err := exec.LookPath("ffmpeg") + _, err := exec.LookPath("ffmpeg") if err != nil { log.Error("Unable to find ffmpeg", err) } - log.Debug("Found ffmpeg", "path", path) return &ffmpeg{} } diff --git a/server/initial_setup.go b/server/initial_setup.go index 5b5ac2675..1362c99d9 100644 --- a/server/initial_setup.go +++ b/server/initial_setup.go @@ -3,6 +3,7 @@ package server import ( "context" "fmt" + "os/exec" "time" "github.com/deluan/navidrome/conf" @@ -79,3 +80,15 @@ func createJWTSecret(ds model.DataStore) error { } return err } + +func checkFfmpegInstallation() { + path, err := exec.LookPath("ffmpeg") + if err == nil { + log.Debug("Found ffmpeg", "path", path) + } + log.Warn("Unable to find ffmpeg. Transcoding will fail if used", err) + if conf.Server.Scanner.Extractor == "ffmpeg" { + log.Warn("ffmpeg cannot be used for metadata extraction. Falling back to taglib") + conf.Server.Scanner.Extractor = "taglib" + } +} diff --git a/server/server.go b/server/server.go index 82945527a..f0f78d3ac 100644 --- a/server/server.go +++ b/server/server.go @@ -32,6 +32,7 @@ func New(scanner *scanner.Scanner, ds model.DataStore) *Server { initialSetup(ds) a.initRoutes() a.initScanner() + checkFfmpegInstallation() return a }