From 910420634c05e23b292e9fa32d7d3bc08c66b643 Mon Sep 17 00:00:00 2001 From: afkarxyz Date: Sat, 13 Dec 2025 13:36:36 +0700 Subject: [PATCH] v6.8 --- backend/ffmpeg.go | 18 +++--------------- backend/ffmpeg_unix.go | 14 ++++++++++++++ backend/ffmpeg_windows.go | 17 +++++++++++++++++ 3 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 backend/ffmpeg_unix.go create mode 100644 backend/ffmpeg_windows.go diff --git a/backend/ffmpeg.go b/backend/ffmpeg.go index fa2f38e..bbf9034 100644 --- a/backend/ffmpeg.go +++ b/backend/ffmpeg.go @@ -76,11 +76,7 @@ func IsFFmpegInstalled() (bool, error) { // Verify it's executable cmd := exec.Command(ffmpegPath, "-version") // Hide console window on Windows - if runtime.GOOS == "windows" { - cmd.SysProcAttr = &syscall.SysProcAttr{ - HideWindow: true, - } - } + setHideWindow(cmd) err = cmd.Run() return err == nil, nil } @@ -392,11 +388,7 @@ func ConvertAudio(req ConvertAudioRequest) ([]ConvertAudioResult, error) { cmd := exec.Command(ffmpegPath, args...) // Hide console window on Windows - if runtime.GOOS == "windows" { - cmd.SysProcAttr = &syscall.SysProcAttr{ - HideWindow: true, - } - } + setHideWindow(cmd) output, err := cmd.CombinedOutput() if err != nil { result.Error = fmt.Sprintf("conversion failed: %s - %s", err.Error(), string(output)) @@ -542,11 +534,7 @@ func InstallFFmpegFromFile(filePath string) error { cmd := exec.Command(ffmpegPath, "-version") // Hide console window on Windows - if runtime.GOOS == "windows" { - cmd.SysProcAttr = &syscall.SysProcAttr{ - HideWindow: true, - } - } + setHideWindow(cmd) verifyErr = cmd.Run() if verifyErr == nil { break diff --git a/backend/ffmpeg_unix.go b/backend/ffmpeg_unix.go new file mode 100644 index 0000000..20cdff5 --- /dev/null +++ b/backend/ffmpeg_unix.go @@ -0,0 +1,14 @@ +//go:build !windows +// +build !windows + +package backend + +import ( + "os/exec" +) + +// setHideWindow is a no-op on non-Windows platforms +func setHideWindow(cmd *exec.Cmd) { + // No-op on Unix-like systems +} + diff --git a/backend/ffmpeg_windows.go b/backend/ffmpeg_windows.go new file mode 100644 index 0000000..12d4c66 --- /dev/null +++ b/backend/ffmpeg_windows.go @@ -0,0 +1,17 @@ +//go:build windows +// +build windows + +package backend + +import ( + "os/exec" + "syscall" +) + +// setHideWindow sets HideWindow attribute for Windows processes +func setHideWindow(cmd *exec.Cmd) { + cmd.SysProcAttr = &syscall.SysProcAttr{ + HideWindow: true, + } +} +