Версия 1.0.0 #11
@ -5,6 +5,7 @@ import (
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/utils"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode"
|
||||
@ -12,6 +13,7 @@ import (
|
||||
|
||||
type FFprobeContract interface {
|
||||
GetPath() string
|
||||
GetVersion() (string, error)
|
||||
GetTotalDuration(file *File) (float64, error)
|
||||
}
|
||||
|
||||
@ -41,6 +43,17 @@ func (f *ffprobe) GetPath() string {
|
||||
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) {
|
||||
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...)
|
||||
|
@ -29,6 +29,7 @@ type UtilitiesContract interface {
|
||||
ChangeFFmpeg(path string) error
|
||||
|
||||
GetFFprobe() (FFprobeContract, error)
|
||||
GetFFprobeVersion() string
|
||||
GetFFprobePath() string
|
||||
ChangeFFprobe(path string) error
|
||||
|
||||
@ -132,6 +133,19 @@ func (u *utilities) GetFFprobe() (FFprobeContract, error) {
|
||||
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 {
|
||||
ffprobeService, err := u.GetFFprobe()
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user