Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import (
)

type Stream struct {
Node *Node
Label Label
Selector Selector
Type string
FfmpegPath string
Context context.Context
Node *Node
Label Label
Selector Selector
Type string
Context context.Context
}

type RunHook struct {
Expand All @@ -28,12 +27,11 @@ type RunHook struct {

func NewStream(node *Node, streamType string, label Label, selector Selector) *Stream {
return &Stream{
Node: node,
Label: label,
Selector: selector,
Type: streamType,
FfmpegPath: "ffmpeg",
Context: context.Background(),
Node: node,
Label: label,
Selector: selector,
Type: streamType,
Context: context.Background(),
}
}

Expand Down
10 changes: 7 additions & 3 deletions run.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ var GlobalCommandOptions = make([]CommandOption, 0)
type CompilationOption func(s *Stream, cmd *exec.Cmd)

func (s *Stream) SetFfmpegPath(path string) *Stream {
s.FfmpegPath = path
s.Context = context.WithValue(s.Context, "ffmpeg_path", path)
return s
}

Expand All @@ -255,7 +255,11 @@ func (s *Stream) Silent(isSilent bool) *Stream {
}
func (s *Stream) Compile(options ...CompilationOption) *exec.Cmd {
args := s.GetArgs()
cmd := exec.CommandContext(s.Context, s.FfmpegPath, args...)
ffmpegPath := "ffmpeg"
if a, ok := s.Context.Value("ffmpeg_path").(string); ok && a != "" {
ffmpegPath = a
}
cmd := exec.CommandContext(s.Context, ffmpegPath, args...)
if a, ok := s.Context.Value("Stdin").(io.Reader); ok {
cmd.Stdin = a
}
Expand All @@ -268,7 +272,7 @@ func (s *Stream) Compile(options ...CompilationOption) *exec.Cmd {
for _, option := range GlobalCommandOptions {
option(cmd)
}
if LogCompiledCommand {
if LogCompiledCommand {
log.Printf("compiled command: ffmpeg %s\n", strings.Join(args, " "))
}
return cmd
Expand Down