-
Notifications
You must be signed in to change notification settings - Fork 45
/
filter.go
61 lines (51 loc) · 1.56 KB
/
filter.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package astiav
//#include <libavfilter/avfilter.h>
import "C"
import (
"unsafe"
)
// https://ffmpeg.org/doxygen/7.0/structAVFilter.html
type Filter struct {
c *C.AVFilter
}
func newFilterFromC(c *C.AVFilter) *Filter {
if c == nil {
return nil
}
return &Filter{c: c}
}
// https://ffmpeg.org/doxygen/7.0/group__lavfi.html#gadd774ec49e50edf00158248e1bfe4ae6
func FindFilterByName(n string) *Filter {
cn := C.CString(n)
defer C.free(unsafe.Pointer(cn))
return newFilterFromC(C.avfilter_get_by_name(cn))
}
// https://ffmpeg.org/doxygen/7.0/structAVFilter.html#a28a4776f344f91055f42a4c2a1b15c0c
func (f *Filter) Name() string {
return C.GoString(f.c.name)
}
func (f *Filter) String() string {
return f.Name()
}
// https://ffmpeg.org/doxygen/7.0/structAVFilter.html#a04e408702054370fbe35c8d5b49f68cb
func (f *Filter) NbInputs() int {
return int(f.c.nb_inputs)
}
// https://ffmpeg.org/doxygen/7.0/structAVFilter.html#abb166cb2c9349de54d24aefb879608f4
func (f *Filter) NbOutputs() int {
return int(f.c.nb_outputs)
}
// https://ffmpeg.org/doxygen/7.0/structAVFilter.html#ad311151fe6e8c87a89f895bef7c8b98b
func (f *Filter) Inputs() (ps []*FilterPad) {
for idx := 0; idx < f.NbInputs(); idx++ {
ps = append(ps, newFilterPad(MediaType(C.avfilter_pad_get_type(f.c.inputs, C.int(idx)))))
}
return
}
// https://ffmpeg.org/doxygen/7.0/structAVFilter.html#ad0608786fa3e1ca6e4cc4b67039f77d7
func (f *Filter) Outputs() (ps []*FilterPad) {
for idx := 0; idx < f.NbOutputs(); idx++ {
ps = append(ps, newFilterPad(MediaType(C.avfilter_pad_get_type(f.c.outputs, C.int(idx)))))
}
return
}