Add GetFFprobeVersion
method to retrieve FFprobe version details
Extended `FFprobeContract` with `GetVersion` to fetch FFprobe version. Implemented version extraction in `utilities` and `ffprobe` to support version retrieval functionality.
This commit is contained in:
parent
a9c59137af
commit
d7428683e4
@ -5,6 +5,7 @@ import (
|
|||||||
"fyne.io/fyne/v2/lang"
|
"fyne.io/fyne/v2/lang"
|
||||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/utils"
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/utils"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
@ -12,6 +13,7 @@ import (
|
|||||||
|
|
||||||
type FFprobeContract interface {
|
type FFprobeContract interface {
|
||||||
GetPath() string
|
GetPath() string
|
||||||
|
GetVersion() (string, error)
|
||||||
GetTotalDuration(file *File) (float64, error)
|
GetTotalDuration(file *File) (float64, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,6 +43,17 @@ func (f *ffprobe) GetPath() string {
|
|||||||
return f.path
|
return f.path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *ffprobe) GetVersion() (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 *ffprobe) GetTotalDuration(file *File) (duration float64, err error) {
|
func (f *ffprobe) GetTotalDuration(file *File) (duration float64, err error) {
|
||||||
args := []string{"-v", "error", "-select_streams", "v:0", "-count_packets", "-show_entries", "stream=nb_read_packets", "-of", "csv=p=0", file.Path}
|
args := []string{"-v", "error", "-select_streams", "v:0", "-count_packets", "-show_entries", "stream=nb_read_packets", "-of", "csv=p=0", file.Path}
|
||||||
cmd := exec.Command(f.path, args...)
|
cmd := exec.Command(f.path, args...)
|
||||||
|
@ -29,6 +29,7 @@ type UtilitiesContract interface {
|
|||||||
ChangeFFmpeg(path string) error
|
ChangeFFmpeg(path string) error
|
||||||
|
|
||||||
GetFFprobe() (FFprobeContract, error)
|
GetFFprobe() (FFprobeContract, error)
|
||||||
|
GetFFprobeVersion() string
|
||||||
GetFFprobePath() string
|
GetFFprobePath() string
|
||||||
ChangeFFprobe(path string) error
|
ChangeFFprobe(path string) error
|
||||||
|
|
||||||
@ -132,6 +133,19 @@ func (u *utilities) GetFFprobe() (FFprobeContract, error) {
|
|||||||
return u.ffprobe, nil
|
return u.ffprobe, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *utilities) GetFFprobeVersion() string {
|
||||||
|
ffprobeService, err := u.GetFFprobe()
|
||||||
|
if err != nil {
|
||||||
|
return lang.L("errorFFprobeVersion")
|
||||||
|
}
|
||||||
|
|
||||||
|
ffprobeVersion, err := ffprobeService.GetVersion()
|
||||||
|
if err != nil {
|
||||||
|
return lang.L("errorFFprobeVersion")
|
||||||
|
}
|
||||||
|
return ffprobeVersion
|
||||||
|
}
|
||||||
|
|
||||||
func (u *utilities) GetFFprobePath() string {
|
func (u *utilities) GetFFprobePath() string {
|
||||||
ffprobeService, err := u.GetFFprobe()
|
ffprobeService, err := u.GetFFprobe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user