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.
53 lines
930 B
Go
53 lines
930 B
Go
package ffmpeg
|
|
|
|
import (
|
|
"errors"
|
|
"fyne.io/fyne/v2/lang"
|
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/utils"
|
|
"os/exec"
|
|
"strings"
|
|
)
|
|
|
|
type FFprobeContract interface {
|
|
GetPath() string
|
|
}
|
|
|
|
type ffprobe struct {
|
|
path string
|
|
}
|
|
|
|
func newFFprobe(path string) (FFprobeContract, error) {
|
|
if path == "" {
|
|
return nil, errors.New(lang.L("errorFFprobe"))
|
|
}
|
|
|
|
isCheck, err := checkFFprobePath(path)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if isCheck == false {
|
|
return nil, errors.New(lang.L("errorFFprobe"))
|
|
}
|
|
|
|
return &ffprobe{
|
|
path: path,
|
|
}, nil
|
|
}
|
|
|
|
func (f *ffprobe) GetPath() string {
|
|
return f.path
|
|
}
|
|
|
|
func checkFFprobePath(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)), "ffprobe") == false {
|
|
return false, nil
|
|
}
|
|
return true, nil
|
|
}
|