Add FFmpeg utilities configuration UI and automated downloading

Introduce a new UI for configuring FFmpeg, FFprobe, and FFplay paths with file selection and error handling. Add platform-specific logic for downloading and extracting FFmpeg binaries directly within the application, improving user experience.
This commit is contained in:
2025-06-07 01:30:32 +05:00
parent b24155caf6
commit c60b9f7b0c
22 changed files with 1118 additions and 37 deletions

View File

@@ -1,19 +1,52 @@
package ffmpeg
import (
"errors"
"fyne.io/fyne/v2/lang"
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/utils"
"os/exec"
"strings"
)
type FFplayContract interface {
SetPath(path string)
GetPath() string
}
type ffplay struct {
path string
}
func newFFplay(path string) FFplayContract {
func newFFplay(path string) (FFplayContract, error) {
if path == "" {
return nil, errors.New(lang.L("errorFFplay"))
}
isCheck, err := checkFFplayPath(path)
if err != nil {
return nil, err
}
if isCheck == false {
return nil, errors.New(lang.L("errorFFplay"))
}
return &ffplay{
path: path,
}
}, nil
}
func (f *ffplay) SetPath(path string) {
f.path = path
func (f *ffplay) GetPath() string {
return f.path
}
func checkFFplayPath(path string) (bool, error) {
cmd := exec.Command(path, "-version")
utils.PrepareBackgroundCommand(cmd)
out, err := cmd.CombinedOutput()
if err != nil {
return false, err
}
if strings.Contains(strings.TrimSpace(string(out)), "ffplay") == false {
return false, nil
}
return true, nil
}