IDK man, changes I guess

This commit is contained in:
2026-11-06 17:57:01 +00:00
parent 9fb9395f99
commit 4c8cafd733
15 changed files with 785 additions and 61 deletions

View File

@@ -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()
}