afmpeg

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package afmpeg renders a keryx timeline by driving FFmpeg compiled to WebAssembly (the ffmpeg-wasi engine) through the afmpeg library — no system ffmpeg binary, entirely in memory. It is an alternative provider.Renderer to the shell-out "ffmpeg" adapter, selected via providers.render=afmpeg.

The reel logic (still-loop, xfade-concat, audio mix) lives here, in keryx; afmpeg/ffmpeg-wasi stay generic. This adapter maps a provider.Timeline to a generic afmpeg.Command (its filtergraph in FilterComplex) and runs it over an in-memory filesystem, then writes the finished mp4 to t.OutputPath.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

Renderer is the in-memory wasm implementation of provider.Renderer. The compiled wasm runtime (the expensive step) is created lazily and cached, so a build's VO probes and the final render share one compilation; Close releases it.

func New

func New(cfg config.Reader) (*Renderer, error)

New resolves the ffmpeg-wasi module (config providers.render.module — a path or an https URL — falling back to $KERYX_FFMPEG_WASI, then to the pinned published default) and returns a Renderer.

func (*Renderer) Close

func (r *Renderer) Close() error

Close releases the cached wasm runtime. The build/studio closes the renderer once it has finished probing + rendering (the renderer implements io.Closer).

func (*Renderer) Probe

func (r *Renderer) Probe(ctx context.Context, srcFs afero.Fs, path string) (float64, error)

Probe returns a media file's duration in seconds via the engine's in-memory probe op (afmpeg v0.4.0's Runtime.Probe — no system ffprobe). The file is staged into a job fs first so srcFs may be any afero.Fs.

func (*Renderer) Render

func (r *Renderer) Render(ctx context.Context, srcFs afero.Fs, t provider.Timeline) (provider.Video, error)

Render assembles the timeline into t.OutputPath (a path in srcFs) via the wasm engine and returns the result. Inputs are read from srcFs and the finished mp4 is written back into srcFs, so srcFs may be any afero.Fs — an on-disk checkout, an in-memory project, or a git-worktree fs.

func (*Renderer) RenderProgress added in v0.9.0

func (r *Renderer) RenderProgress(
	ctx context.Context, srcFs afero.Fs, t provider.Timeline, onProgress func(provider.Progress),
) (provider.Video, error)

RenderProgress renders while streaming a live percentage to onProgress, satisfying provider.ProgressRenderer (spec 0026 Phase B).

afmpeg reports progress on a channel attached to the context, and does so best-effort: a non-blocking send means a slow consumer misses samples rather than stalling the render. A nil onProgress behaves exactly like Render — no channel is attached, so afmpeg does no progress work at all.

Fraction is -1 when afmpeg cannot determine completion (a generative input with no source to consume, and an engine reporting no duration). That is passed through as a NEGATIVE percent rather than clamped to zero: a caller must be able to tell "0% done" from "cannot say", or a stuck bar and an unknowable one look identical.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL