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,13 +1,25 @@
package ffmpeg
import (
"errors"
"fyne.io/fyne/v2/lang"
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application/setting"
)
type UtilitiesContract interface {
GetFFmpeg() FFmpegContract
GetFFprobe() FFprobeContract
GetFFplay() FFplayContract
UtilityCheck() bool
GetFFmpeg() (FFmpegContract, error)
GetFFmpegPath() string
ChangeFFmpeg(path string) error
GetFFprobe() (FFprobeContract, error)
GetFFprobePath() string
ChangeFFprobe(path string) error
GetFFplay() (FFplayContract, error)
GetFFplayPath() string
ChangeFFplay(path string) error
}
type utilities struct {
@@ -23,26 +35,131 @@ func NewUtilities(setting setting.SettingContract) UtilitiesContract {
}
}
func (u *utilities) GetFFmpeg() FFmpegContract {
func (u *utilities) UtilityCheck() bool {
var err error
_, err = u.GetFFmpeg()
if err != nil {
return false
}
_, err = u.GetFFprobe()
if err != nil {
return false
}
_, err = u.GetFFplay()
if err != nil {
return false
}
return true
}
func (u *utilities) GetFFmpeg() (FFmpegContract, error) {
if u.ffmpeg == nil {
u.ffmpeg = newFFmpeg(u.setting.GetFFmpegPath())
createFFmpeg, err := newFFmpeg(u.setting.GetFFmpegPath())
if err != nil {
return nil, err
}
u.ffmpeg = createFFmpeg
}
return u.ffmpeg
return u.ffmpeg, nil
}
func (u *utilities) GetFFprobe() FFprobeContract {
if u.ffprobe != nil {
u.ffprobe = newFFprobe(u.setting.GetFFprobePath())
func (u *utilities) GetFFmpegPath() string {
ffmpegService, err := u.GetFFmpeg()
if err != nil {
return ""
}
return ffmpegService.GetPath()
}
func (u *utilities) ChangeFFmpeg(path string) error {
if path == "" {
return errors.New(lang.L("errorFFmpeg"))
}
return u.ffprobe
createFFmpeg, err := newFFmpeg(path)
if err != nil {
return err
}
u.ffmpeg = createFFmpeg
u.setting.SetFFmpegPath(path)
return nil
}
func (u *utilities) GetFFplay() FFplayContract {
func (u *utilities) GetFFprobe() (FFprobeContract, error) {
if u.ffprobe == nil {
createFFprobe, err := newFFprobe(u.setting.GetFFprobePath())
if err != nil {
return nil, err
}
u.ffprobe = createFFprobe
}
return u.ffprobe, nil
}
func (u *utilities) GetFFprobePath() string {
ffprobeService, err := u.GetFFprobe()
if err != nil {
return ""
}
return ffprobeService.GetPath()
}
func (u *utilities) ChangeFFprobe(path string) error {
if path == "" {
return errors.New(lang.L("errorFFprobe"))
}
createFFprobe, err := newFFprobe(path)
if err != nil {
return err
}
u.ffprobe = createFFprobe
u.setting.SetFFprobePath(path)
return nil
}
func (u *utilities) GetFFplay() (FFplayContract, error) {
if u.ffplay == nil {
u.ffplay = newFFplay(u.setting.GetFFplayPath())
createFFplay, err := newFFplay(u.setting.GetFFplayPath())
if err != nil {
return nil, err
}
u.ffplay = createFFplay
}
return u.ffplay
return u.ffplay, nil
}
func (u *utilities) GetFFplayPath() string {
ffplayService, err := u.GetFFplay()
if err != nil {
return ""
}
return ffplayService.GetPath()
}
func (u *utilities) ChangeFFplay(path string) error {
if path == "" {
return errors.New(lang.L("errorFFplay"))
}
createFFplay, err := newFFplay(path)
if err != nil {
return err
}
u.ffplay = createFFplay
u.setting.SetFFplayPath(path)
return nil
}