Files
majordomo/videogen/matte.go
T
steveandClaude Fable 5 5f175ecf82
CI / Tidy (pull_request) Successful in 9m27s
CI / Build & Test (pull_request) Successful in 10m43s
Gadfly review (reusable) / review (pull_request) Successful in 10m9s
Adversarial Review (Gadfly) / review (pull_request) Successful in 10m9s
feat: wave-3 video surfaces — lipsync, video matte, video upscale, chain jobs (ADR-0025)
- videogen.LipSyncer/LipsyncProvider: SadTalker talking heads via
  POST /upstream/<id>/v1/talking_head (multipart image+audio parts,
  still/enhance/preprocess flags) -> mp4.
- videogen.VideoBackgroundRemover/VideoBackgroundRemovalProvider:
  POST /upstream/<id>/v1/video/matte (output greenscreen_mp4|alpha_webm).
- videogen.VideoUpscaler/VideoUpscaleProvider:
  POST /upstream/<id>/v1/video/upscale (scale 2|4).
- videogen.Chainer/ChainerProvider: async long-video chain-job client —
  SubmitChain (JSON POST /v1/video/chain, init_image_b64), ChainStatus
  (GET /v1/jobs/{id}, tolerant segment-id decode), ChainResult,
  ChainSegmentResult (partial delivery after mid-chain failure); hostile
  job-id path rejection.
- Shared singleVideoResult validation (positive video evidence) + a
  videoInputFilename hint helper; httptest contract tests per surface;
  ADR-0025 (index row deferred — MJ-A backfills the ADR index table and
  parallel edits would conflict).

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-07-16 17:07:27 -04:00

81 lines
3.0 KiB
Go

package videogen
import "context"
// VideoBackgroundRemovalRequest asks a video-matting backend (Robust Video
// Matting style) to separate the foreground subject from the background of a
// clip. Zero values mean "backend default" (ADR-0025).
type VideoBackgroundRemovalRequest struct {
// Video is the encoded clip to matte. Required. Carried as bytes (never
// a URL).
Video []byte
// MIME is the video MIME type (e.g. "video/mp4"); "" = let the backend
// sniff it.
MIME string
// Filename is the multipart filename hint some backends key their format
// detection on; "" derives one from MIME ("video.mp4") or falls back to
// "video".
Filename string
// Output selects the delivery container: "greenscreen_mp4" (subject over
// solid green, universally playable) or "alpha_webm" (true transparency,
// VP9 alpha channel); "" = backend default.
Output string
}
// VideoBackgroundRemovalOption mutates a VideoBackgroundRemovalRequest
// before it is sent.
type VideoBackgroundRemovalOption func(*VideoBackgroundRemovalRequest)
// WithVideoBackgroundOutput selects the delivery container
// ("greenscreen_mp4" or "alpha_webm").
func WithVideoBackgroundOutput(o string) VideoBackgroundRemovalOption {
return func(r *VideoBackgroundRemovalRequest) { r.Output = o }
}
// Apply returns a copy of the request with all options applied.
func (r VideoBackgroundRemovalRequest) Apply(opts ...VideoBackgroundRemovalOption) VideoBackgroundRemovalRequest {
for _, opt := range opts {
opt(&r)
}
return r
}
// VideoBackgroundRemover mattes the subject out of video clips — the moving-
// picture sibling of imagegen.BackgroundRemover.
type VideoBackgroundRemover interface {
// RemoveVideoBackground returns the matted clip. Matting is slow
// (per-frame inference); bound the call with a context deadline.
RemoveVideoBackground(ctx context.Context, req VideoBackgroundRemovalRequest, opts ...VideoBackgroundRemovalOption) (*Result, error)
}
// VideoBackgroundRemoverModelOption configures a VideoBackgroundRemover at
// construction time. Reserved for future per-model settings.
type VideoBackgroundRemoverModelOption func(*VideoBackgroundRemoverModelConfig)
// VideoBackgroundRemoverModelConfig carries per-model construction settings.
type VideoBackgroundRemoverModelConfig struct{}
// ApplyVideoBackgroundRemoverModelOptions folds options into a config.
func ApplyVideoBackgroundRemoverModelOptions(opts []VideoBackgroundRemoverModelOption) VideoBackgroundRemoverModelConfig {
var cfg VideoBackgroundRemoverModelConfig
for _, opt := range opts {
opt(&cfg)
}
return cfg
}
// VideoBackgroundRemovalProvider mints VideoBackgroundRemovers bound to one
// backend.
type VideoBackgroundRemovalProvider interface {
// Name is the registry identifier for the provider.
Name() string
// VideoBackgroundRemoverModel returns a VideoBackgroundRemover bound to
// the given id (passed through to the backend verbatim; no catalog
// validation).
VideoBackgroundRemoverModel(id string, opts ...VideoBackgroundRemoverModelOption) (VideoBackgroundRemover, error)
}