Added the ability to get the FFmpeg version.

This commit is contained in:
2025-06-09 23:19:48 +05:00
parent c49957e583
commit c8619cdc7f
2 changed files with 27 additions and 0 deletions

View File

@@ -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 {