Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] pull in go-ffmpreg v0.4.1 #3485

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
codeberg.org/gruf/go-debug v1.3.0
codeberg.org/gruf/go-errors/v2 v2.3.2
codeberg.org/gruf/go-fastcopy v1.1.3
codeberg.org/gruf/go-ffmpreg v0.3.1
codeberg.org/gruf/go-ffmpreg v0.4.2
codeberg.org/gruf/go-iotools v0.0.0-20240710125620-934ae9c654cf
codeberg.org/gruf/go-kv v1.6.5
codeberg.org/gruf/go-list v0.0.0-20240425093752-494db03d641f
Expand Down
4 changes: 2 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 9 additions & 26 deletions internal/media/ffmpeg/wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@ import (
ffprobelib "codeberg.org/gruf/go-ffmpreg/embed/ffprobe"
"codeberg.org/gruf/go-ffmpreg/wasm"
"github.com/tetratelabs/wazero"
"github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1"
)

// Use all core features required by ffmpeg / ffprobe
// (these should be the same but we OR just in case).
const corefeatures = wasm.CoreFeatures

var (
// shared WASM runtime instance.
runtime wazero.Runtime
Expand Down Expand Up @@ -91,38 +86,26 @@ func compileFfprobe(ctx context.Context) error {

// initRuntime initializes the global wazero.Runtime,
// if already initialized this function is a no-op.
func initRuntime(ctx context.Context) error {
func initRuntime(ctx context.Context) (err error) {
if runtime != nil {
return nil
}

var cache wazero.CompilationCache
// Create new runtime config.
cfg := wazero.NewRuntimeConfig()

if dir := os.Getenv("GTS_WAZERO_COMPILATION_CACHE"); dir != "" {
tsmethurst marked this conversation as resolved.
Show resolved Hide resolved
var err error

// Use on-filesystem compilation cache given by env.
cache, err = wazero.NewCompilationCacheWithDir(dir)
cache, err := wazero.NewCompilationCacheWithDir(dir)
if err != nil {
return err
}
}

// Prepare config with cache.
cfg := wazero.NewRuntimeConfig()
cfg = cfg.WithCoreFeatures(corefeatures)
cfg = cfg.WithCompilationCache(cache)

// Instantiate runtime with prepared config.
rt := wazero.NewRuntimeWithConfig(ctx, cfg)

// Instantiate wasi snapshot preview features into runtime.
_, err := wasi_snapshot_preview1.Instantiate(ctx, rt)
if err != nil {
return err
// Update runtime config with cache.
cfg = cfg.WithCompilationCache(cache)
}

// Set runtime.
runtime = rt
return nil
// Initialize new runtime from config.
runtime, err = wasm.NewRuntime(ctx, cfg)
return
}
Binary file modified vendor/codeberg.org/gruf/go-ffmpreg/embed/ffmpeg/ffmpeg.wasm
Binary file not shown.
Binary file modified vendor/codeberg.org/gruf/go-ffmpreg/embed/ffprobe/ffprobe.wasm
Binary file not shown.
74 changes: 74 additions & 0 deletions vendor/codeberg.org/gruf/go-ffmpreg/wasm/funcs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions vendor/codeberg.org/gruf/go-ffmpreg/wasm/runtime.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ codeberg.org/gruf/go-fastcopy
# codeberg.org/gruf/go-fastpath/v2 v2.0.0
## explicit; go 1.14
codeberg.org/gruf/go-fastpath/v2
# codeberg.org/gruf/go-ffmpreg v0.3.1
# codeberg.org/gruf/go-ffmpreg v0.4.2
## explicit; go 1.22.0
codeberg.org/gruf/go-ffmpreg/embed/ffmpeg
codeberg.org/gruf/go-ffmpreg/embed/ffprobe
Expand Down