Skip to content

Commit

Permalink
[chore] pull in go-ffmpreg v0.4.1 (#3485)
Browse files Browse the repository at this point in the history
* pull in go-ffmpreg v0.4.1

* bring back GTS_WAZERO_COMPILATION_CACHE
  • Loading branch information
NyaaaWhatsUpDoc authored Oct 28, 2024
1 parent 8f4a96c commit e86592b
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 40 deletions.
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 != "" {
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

0 comments on commit e86592b

Please sign in to comment.