From a90f7ca8563db2064303e9e19bec3ea71df7cec4 Mon Sep 17 00:00:00 2001 From: zhangzhonghao Date: Mon, 31 Oct 2022 15:24:09 +0800 Subject: [PATCH] U In version 1.19, ffmpeg in the current directory cannot be used automatically, and the path of ffmpeg can be customized --- node.go | 22 ++++++++++++---------- run.go | 7 ++++++- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/node.go b/node.go index bcb2ba0..4bf3697 100644 --- a/node.go +++ b/node.go @@ -10,11 +10,12 @@ import ( ) type Stream struct { - Node *Node - Label Label - Selector Selector - Type string - Context context.Context + Node *Node + Label Label + Selector Selector + Type string + FfmpegPath string + Context context.Context } type RunHook struct { @@ -27,11 +28,12 @@ type RunHook struct { func NewStream(node *Node, streamType string, label Label, selector Selector) *Stream { return &Stream{ - Node: node, - Label: label, - Selector: selector, - Type: streamType, - Context: context.Background(), + Node: node, + Label: label, + Selector: selector, + Type: streamType, + FfmpegPath: "ffmpeg", + Context: context.Background(), } } diff --git a/run.go b/run.go index 6d386bb..e917404 100644 --- a/run.go +++ b/run.go @@ -248,10 +248,15 @@ func SeparateProcessGroup() CompilationOption { } } +func (s *Stream) SetFfmpegPath(path string) *Stream { + s.FfmpegPath = path + return s +} + // for test func (s *Stream) Compile(options ...CompilationOption) *exec.Cmd { args := s.GetArgs() - cmd := exec.CommandContext(s.Context, "ffmpeg", args...) + cmd := exec.CommandContext(s.Context, s.FfmpegPath, args...) if a, ok := s.Context.Value("Stdin").(io.Reader); ok { cmd.Stdin = a }