muvid.footage.strategy¶
The pluggable SelectionStrategy registry — alignments → an EDL.
The user-extensible strategy pattern behind full-auto assembly: a strategy turns a set of
FootageAlignments (which clip covers which span of the
song, with a confidence) into an EDL (which clip to SHOW for each span). Strategies emit
only {song_start, song_end, clip_id} — the clip_in sign convention lives in
muvid.footage.edl.derive_cuts() (SSOT), so a third-party strategy can’t desync the
cut. Every strategy’s output still passes validate_edl() before
any cutting, so a strategy that leaves a gap fails loudly with the exact uncovered span.
**A strategy sees reliable the way it already sees overlaps: as a preference**
(muvid#88). Every built-in ranks a vouched clip above an unvouched one for the same span
via _prefer_vouched(), and falls back to an unvouched clip only where nothing else
covers the span — so one badly-aligned clip in a shoot costs the spans only it covered,
not the whole edit. The strategies still decide nothing about trust: they never drop a
source, and the verdict they read (FootageAlignment.reliable) is
vouches_for()’s. A third-party strategy that ranks clips itself
should carry the same preference; weighted does it as a reward penalty rather than a
special case (see muvid.footage.select_score).
Registry idiom mirrors mixing.audio.segmentation (a strategy: str | callable param
a
_STRATEGIESdict +resolve_strategy()) — the federation’s established shape.
Register your own with register_selection_strategy().
Module Attributes
alignments + song duration → an EDL (built-ins ignore song_duration but it is passed so a strategy MAY reason about the full timeline). |
|
The default auto-strategy when none is chosen. |
Functions
|
For each covered span, show the highest-confidence clip (ties: longest coverage). |
|
Stay on the current clip as long as it covers; only switch when it runs out (then to the clip extending furthest). |
All strategy slugs (eager + lazy), sorted. |
|
|
Prefer the clip that keeps rolling longest — pick the one whose coverage extends furthest forward (ties: higher confidence). |
|
Register a strategy by a |
|
Register a selection strategy under |
|
Resolve a strategy name OR a bare callable to a |
|
Run |
- muvid.footage.strategy.DEFAULT_STRATEGY = 'best_confidence'¶
The default auto-strategy when none is chosen.
- muvid.footage.strategy.SelectionStrategy¶
alignments + song duration → an EDL (built-ins ignore song_duration but it is passed so a strategy MAY reason about the full timeline).
Score-driven opt-in (progressive disclosure). A strategy that needs the score tensor
beats declares a keyword-only
contextparameter (or**kwargs);select_edl()then passes aSelectionContext(defined inmuvid.footage.select_score) ascontext=. The built-ins take only(alignments, song_duration)and never see it — the exact same dispatch idiom asnw.jobs._call_dispatch. The magic parameter name is literallycontext.
- Type:
A strategy
alias of
Callable[[…],list[EdlEntry]]
- muvid.footage.strategy.best_confidence(alignments, song_duration)[source]¶
For each covered span, show the highest-confidence clip (ties: longest coverage).
- muvid.footage.strategy.fewest_cuts(alignments, song_duration)[source]¶
Stay on the current clip as long as it covers; only switch when it runs out (then to the clip extending furthest). Minimizes the number of cuts.
- muvid.footage.strategy.list_strategies()[source]¶
All strategy slugs (eager + lazy), sorted. Lazy slugs are NOT imported to list them.
- muvid.footage.strategy.longest_take(alignments, song_duration)[source]¶
Prefer the clip that keeps rolling longest — pick the one whose coverage extends furthest forward (ties: higher confidence). Yields long, continuous takes.
- muvid.footage.strategy.register_lazy_strategy(slug, target_ref)[source]¶
Register a strategy by a
"module:func"reference, imported only on first use.Lets a heavy strategy (numpy DP, cv2, …) be listed and named without importing its module at registration time — the import happens in
resolve_strategy().- Return type:
- muvid.footage.strategy.register_selection_strategy(slug, fn)[source]¶
Register a selection strategy under
slug(returns it, for inline use).
- muvid.footage.strategy.resolve_strategy(strategy)[source]¶
Resolve a strategy name OR a bare callable to a
SelectionStrategy.A lazy slug is imported here (and cached into the eager table) on first resolution.
- muvid.footage.strategy.select_edl(strategy, alignments, song_duration, *, context=None)[source]¶
Run
strategy(name or callable) to produce an EDL fromalignments.context(aSelectionContext) is passed to score-driven strategies that declare it; the alignment-only built-ins ignore it. SeeSelectionStrategy.