Версия 1.0.0 #11

Merged
kor-elf merged 41 commits from develop into main 2025-06-14 22:56:20 +05:00
2 changed files with 27 additions and 0 deletions
Showing only changes of commit c8619cdc7f - Show all commits

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 {

View File

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