Repository navigation
feat(editor): stage-based output + per-element viewport transform - #21
Merged
Merged
Conversation
The render pipeline used to compute Output dims as bbox(maxW, maxH)
across all clips. With multi-aspect mixes (Widescreen + Portrait) that
produced a square output with letterboxing on both axes — and the user
had no control over which slice ended up in the frame.
Replace it with an explicit Stage:
* Output dims now come from `exportSpec.resolution`. The Export panel's
ASPECT + RESOLUTION pickers (long-side mode) drive the Stage shape,
with the first-clip auto-init seeding the spec the first time a clip
reports its dims.
* Each clip carries an optional `viewportTransform { scale, x, y }`
applied on top of a cover-fit default. Drag / wheel / dbl-click in
the live preview mutate it via the new `StageInteractionOverlay`,
Alt-modifier giving 5x precision. Per-element so two portraits in a
widescreen Stage can each frame their own subject.
* Preview and export now share `applyViewportTransform` from
`editor/render/element-transform.ts` — the duplicated `computeFitRect`
copies in `build-descriptor.ts` and `local/render/compositor.ts` are
gone, with a convergence test pinning the two paths together.
* Export panel re-laid out: presets (Web/Archive/Mobile/Custom) at the
top as opinionated recipes, then Aspect, Resolution, Quality. WEB =
16:9 1080p, MOBILE = 9:16 1080p, ARCHIVE keeps the user's aspect at
H.265/Pristine. Custom is the default — derived from the first clip.
* Persistence: `viewportTransform` per clip + the full `exportSpec`
round-trip through `useAutoPersist` so reload restores the Stage
shape and per-clip framing.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…nated recipes Type-check failures from CI: - `capLongSide` was unused after applyPreset's rewrite (presets now use deriveResolution directly). - The applyPreset test suite still asserted the old "preserve user's aspect" behaviour. Rewrite it to match the new contract — WEB always 16:9 1080p, MOBILE always 9:16 1080p, ARCHIVE keeps user's aspect at H.265/Pristine. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The component test still asserted preset='web' default and Mobile preserving source aspect — both no longer hold: - DEFAULT_EXPORT.preset is now 'custom' (Stage shape derives from the first clip's dims via the store's auto-init). - MOBILE is opinionated: 9:16 1080×1920 regardless of source. - WEB is opinionated: 16:9 1920×1080 regardless of source. - ARCHIVE keeps current aspect/dims (with 16:9 4K fallback). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
viewportTransform { scale, x, y }on top of a cover-fit default. The newStageInteractionOverlaylets the user drag/wheel/dbl-click in the live preview to pan/zoom the active element. Alt = 5× precision.applyViewportTransformfromeditor/render/element-transform.ts— the duplicatecomputeFitRectinlocal/render/compositor.tsis gone, plus a convergence test pins the two paths together so they can never drift again.viewportTransformand the fullexportSpecround-trip throughuseAutoPersistso reload restores everything.Why
The old bbox heuristic produced unusable squares when a project mixed widescreen + portrait clips. There was no way to pick the output shape, no way to frame each element inside the Stage, and the IOReadout's "Source vs Output" no longer matched the multi-clip reality.
Notes for review
element-transform.tsis the single source of truth for "where does an element land on the Stage." Botheditor/render/build-descriptor.ts(preview) andlocal/render/compositor.ts(export) callbuildElementFitRect.editor/render/preview-export-convergence.test.tsrebuilds a frame through both paths and asserts identical fitRects.FrameLayer.fitRectunchanged — no backend code changes were needed; the rect can now extend past the canvas bounds and the implicit canvas clip handles the rest.applyPresetwas rewritten to set aspect + dims + codec + bitrate together (presets are opinionated recipes). Custom is the default and means "derived from the first clip."DEFAULT_EXPORT.presetflipped from"web"to"custom"so first-time users see derived dims, not a forced 16:9.git merge-treeconfirms a clean merge — no conflicts.Test plan
ffprobe)🤖 Generated with Claude Code