[chore] update go ffmpreg to v0.6.0 (#3515)

* pull in go-ffmpreg v0.6.0

* add code comment

* grrr linter

* set empty module name when calling ffmpeg / ffprobe
This commit is contained in:
kim
2024-11-06 13:38:13 +00:00
committed by GitHub
parent 6f4cb2f14e
commit b84637801a
14 changed files with 159 additions and 123 deletions

View File

@ -21,6 +21,7 @@ package ffmpeg
import (
"context"
"errors"
"codeberg.org/gruf/go-ffmpreg/wasm"
)
@ -35,12 +36,25 @@ var ffmpegRunner runner
// prepares the runner to only allow max given concurrent running instances.
func InitFfmpeg(ctx context.Context, max int) error {
ffmpegRunner.Init(max)
return compileFfmpeg(ctx)
return initWASM(ctx)
}
// Ffmpeg runs the given arguments with an instance of ffmpeg.
func Ffmpeg(ctx context.Context, args Args) (uint32, error) {
return ffmpegRunner.Run(ctx, func() (uint32, error) {
return wasm.Run(ctx, runtime, ffmpeg, args)
// Load WASM rt and module.
ffmpreg := ffmpreg.Load()
if ffmpreg == nil {
return 0, errors.New("wasm not initialized")
}
// Call into ffmpeg.
args.Name = "ffmpeg"
return wasm.Run(ctx,
ffmpreg.run,
ffmpreg.mod,
args,
)
})
}