-
Notifications
You must be signed in to change notification settings - Fork 0
/
split_node.go
43 lines (35 loc) · 960 Bytes
/
split_node.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package ffmpegtree
import "fmt"
type ISplitNode interface {
INode
IFilterNode
GetFanOut() int
}
// SplitNode implements ISplitNode
var _ ISplitNode = &SplitNode{}
// NOTE: to split an audio stream asplit filter should be used but for now SplitNode only works for
// video streams since there is no audio-video stream separation as of now. So splitting audio streams
// would not work.
type SplitNode struct {
BaseFilterNode
fanOut, called int
}
func (s *SplitNode) GetFanOut() int {
return s.fanOut
}
func (s *SplitNode) GetOutStreamName() string {
defer func() { s.called++ }()
return fmt.Sprintf("%v_%v", s.OutStreamName, s.called%s.fanOut)
}
func (s *SplitNode) FilterString() string {
if s.fanOut > 2 {
return fmt.Sprintf("split=%v", s.fanOut)
}
return "split"
}
func NewSplitNode(input INode, fanOut int) *SplitNode {
return &SplitNode{
BaseFilterNode: *NewBaseFilterNode([]INode{input}, randStr()),
fanOut: fanOut,
}
}