Added the ability to get the FFmpeg version.
This commit is contained in:
parent
c49957e583
commit
c8619cdc7f
@ -7,6 +7,7 @@ import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/utils"
|
||||
"io"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -17,6 +18,7 @@ type ProgressContract interface {
|
||||
|
||||
type FFmpegContract interface {
|
||||
GetPath() string
|
||||
GetFFmpegVersion() (string, error)
|
||||
GetEncoders(scanner func(scanner *bufio.Reader)) error
|
||||
RunConvert(setting ConvertSetting, progress ProgressContract, beforeWait func(cmd *exec.Cmd), afterWait func(cmd *exec.Cmd)) error
|
||||
}
|
||||
@ -47,6 +49,17 @@ func (f *ffmpeg) GetPath() string {
|
||||
return f.path
|
||||
}
|
||||
|
||||
func (f *ffmpeg) GetFFmpegVersion() (string, error) {
|
||||
cmd := exec.Command(f.path, "-version")
|
||||
utils.PrepareBackgroundCommand(cmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
text := regexp.MustCompile("\r?\n").Split(strings.TrimSpace(string(out)), -1)
|
||||
return text[0], nil
|
||||
}
|
||||
|
||||
func (f *ffmpeg) RunConvert(setting ConvertSetting, progress ProgressContract, beforeWait func(cmd *exec.Cmd), afterWait func(cmd *exec.Cmd)) error {
|
||||
overwriteOutputFiles := "-n"
|
||||
if setting.OverwriteOutputFiles == true {
|
||||
|
@ -24,6 +24,7 @@ type UtilitiesContract interface {
|
||||
UtilityCheck() bool
|
||||
|
||||
GetFFmpeg() (FFmpegContract, error)
|
||||
GetFFmpegVersion() string
|
||||
GetFFmpegPath() string
|
||||
ChangeFFmpeg(path string) error
|
||||
|
||||
@ -82,6 +83,19 @@ func (u *utilities) GetFFmpeg() (FFmpegContract, error) {
|
||||
return u.ffmpeg, nil
|
||||
}
|
||||
|
||||
func (u *utilities) GetFFmpegVersion() string {
|
||||
ffmpegService, err := u.GetFFmpeg()
|
||||
if err != nil {
|
||||
return lang.L("errorFFmpegVersion")
|
||||
}
|
||||
|
||||
version, err := ffmpegService.GetFFmpegVersion()
|
||||
if err != nil {
|
||||
return lang.L("errorFFmpegVersion")
|
||||
}
|
||||
return version
|
||||
}
|
||||
|
||||
func (u *utilities) GetFFmpegPath() string {
|
||||
ffmpegService, err := u.GetFFmpeg()
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user