Discover CommandOption type and ffmpeg.GlobalCommandOptions array, that is processed before running ffmpeg or ffprobe commands.
Add tests.
This commit is contained in:
Denis Borzenko
2023-02-28 23:46:11 +03:00
parent 2a41acb422
commit bbf2881ff4
4 changed files with 39 additions and 1 deletions

7
run.go
View File

@@ -236,6 +236,10 @@ func (s *Stream) ErrorToStdOut() *Stream {
return s.WithErrorOutput(os.Stdout)
}
type CommandOption func(cmd *exec.Cmd)
var GlobalCommandOptions = make([]CommandOption, 0)
type CompilationOption func(s *Stream, cmd *exec.Cmd)
func (s *Stream) SetFfmpegPath(path string) *Stream {
@@ -259,6 +263,9 @@ func (s *Stream) Compile(options ...CompilationOption) *exec.Cmd {
for _, option := range options {
option(s, cmd)
}
for _, option := range GlobalCommandOptions {
option(cmd)
}
log.Printf("compiled command: ffmpeg %s\n", strings.Join(args, " "))
return cmd
}