mirror of
https://github.com/u2takey/ffmpeg-go.git
synced 2025-09-26 20:11:17 +08:00

Discover CommandOption type and ffmpeg.GlobalCommandOptions array, that is processed before running ffmpeg or ffprobe commands. Add tests.
36 lines
882 B
Go
36 lines
882 B
Go
package ffmpeg_go
|
|
|
|
import (
|
|
"os/exec"
|
|
"syscall"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestCompileWithOptions(t *testing.T) {
|
|
out := Input("dummy.mp4").Output("dummy2.mp4")
|
|
cmd := out.Compile(func(s *Stream, cmd *exec.Cmd) {
|
|
if cmd.SysProcAttr == nil {
|
|
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
|
}
|
|
cmd.SysProcAttr.HideWindow = true
|
|
})
|
|
assert.Equal(t, true, cmd.SysProcAttr.HideWindow)
|
|
}
|
|
|
|
func TestGlobalCommandOptions(t *testing.T) {
|
|
out := Input("dummy.mp4").Output("dummy2.mp4")
|
|
GlobalCommandOptions = append(GlobalCommandOptions, func(cmd *exec.Cmd) {
|
|
if cmd.SysProcAttr == nil {
|
|
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
|
}
|
|
cmd.SysProcAttr.HideWindow = true
|
|
})
|
|
defer func() {
|
|
GlobalCommandOptions = GlobalCommandOptions[0 : len(GlobalCommandOptions)-1]
|
|
}()
|
|
cmd := out.Compile()
|
|
assert.Equal(t, true, cmd.SysProcAttr.HideWindow)
|
|
}
|