Check version of ffmpeg. Closes #587
This commit is contained in:
@@ -4,6 +4,10 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/mod/semver"
|
||||
)
|
||||
|
||||
// verifyFFMpegPath verifies that the path exists, is a file, and is executable.
|
||||
@@ -28,5 +32,22 @@ func verifyFFMpegPath(path string) error {
|
||||
return errors.New("ffmpeg path is not executable")
|
||||
}
|
||||
|
||||
suggestedVersion := "v4.1.5"
|
||||
cmd := exec.Command(path)
|
||||
out, err := cmd.CombinedOutput()
|
||||
|
||||
response := string(out)
|
||||
if response == "" {
|
||||
fmt.Println(err)
|
||||
return fmt.Errorf("unable to determine the version of your ffmpeg installation at %s. you may experience issues with video.", path)
|
||||
}
|
||||
|
||||
responseComponents := strings.Split(response, " ")
|
||||
fullVersionString := responseComponents[2]
|
||||
versionString := "v" + strings.Split(fullVersionString, "-")[0]
|
||||
if !semver.IsValid(versionString) || semver.Compare(versionString, suggestedVersion) == -1 {
|
||||
return fmt.Errorf("your %s version of ffmpeg at %s may be older than the suggested version of %s. you may experience issues with video.", versionString, path, suggestedVersion)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user