- Fixed Windows ffmpeg.exe popups by adding //go:build tags and exporting CreateCommand/CreateCommandRaw properly - Use utils.GetFFmpegPath(), GetFFprobePath(), GetFFplayPath() instead of hardcoded strings - Switch AV1 codec to H.264 for better performance (AV1/libsvtav1 is extremely slow) - Minor UI component refinements (padding, SetMinSize)
37 lines
1.3 KiB
Go
37 lines
1.3 KiB
Go
//go:build windows
|
|
|
|
package utils
|
|
|
|
import (
|
|
"context"
|
|
"os/exec"
|
|
"syscall"
|
|
)
|
|
|
|
// CreateCommand is a platform-specific implementation for Windows.
|
|
// It ensures that the command is created without a new console window,
|
|
// preventing disruptive pop-ups when running console applications (like ffmpeg)
|
|
// from a GUI application.
|
|
func CreateCommand(ctx context.Context, name string, arg ...string) *exec.Cmd {
|
|
cmd := exec.CommandContext(ctx, name, arg...)
|
|
// SysProcAttr is used to control process creation parameters on Windows.
|
|
// HideWindow: If true, the new process's console window will be hidden.
|
|
// CreationFlags: CREATE_NO_WINDOW (0x08000000) prevents the creation of a console window.
|
|
// This is crucial for a smooth GUI experience when launching CLI tools.
|
|
cmd.SysProcAttr = &syscall.SysProcAttr{
|
|
HideWindow: true,
|
|
CreationFlags: 0x08000000, // CREATE_NO_WINDOW
|
|
}
|
|
return cmd
|
|
}
|
|
|
|
// CreateCommandRaw is a platform-specific implementation for Windows, without a context.
|
|
// It applies the same console hiding behavior as CreateCommand.
|
|
func CreateCommandRaw(name string, arg ...string) *exec.Cmd {
|
|
cmd := exec.Command(name, arg...)
|
|
cmd.SysProcAttr = &syscall.SysProcAttr{
|
|
HideWindow: true,
|
|
CreationFlags: 0x08000000, // CREATE_NO_WINDOW
|
|
}
|
|
return cmd
|
|
} |