Add FFplay support to the application

Integrated FFplay functionality across the application. This includes support for setting up the FFplay path and invoking FFplay for media playback.
This commit is contained in:
2025-05-19 22:49:09 +05:00
parent a831d56d93
commit 306383449a
17 changed files with 244 additions and 24 deletions

View File

@@ -32,8 +32,10 @@ type ConvertorContract interface {
GetTotalDuration(file *File) (float64, error)
GetFFmpegVesrion() (string, error)
GetFFprobeVersion() (string, error)
GetFFplayVersion() (string, error)
ChangeFFmpegPath(path string) (bool, error)
ChangeFFprobePath(path string) (bool, error)
ChangeFFplayPath(path string) (bool, error)
GetRunningProcesses() map[int]*exec.Cmd
GetSupportFormats() (encoder.ConvertorFormatsContract, error)
}
@@ -46,6 +48,7 @@ type ProgressContract interface {
type FFPathUtilities struct {
FFmpeg string
FFprobe string
FFplay string
}
type runningProcesses struct {
@@ -177,6 +180,17 @@ func (s Convertor) GetFFprobeVersion() (string, error) {
return text[0], nil
}
func (s Convertor) GetFFplayVersion() (string, error) {
cmd := exec.Command(s.ffPathUtilities.FFplay, "-version")
helper.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 (s Convertor) ChangeFFmpegPath(path string) (bool, error) {
cmd := exec.Command(path, "-version")
helper.PrepareBackgroundCommand(cmd)
@@ -205,6 +219,20 @@ func (s Convertor) ChangeFFprobePath(path string) (bool, error) {
return true, nil
}
func (s Convertor) ChangeFFplayPath(path string) (bool, error) {
cmd := exec.Command(path, "-version")
helper.PrepareBackgroundCommand(cmd)
out, err := cmd.CombinedOutput()
if err != nil {
return false, err
}
if strings.Contains(strings.TrimSpace(string(out)), "ffplay") == false {
return false, nil
}
s.ffPathUtilities.FFplay = path
return true, nil
}
func (s Convertor) GetSupportFormats() (encoder.ConvertorFormatsContract, error) {
formats := encoder.NewConvertorFormats()
cmd := exec.Command(s.ffPathUtilities.FFmpeg, "-encoders")