Merge pull request #65 from banana-framework-lab/banana-patch-1

U In version 1.19, ffmpeg in the current directory cannot be used aut…
This commit is contained in:
leiiwang
2022-10-31 18:33:23 +08:00
committed by GitHub
2 changed files with 18 additions and 11 deletions

View File

@@ -14,6 +14,7 @@ type Stream struct {
Label Label Label Label
Selector Selector Selector Selector
Type string Type string
FfmpegPath string
Context context.Context Context context.Context
} }
@@ -31,6 +32,7 @@ func NewStream(node *Node, streamType string, label Label, selector Selector) *S
Label: label, Label: label,
Selector: selector, Selector: selector,
Type: streamType, Type: streamType,
FfmpegPath: "ffmpeg",
Context: context.Background(), Context: context.Background(),
} }
} }

7
run.go
View File

@@ -248,10 +248,15 @@ func SeparateProcessGroup() CompilationOption {
} }
} }
func (s *Stream) SetFfmpegPath(path string) *Stream {
s.FfmpegPath = path
return s
}
// for test // for test
func (s *Stream) Compile(options ...CompilationOption) *exec.Cmd { func (s *Stream) Compile(options ...CompilationOption) *exec.Cmd {
args := s.GetArgs() 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 { if a, ok := s.Context.Value("Stdin").(io.Reader); ok {
cmd.Stdin = a cmd.Stdin = a
} }