IDK man, changes I guess
This commit is contained in:
22
ffmpeg.go
22
ffmpeg.go
@@ -100,6 +100,7 @@ type Tools struct {
|
||||
|
||||
mu sync.Mutex
|
||||
encoders map[string]bool // usable encoders (hardware ones are test-encoded)
|
||||
filters map[string]bool // filters compiled into ffmpeg
|
||||
ready bool
|
||||
}
|
||||
|
||||
@@ -162,6 +163,12 @@ func (t *Tools) HasEncoder(name string) bool {
|
||||
return t.encoders[name]
|
||||
}
|
||||
|
||||
func (t *Tools) HasFilter(name string) bool {
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
return t.filters[name]
|
||||
}
|
||||
|
||||
// CodecList returns the catalog entries this ffmpeg build can use.
|
||||
func (t *Tools) CodecList() []Codec {
|
||||
t.mu.Lock()
|
||||
@@ -175,9 +182,9 @@ func (t *Tools) CodecList() []Codec {
|
||||
return out
|
||||
}
|
||||
|
||||
// detectEncoders lists the encoders compiled into ffmpeg and test-encodes a
|
||||
// few frames with each hardware encoder, since being compiled in does not mean
|
||||
// the GPU is present.
|
||||
// detectEncoders lists the encoders and filters compiled into ffmpeg and
|
||||
// test-encodes a few frames with each hardware encoder, since being compiled
|
||||
// in does not mean the GPU is present.
|
||||
func (t *Tools) detectEncoders() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
||||
defer cancel()
|
||||
@@ -191,6 +198,14 @@ func (t *Tools) detectEncoders() {
|
||||
}
|
||||
}
|
||||
}
|
||||
filters := map[string]bool{}
|
||||
if out, err := command(ctx, t.FFmpeg, "-hide_banner", "-filters").Output(); err == nil {
|
||||
for _, line := range strings.Split(string(out), "\n") {
|
||||
if f := strings.Fields(line); len(f) >= 3 && strings.Contains(f[2], "->") {
|
||||
filters[f[1]] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
usable := map[string]bool{}
|
||||
var wg sync.WaitGroup
|
||||
var mu sync.Mutex
|
||||
@@ -220,6 +235,7 @@ func (t *Tools) detectEncoders() {
|
||||
wg.Wait()
|
||||
t.mu.Lock()
|
||||
t.encoders = usable
|
||||
t.filters = filters
|
||||
t.ready = true
|
||||
t.mu.Unlock()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user