Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
Keep music video clips at the video's aspect, with a per-shot frame fit
Claude5006a8f29930
diff --git a/client/src/components/musicVideo/SceneCard.jsx b/client/src/components/musicVideo/SceneCard.jsxindex 5955a9be01..1403752d08 100644--- a/client/src/components/musicVideo/SceneCard.jsx+++ b/client/src/components/musicVideo/SceneCard.jsx@@ -31,6 +31,7 @@ import { COVERAGE_TOLERANCE_SEC, SCENE_ATTENTION_LABELS, sceneAttention } from 'import { ShotLockButton, useShotLock } from './ShotLock.jsx';import ScenePoster from './ScenePoster.jsx';import SceneRenderTarget, { renderTargetOverrides } from './SceneRenderTarget.jsx';+import SceneFrameFit, { sceneFrameFit } from './SceneFrameFit.jsx';/** One of a shot's two frames: tap to work on it, the corner button to see it full size. */function FrameTile({ label, imageId, empty, active, onPick, onOpen, openLabel }) {@@ -124,7 +125,7 @@ export default function SceneCard({settingsSaving, videoBlockedReason, videoBlockedReasonFor = null, canContinueShot,onMove, onDelete, onEditLocal, onSave,onGenerateFrame, onGenerateVideo, onContinueVideo, onGenerateEndFrame, generatingEndFrame = false, onContinueFromPrevious, previousHasClip = false,- onOpenPreview, onSelectTake, onReviewTake, onImportTake, onImportClipTake, onPlacePoolItem, onTrimClip, projectId = null, videoModels = [], defaultVideoModel = '', shotNumbers = undefined, takeBusy = false, layered = false, documentComposition = false,+ onOpenPreview, onSelectTake, onReviewTake, onImportTake, onImportClipTake, onPlacePoolItem, onTrimClip, projectId = null, aspect = '16:9', videoModels = [], defaultVideoModel = '', shotNumbers = undefined, takeBusy = false, layered = false, documentComposition = false,lipSyncBackend = '', songDurationSec = null, onSplit, onMergeNext, nextEndSec = null, falVideoSettings = null, onSeek, performanceReview = null, onRepairPerformance, repairBusy = false,expanded, onToggleExpand, footageOptional = false, failedScenes = null, songReview = null,}) {@@ -160,6 +161,7 @@ export default function SceneCard({// Which of the shot's two frames the Frames section works on.const [frameSide, setFrameSide] = useState('start');const clipSec = clipMeta && clipMeta.id === scene.videoHistoryId ? clipMeta.sec : null;+ const clipSize = clipMeta && clipMeta.id === scene.videoHistoryId && clipMeta.width > 0 ? { width: clipMeta.width, height: clipMeta.height } : null;// Pre-#8964 scenes have no `loop` key and keep the legacy loop-to-fill render.const loops = scene.loop !== false;const spanSec = scene.beatAligned && typeof scene.startSec === 'number' && typeof scene.endSec === 'number'@@ -433,14 +435,15 @@ export default function SceneCard({<videoref={clipPlayerRef}src={clipSrc}- className="block w-full aspect-video object-cover rounded border border-port-border bg-black"+ className={`block w-full aspect-video ${sceneFrameFit(scene) === 'fill' ? 'object-cover' : 'object-contain'} rounded border border-port-border bg-black`}mutedplaysInlinepreload="metadata"controlsonLoadedMetadata={(e) => {const sec = e.currentTarget.duration;- if (Number.isFinite(sec) && sec > 0) setClipMeta({ id: scene.videoHistoryId, sec });+ const { videoWidth: width, videoHeight: height } = e.currentTarget;+ if (Number.isFinite(sec) && sec > 0) setClipMeta({ id: scene.videoHistoryId, sec, width, height });}}/>{/* Corner expand — do not put the open handler on <video> itself;@@ -466,6 +469,11 @@ export default function SceneCard({disabled={takeBusy || !!generatingVideo || shotLock?.clip === 'locked'}onTrim={(startSec) => onTrimClip(scene, startSec)} />)}+ {/* A clip of another shape (a 3:2 local render) zooms to fill, or keeps its ratio with covered edges. */}+ {scene.videoHistoryId && (+ <SceneFrameFit id={fieldId('frame-fit')} scene={scene} clipSize={clipSize} aspect={aspect}+ onChange={(frameFit) => applyPatch({ frameFit })} />+ )}{!scene.videoHistoryId && layer === 'footage' && (<div className="flex aspect-video w-full items-center justify-center rounded border border-dashed border-port-border text-xs text-port-text-muted">No clip yet</div>)}diff --git a/client/src/components/musicVideo/SceneCard.test.jsx b/client/src/components/musicVideo/SceneCard.test.jsxindex f006dc2c8c..88c8e2a5d5 100644--- a/client/src/components/musicVideo/SceneCard.test.jsx+++ b/client/src/components/musicVideo/SceneCard.test.jsx@@ -368,3 +368,29 @@ describe('start and end frames', () => {expect(screen.getByTestId('end-frame-plan').textContent).toBe('The clip ends on the end frame.');});});++describe('frame fit for an off-shape clip', () => {+ // Uniquely catches the fit choice hiding on a 3:2 clip in a 16:9 video (or+ // cluttering a matching one), and the pick not reaching the saved shot.+ it('offers zoom to fill or keep ratio once the clip reads 3:2, and saves the pick', () => {+ const scene = { sceneId: 's1', prompt: 'Memory footage', referenceImageId: 'still.png', videoHistoryId: 'clip-1', startSec: 0, endSec: 4, takes: [] };+ const onSave = vi.fn();+ const onEditLocal = vi.fn();+ const { container } = render(<SceneCard scene={scene} index={0} expanded onEditLocal={onEditLocal} onSave={onSave} />);+ const video = container.querySelector('video');+ const load = (width, height) => {+ Object.defineProperty(video, 'duration', { value: 4, configurable: true });+ Object.defineProperty(video, 'videoWidth', { value: width, configurable: true });+ Object.defineProperty(video, 'videoHeight', { value: height, configurable: true });+ fireEvent.loadedMetadata(video);+ };+ load(1024, 576);+ expect(screen.queryByLabelText('Not 16:9')).toBeNull();+ load(768, 512);+ const pick = screen.getByLabelText('Not 16:9');+ expect(pick.value).toBe('fill');+ fireEvent.change(pick, { target: { value: 'vhs' } });+ expect(onSave).toHaveBeenCalledWith('s1', { frameFit: 'vhs' });+ expect(onEditLocal).toHaveBeenCalledWith('s1', { frameFit: 'vhs' });+ });+});diff --git a/client/src/components/musicVideo/SceneFrameFit.jsx b/client/src/components/musicVideo/SceneFrameFit.jsxnew file mode 100644index 0000000000..fcebfcd29a--- /dev/null+++ b/client/src/components/musicVideo/SceneFrameFit.jsx@@ -0,0 +1,32 @@+import { MUSIC_VIDEO_FRAME_FITS } from '../../lib/musicVideoLayers.js';+import { matchesMusicVideoAspect } from '../../lib/musicVideoAspect.js';++export const FRAME_FIT_LABELS = Object.freeze({+ fill: 'Zoom to fill',+ still: 'Keep ratio, still at the edges',+ vhs: 'Keep ratio, VHS edges',+ black: 'Keep ratio, black bars',+});++/** The shot's frame fit: an unset or unknown value zooms to fill. */+export const sceneFrameFit = (scene) => (MUSIC_VIDEO_FRAME_FITS.includes(scene?.frameFit) ? scene.frameFit : 'fill');++/**+ * How a clip whose shape is not the video's fills the frame, in the final+ * render and the preview. Shown only when the clip's size (read from the+ * player) differs from the video's aspect, or a fit was already picked.+ */+export default function SceneFrameFit({ id, scene, clipSize, aspect = '16:9', onChange, disabled = false }) {+ const fit = sceneFrameFit(scene);+ const offShape = clipSize && !matchesMusicVideoAspect(clipSize.width, clipSize.height, aspect);+ if (!offShape && fit === 'fill') return null;+ return (+ <span className="flex min-w-0 items-center gap-1">+ <label htmlFor={id} className="text-xs text-port-text-muted">{offShape ? `Not ${aspect}` : 'Frame'}</label>+ <select id={id} value={fit} disabled={disabled} onChange={(e) => onChange(e.target.value)}+ className="min-w-0 max-w-full bg-port-bg border border-port-border rounded px-1 py-1 text-xs min-h-[44px] sm:min-h-0 disabled:opacity-50">+ {MUSIC_VIDEO_FRAME_FITS.map((value) => <option key={value} value={value}>{FRAME_FIT_LABELS[value]}</option>)}+ </select>+ </span>+ );+}diff --git a/client/src/components/musicVideo/StoryboardAnimatic.jsx b/client/src/components/musicVideo/StoryboardAnimatic.jsxindex 04eabf80b3..3c1ccdf5f3 100644--- a/client/src/components/musicVideo/StoryboardAnimatic.jsx+++ b/client/src/components/musicVideo/StoryboardAnimatic.jsx@@ -11,6 +11,7 @@ import { selectedPerformanceInstruction } from '../../lib/musicVideoShotTiming.jimport { normalizeTitleCard } from '../../../../server/lib/musicVideoTitleCard.js';import ShotStepper from './ShotStepper.jsx';import FrameStepper, { captureMediaFrame } from './FrameStepper.jsx';+import { sceneFrameFit } from './SceneFrameFit.jsx';const timedShots = (scenes) => scenes.filter((scene) => Number.isFinite(scene?.startSec)).sort((a, b) => a.startSec - b.startSec);@@ -211,6 +212,8 @@ function ShotClip({ scene, audioRef, time, current }) {return () => { audio.removeEventListener('play', sync); audio.removeEventListener('pause', sync); };}, [audioRef, sync]);if (!src) return null;+ // The final render's frame fit: zoomed to fill, or whole over the still, the VHS edge or black bars.+ const fit = sceneFrameFit(scene);return (<videoref={videoRef}@@ -225,7 +228,7 @@ function ShotClip({ scene, audioRef, time, current }) {aria-label={`Clip for ${scene.label || 'this shot'}`}aria-hidden={current ? undefined : true}data-ready={ready ? 'true' : 'false'}- className={`pointer-events-none absolute inset-0 h-full w-full object-contain ${current && ready ? 'opacity-100' : 'opacity-0'}`}+ className={`pointer-events-none absolute inset-0 h-full w-full ${fit === 'fill' ? 'object-cover' : 'object-contain'} ${fit === 'black' ? 'bg-black' : ''} ${current && ready ? 'opacity-100' : 'opacity-0'}`}/>);}@@ -287,13 +290,16 @@ export default function StoryboardAnimatic({ project, audioUrl, seekRequest, col// With the lyrics drawn over the picture, a shot without a frame keeps its label and// intent under the picture instead, so no stand-in text sits under the sung words.const cardInFrame = !overlay;+ const vhsEdges = !!shot?.videoHistoryId && sceneFrameFit(shot) === 'vhs';return (<div className={`space-y-2 ${collapsed ? 'max-xl:hidden' : ''}`}><figure ref={figureRef} aria-label="Storyboard animatic" className="relative aspect-video w-full overflow-hidden rounded border border-port-border bg-black">{/* The project's film look, as the final render applies it over the whole picture, lyrics included. */}<FilmLookFrame look={lookOn ? project.filmLook : null} frame={Math.round(time * ANIMATIC_FPS)} playing={playing} className="h-full w-full">{shot?.referenceImageId ? (- <img src={`/data/images/${shot.referenceImageId}`} alt="" className="h-full w-full object-contain" />+ // Behind a VHS-edged clip the still stands in, blurred and faded, for the render's blur of the clip.+ <img src={`/data/images/${shot.referenceImageId}`} alt=""+ className={`h-full w-full ${vhsEdges ? 'object-cover blur-md saturate-50 brightness-75' : 'object-contain'}`} />) : cardInFrame && !shot?.videoHistoryId ? (<div className="flex h-full w-full flex-col items-center justify-center gap-1 p-4 text-center"><span className="text-sm font-medium text-port-text">{label}</span>diff --git a/client/src/components/musicVideo/stages/BoardStage.jsx b/client/src/components/musicVideo/stages/BoardStage.jsxindex 2dd0a5af87..594a584069 100644--- a/client/src/components/musicVideo/stages/BoardStage.jsx+++ b/client/src/components/musicVideo/stages/BoardStage.jsx@@ -8,6 +8,7 @@ import { ShotLockContext, SHOT_LOCK_LABELS, overallShotLock } from '../ShotLock.import { shotNumbers } from '../ShotStepper.jsx';import { previousShot } from '../../../../../server/lib/musicVideoHandoffFrame.js';import { isLayeredComposition } from '../../../lib/musicVideoLayers.js';+import { musicVideoAspect } from '../../../lib/musicVideoAspect.js';import { FOOTAGE_OPTIONAL_MODES } from '../../../lib/musicVideoStages.js';import { parseSceneFilter, sceneAttention, sceneMatchesFilter, sceneMediaKind, SCENE_ATTENTION_LABELS, SCENE_MEDIA_LABELS } from '../../../lib/musicVideoSceneAttention.js';import { formatTimecode } from '../../../utils/formatters.js';@@ -230,6 +231,7 @@ export default function BoardStage({ board }) {onPlacePoolItem={takes.placePoolItem}onTrimClip={takes.trimClipTake}projectId={project.id}+ aspect={musicVideoAspect(project)}shotNumbers={numbers}layered={layered}documentComposition={project.composition?.mode === 'document'}diff --git a/client/src/lib/README.md b/client/src/lib/README.mdindex 93d90a4634..1ffd03d5a9 100644--- a/client/src/lib/README.md+++ b/client/src/lib/README.md@@ -59,7 +59,7 @@ grep -i "what you want to do" client/src/lib/README.md| `backupExcludes.js` | CLIENT MIRROR of the backup-exclude block in `server/lib/sharedSchemas.js` (#7241) — `anchorUserExclude` / `anchorUserExcludes` / `isSafeExcludePattern` / `EXCLUDE_PATTERN_MAX_LENGTH`. The Backup settings tab anchors a newly added exclude and renders the effective list with these, so the chip the user sees is the rsync filter the server will actually run instead of an unanchored pattern that matches at any depth. || `beatColors.js` | `BEAT_KIND_COLORS` + `getBeatKindColor(kind)` — per-kind display colors for reader-map emotional beats (kinds defined server-side in `storyArc.js`). Keeps every beat visualization consistent. || `beatGrid.js` | Music-video beat-quantized timeline arranger (#1854). `buildBeatGridPoints(audioAnalysis)` merges beats/downbeats/section edges into one ranked snap-point list; `snapTimeToGrid(timeSec, gridPoints, toleranceSec)` finds the nearest point within tolerance; `computeSceneSpans(scenes, durationSec)` lays out scenes without a persisted `startSec`/`endSec` contiguously as a display-only fallback; `computeDragSpan({kind, startSpan, deltaSec, gridPoints, ...})` resolves a timeline drag gesture (`'move'` or `'right'` — no `'left'`, since the render can only trim from a clip's own frame 0) into a new span; `shouldMarkBeatAligned({kind, snapped, wasPersisted})` gates the `beatAligned` flag so a reposition-only drag can't silently promote an unpersisted scene's placeholder fallback duration into a "saved exactly" render duration; `autoArrangeScenes(scenes, audioAnalysis)` proposes a full `{ sceneId, startSec, endSec, beatAligned }[]` arrangement by distributing scenes across song sections weighted by each section's `energy` (#1915). Used by `components/musicVideo/BeatTimeline.jsx` and `pages/MusicVideo.jsx`. |-| `musicVideoAspect.js` | Re-export of `server/lib/musicVideoAspect.js`: `musicVideoAspect`, `musicVideoFrameGenSize`. Used by `hooks/useMusicVideoSceneMedia.js` so board frames match the project aspect. |+| `musicVideoAspect.js` | Re-export of `server/lib/musicVideoAspect.js`: `musicVideoAspect`, `musicVideoFrameGenSize`, `matchesMusicVideoAspect`. Used by `hooks/useMusicVideoSceneMedia.js` so board frames match the project aspect. || `musicVideoFiling.js` | Which music video an Image Gen / Video Gen render is for: `MUSIC_VIDEO_FILING_PARAM` (the `musicVideo` URL param), `musicVideoFilingFields(searchParams)` (the `musicVideoProjectId` request field), `musicVideoOf(item)` (a record's video). Used by `components/media/MusicVideoFilingSelect.jsx`, `hooks/useMediaPreviewActions.js` and the two generate pages. || `musicVideoMotion.js` | Re-export of `server/lib/musicVideoMotion.js` (`MOTION_CONTINUITY_CLAUSE`) for board motion prompts. || `musicVideoBatchPlan.js` | Pure helpers for the Music Video missing-frame / missing-clip batches (#10153): `videoBatchPreview` (count + fal estimate summed from `falSceneTake`, unpriced count), `scenesWaitingForFrame`, `videosButtonLabel`, `batchSummary`, `batchActive`, `batchSceneName`. Used by `components/musicVideo/ProjectActionGroups.jsx`. |diff --git a/client/src/lib/musicVideoAspect.js b/client/src/lib/musicVideoAspect.jsindex 0000456f70..3f83c39923 100644--- a/client/src/lib/musicVideoAspect.js+++ b/client/src/lib/musicVideoAspect.js@@ -1,2 +1,2 @@/** Music Video frame aspect — re-export of `server/lib/musicVideoAspect.js` so the board requests frames at the same size as the production run. */-export { MUSIC_VIDEO_ASPECTS, musicVideoAspect, musicVideoFrameGenSize } from '../../../server/lib/musicVideoAspect.js';+export { MUSIC_VIDEO_ASPECTS, matchesMusicVideoAspect, musicVideoAspect, musicVideoFrameGenSize } from '../../../server/lib/musicVideoAspect.js';diff --git a/client/src/lib/musicVideoLayers.js b/client/src/lib/musicVideoLayers.jsindex 5bd0b5d936..9f208dfd83 100644--- a/client/src/lib/musicVideoLayers.js+++ b/client/src/lib/musicVideoLayers.js@@ -6,6 +6,7 @@export {MUSIC_VIDEO_VISUAL_LAYERS,MUSIC_VIDEO_STILL_MOVES,+ MUSIC_VIDEO_FRAME_FITS,MUSIC_VIDEO_TEXT_ZONES,MUSIC_VIDEO_LYRIC_ROLES,isSelfDrawnLayer,diff --git a/server/lib/README.md b/server/lib/README.mdindex 4756a99dc3..d5e283546d 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -558,7 +558,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `claimFlowTaskTypes.js` | `hasClaimFlowContract(task)` shares trusted claim identity across registration, completion and resume. `CLAIM_FLOW_TASK_TYPES` — the ONE list of task kinds whose prompts own their own `claim/<item>` worktree and push/PR/MR/review lifecycle (#6613). `services/cosTaskGenerator.js` stamps `metadata.claimFlow` from it (WRITE side); `services/agentPromptBuilder.js` reads it back through `isClaimFlowTask()` to pick a run's claim posture (READ side). It lived as two byte-identical copies, so a new claim type added to one silently split the writer from the reader — no error, just a claim run treated as a plain commit-only handoff; `claimFlowTaskTypes.test.js` fails if a local copy reappears. Imports nothing. || `chiptuneRender.js` | Deterministic chiptune score → mono PCM → 16-bit WAV buffer (pure Node, no audio deps); `renderScoreToPcm` / `pcmToWavBuffer` / `renderScoreToWav`. || `chiptuneScore.js` | Chiptune score contract (#2911): `chiptuneScoreSchema` (Zod) + `sanitizeChiptuneScore`, `buildScoreEvents` — the pattern/order → absolute-time flatten mirrored by `client/src/lib/chiptunePlayback.js`. |-| `musicVideoLayers.js` | Music Video per-scene visual layers (#8985): `MUSIC_VIDEO_VISUAL_LAYERS` (`footage`/`still`/`card`/`code`), `MUSIC_VIDEO_STILL_MOVES` (`hold`/`push`/`pan`), `sceneVisualLayer(scene, { layered })` (only a composed render honors a still/card), `sceneHasAuthoredSpan`, and `sceneRenderReady(scene, { layered })`. Pure leaf shared by `services/musicVideo/render.js` and the client board (`client/src/lib/musicVideoLayers.js`). |+| `musicVideoLayers.js` | Music Video per-scene visual layers (#8985): `MUSIC_VIDEO_VISUAL_LAYERS` (`footage`/`still`/`card`/`code`), `MUSIC_VIDEO_STILL_MOVES` (`hold`/`push`/`pan`), `MUSIC_VIDEO_FRAME_FITS` (`fill`/`still`/`vhs`/`black`: how an off-shape clip fills the frame), `sceneVisualLayer(scene, { layered })` (only a composed render honors a still/card), `sceneHasAuthoredSpan`, and `sceneRenderReady(scene, { layered })`. Pure leaf shared by `services/musicVideo/render.js` and the client board (`client/src/lib/musicVideoLayers.js`). || `pitchMath.js` | Dependency-free scientific-pitch math shared by the LLM-authored music formats on both runtimes: `pitchToMidi("C4")` → 60 (null when unparseable) and `midiToFreq(69)` → 440. || `wavAudioFile.js` | `writeWavAudioFile(wav, dir, basename)` — land a synthesized WAV Buffer as `<basename>.ogg` via the system ffmpeg, falling back to `<basename>.wav` (and dropping a stale `.ogg`) when ffmpeg is missing or the encode fails; resolves to the filename used. Shared by the chiptune and drawn-waveform renderers and the code-engine take upload. `wavDurationMs(buffer)` reads a PCM WAV's duration from its RIFF header (0 for anything that is not a parseable WAV). `measureWavAudio(buffer)` decodes PCM 16/24/32-bit or float 32/64 (EXTENSIBLE included) into `{ channels, sampleRate, frames, durationMs, peak, rms, nonFinite }` so native renders are judged by their samples (null when undecodable). || `superColliderRuntime.js` | Managed SuperCollider runtime contract (#9412), pure: image/runtime/policy version constants, `buildSuperColliderRunArgs` (the one contained `docker run` for untrusted `sclang` source: no network/caps, read-only root, limits, ro input, private output), `buildSuperColliderBuildArgs`, the shipped synthetic probe, `evaluateSuperColliderStatus` (docker-missing … ready, with stale image/evidence invalidation), and the render contract (#9413): `SUPERCOLLIDER_RENDER` bounds, the trusted NRT `SUPERCOLLIDER_RENDER_WRAPPER_SOURCE`, `classifySuperColliderRenderLog` (syntax/source/pattern/score/synthesis failures) and `parseDockerContainerList` for orphan sweeps. I/O lives in `services/superColliderRuntime.js`. |@@ -847,7 +847,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `muscriptorModels.js` | `MUSCRIPTOR_MODELS` (`small`/`medium`/`large`) — MuScriptor size tiers shared by route schemas and `audioMidiTranscription.js`; pinned to the Python runner's argparse choices. || `loopInterval.js` | Loop interval grammar (`MIN_INTERVAL_MS`, `parseInterval`, `isValidLoopInterval`) shared by `services/loops.js` and `createLoopSchema` so the route rejects what the service would. |-| `musicVideoAspect.js` | `musicVideoAspect(project)` (treatment brief aspect, default 16:9), `MUSIC_VIDEO_FRAME_GEN_SIZES` and `musicVideoFrameGenSize(project)`: the size every Music Video reference frame is requested at, so a backend never picks portrait for a 16:9 video. `musicVideoAtAspect(project, aspect)` re-frames the project for one render (a vertical social cut) without touching the record. Shared by `productionDispatch.js`, `documentRender.js` and the client board. |+| `musicVideoAspect.js` | `musicVideoAspect(project)` (treatment brief aspect, default 16:9), `MUSIC_VIDEO_FRAME_GEN_SIZES` and `musicVideoFrameGenSize(project)`: the size every Music Video reference frame is requested at, so a backend never picks portrait for a 16:9 video. `musicVideoAtAspect(project, aspect)` re-frames the project for one render (a vertical social cut) without touching the record. `musicVideoLocalClipSize(project, model, { endFrame })` sizes a local clip to the aspect, `musicVideoRenderCanvas(aspect, lead)` the final render's frame, and `matchesMusicVideoAspect(w, h, aspect)` tests a frame's shape. Shared by `productionDispatch.js`, `documentRender.js` and the client board. || `musicVideoMotion.js` | `MOTION_CONTINUITY_CLAUSE`: the clause every Music Video motion (i2v) prompt ends with, pinning the reference frame's lighting, time of day and palette. Shared by `handoff.js` and the client board. `silentMotionPrompt(prompt, { styleParts })`: the same prompt as plain physical motion (no lyric/beat cues, song times or look words) for a take that hears no audio; applied at video submit. || `musicVideoConditioning.js` | `musicVideoStyleImages`, `musicVideoStylePrompt`, `musicVideoStyleBasis`, and `musicVideoStyleReferenceCapacity` supply bounded moodboard conditioning and text fallback; `musicVideoConditioningReferences(project, scene)` selects the approved character sheet, the scene's mapped set plate and the sheets of supporting cast the scene's prompt names (capped at 4), with capped project-wide fallback; shared by board and production. || `musicVideoMediumPlan.js` | `normalizeMusicVideoProductionPolicy`, `planMusicVideoMedia`, `summarizeMusicVideoMediumPlan`, and `codeFirstProductionAssets`: pinned shot media, union-of-intervals video allowance, and selected-asset preflight shared by planning and Board review. `musicVideoBriefTools`, `musicVideoBriefAllowsVideo` and `musicVideoToolPolicyConflict` read the brief's selected tools against the policy (the setup warning and the video-dispatch refusal). |diff --git a/server/lib/musicVideoAspect.js b/server/lib/musicVideoAspect.jsindex 20f4643e64..3500071206 100644--- a/server/lib/musicVideoAspect.js+++ b/server/lib/musicVideoAspect.js@@ -35,3 +35,69 @@ export function musicVideoAtAspect(project, aspect) {/** `{ width, height }` to request a project's reference frames at. */export const musicVideoFrameGenSize = (project) => ({ ...MUSIC_VIDEO_FRAME_GEN_SIZES[musicVideoAspect(project)] });++/** Width over height for each aspect. */+export const MUSIC_VIDEO_ASPECT_RATIOS = Object.freeze({ '16:9': 16 / 9, '9:16': 9 / 16, '1:1': 1 });++// A frame within this of the aspect counts as matching it: an H3 1344x768+// canvas (1.75) is its 16:9, and ffmpeg's fit loses under a percent of it.+const ASPECT_TOLERANCE = 0.02;++/** Whether `width` x `height` is the aspect's shape (within a couple of percent). */+export function matchesMusicVideoAspect(width, height, aspect) {+ const target = MUSIC_VIDEO_ASPECT_RATIOS[aspect];+ const w = Number(width);+ const h = Number(height);+ if (!target || !(w > 0) || !(h > 0)) return false;+ return Math.abs(w / h / target - 1) <= ASPECT_TOLERANCE;+}++// Local clip sizes on the shared 64px render grid, exactly the aspect. A model+// left to its own default renders 768x512 (3:2), which the conditioning crop+// and the final render then have to cut or pad to a 16:9 video.+const LOCAL_CLIP_SIZES = Object.freeze({+ '16:9': Object.freeze({ width: 1024, height: 576 }),+ '9:16': Object.freeze({ width: 576, height: 1024 }),+ '1:1': Object.freeze({ width: 768, height: 768 }),+});+// First+last frame renders spend their pixel budget per frame (renderArgs+// FFLF clamp), so an end-frame clip stays near the 768x512 area it was sized+// for: within 2% of the aspect, and the clip keeps its length.+const LOCAL_END_FRAME_CLIP_SIZES = Object.freeze({+ '16:9': Object.freeze({ width: 896, height: 512 }),+ '9:16': Object.freeze({ width: 512, height: 896 }),+ '1:1': Object.freeze({ width: 640, height: 640 }),+});++/**+ * `{ width, height }` for a local Music Video clip on `model`: the model's own+ * preset in the project's aspect when it has one (MiniMax H3's native canvas),+ * else its default when that already matches, else the aspect on the 64px grid.+ */+export function musicVideoLocalClipSize(project, model = null, { endFrame = false } = {}) {+ const aspect = musicVideoAspect(project);+ if (!endFrame) {+ const preset = (Array.isArray(model?.resolutionOptions) ? model.resolutionOptions : [])+ .find((option) => matchesMusicVideoAspect(option?.w, option?.h, aspect));+ if (preset) return { width: preset.w, height: preset.h };+ if (matchesMusicVideoAspect(model?.defaultWidth, model?.defaultHeight, aspect)) {+ return { width: model.defaultWidth, height: model.defaultHeight };+ }+ }+ return { ...(endFrame ? LOCAL_END_FRAME_CLIP_SIZES : LOCAL_CLIP_SIZES)[aspect] };+}++/**+ * The final render's frame: the lead clip's size when it is already the+ * project's aspect, else that aspect at the lead clip's height (its width for+ * a portrait video), on even pixels, so a 3:2 lead clip no longer makes the+ * whole video 3:2.+ */+export function musicVideoRenderCanvas(aspect, lead) {+ const ratio = MUSIC_VIDEO_ASPECT_RATIOS[aspect];+ if (!ratio || matchesMusicVideoAspect(lead.width, lead.height, aspect)) return { width: lead.width, height: lead.height };+ const even = (n) => Math.max(2, Math.round(n / 2) * 2);+ return ratio >= 1+ ? { width: even(lead.height * ratio), height: even(lead.height) }+ : { width: even(lead.width), height: even(lead.width / ratio) };+}diff --git a/server/lib/musicVideoDependencies.js b/server/lib/musicVideoDependencies.jsindex 6d05a0921d..742679b2ab 100644--- a/server/lib/musicVideoDependencies.js+++ b/server/lib/musicVideoDependencies.js@@ -17,6 +17,8 @@ const layerRef = (scene) => ({ role: 'layer', sceneId: scene.sceneId, assetId: s.map((key) => [key, scene[key] ?? null]).concat([['actionContract', scene.direction?.actionContract || null]])// #10589: only a planned camera joins the revision, so pre-camera evidence stays current..concat(scene.camera ? [['camera', scene.camera]] : [])+ // A chosen frame fit changes the render; a shot left to fill keeps its evidence.+ .concat(scene.frameFit && scene.frameFit !== 'fill' ? [['frameFit', scene.frameFit]] : [])// Only a music-driven performance joins it, so lip-sync evidence stays current..concat(scene.performanceStyle === 'music' ? [['performanceStyle', 'music']] : []))) });const snapshot = (references) => ({ version: MUSIC_VIDEO_DEPENDENCY_VERSION, references });diff --git a/server/lib/musicVideoLayers.js b/server/lib/musicVideoLayers.jsindex 40725094e3..62cd052b04 100644--- a/server/lib/musicVideoLayers.js+++ b/server/lib/musicVideoLayers.js@@ -21,6 +21,14 @@ export const MUSIC_VIDEO_VISUAL_LAYERS = ['footage', 'still', 'card', 'code'];export const isSelfDrawnLayer = (layer) => layer === 'card' || layer === 'code';export const MUSIC_VIDEO_STILL_MOVES = ['hold', 'push', 'pan'];+/**+ * How a footage clip whose shape is not the video's fills the frame:+ * `fill` zooms it to fill (the default, and every shot saved before the field+ * existed), the others keep it whole and cover the side gaps with the shot's+ * still, a VHS-style blur of the clip itself, or black bars.+ */+export const MUSIC_VIDEO_FRAME_FITS = ['fill', 'still', 'vhs', 'black'];+/*** Kinetic lyric type per shot (#10583), read by the shared lyricType.js document* module: `textZone` is where the shot's words may sit so they never cover thediff --git a/server/lib/musicVideoValidation.js b/server/lib/musicVideoValidation.jsindex cedf24f42b..da0e8b444b 100644--- a/server/lib/musicVideoValidation.js+++ b/server/lib/musicVideoValidation.js@@ -51,7 +51,7 @@ import { EFFORT_LEVELS } from './providerModels.js';import { shotActionContractProblem } from './musicVideoActionContract.js';import { NARRATIVE_EVENT_KINDS } from './musicVideoNarrativeEvents.js';import { MUSIC_VIDEO_MEDIA } from './musicVideoMediumPlan.js';-import { MUSIC_VIDEO_LYRIC_ROLES, MUSIC_VIDEO_STILL_MOVES, MUSIC_VIDEO_TEXT_ZONES, MUSIC_VIDEO_VISUAL_LAYERS } from './musicVideoLayers.js';+import { MUSIC_VIDEO_FRAME_FITS, MUSIC_VIDEO_LYRIC_ROLES, MUSIC_VIDEO_STILL_MOVES, MUSIC_VIDEO_TEXT_ZONES, MUSIC_VIDEO_VISUAL_LAYERS } from './musicVideoLayers.js';import { CAMERA_FRAMINGS, CAMERA_MOVEMENT_VALUES, CAMERA_SPEEDS } from './cameraMovements.js';import { MUSIC_VIDEO_PERFORMANCE_STYLES, MUSIC_VIDEO_SHOT_MODES, SOURCE_AUDIO_LIPSYNC } from './musicVideoShotTiming.js';import {@@ -581,6 +581,8 @@ const sceneLayerFields = {camera: musicVideoSceneCameraSchema.nullable().optional(),visualLayer: z.enum(MUSIC_VIDEO_VISUAL_LAYERS).optional(),stillMove: z.enum(MUSIC_VIDEO_STILL_MOVES).optional(),+ // How a clip of another shape fills the video's frame (musicVideoLayers.js).+ frameFit: z.enum(MUSIC_VIDEO_FRAME_FITS).optional(),cardText: z.string().max(500).nullable().optional(),// #10302: footage that the composition also draws code over; still counts as footage.codeOverlay: z.boolean().optional(),diff --git a/server/services/musicVideo/excerptRender.js b/server/services/musicVideo/excerptRender.jsindex 5c34198217..199ff43bc0 100644--- a/server/services/musicVideo/excerptRender.js+++ b/server/services/musicVideo/excerptRender.js@@ -278,14 +278,14 @@ export async function startExcerptRender(projectId, { startSec, endSec, aspect =status: 422, code: 'EXCERPT_ASPECT_UNSUPPORTED',});}- const { ffmpeg, audioPath, composed, clips, audioDurationSec, soundBed } = await planMusicVideoRender(project, { draft: true });+ const { ffmpeg, audioPath, composed, clips, audioDurationSec, soundBed, aspect: canvasAspect } = await planMusicVideoRender(project, { draft: true });await ensureDir(PATHS.videos);await ensureDir(PATHS.videoThumbnails);// A probe pass (no `excerpt` option) gets the full-song plan's canonical// dims/fps/sections/cues in ABSOLUTE song time — the coordinate space// `startSec`/`endSec` and `excerptBoundaryTimes` are given in.- const probe = buildMusicVideoFfmpegArgs(clips, audioPath, join(PATHS.videos, 'probe.mp4'), { audioDurationSec, frameGrid: composed });+ const probe = buildMusicVideoFfmpegArgs(clips, audioPath, join(PATHS.videos, 'probe.mp4'), { audioDurationSec, frameGrid: composed, aspect: canvasAspect });// A range ending on the song's analysed length may overrun the frame-rounded render by under a frame.if (!excerptRangeFits(startSec, endSec, probe.totalDuration, probe.fps)) {throw new ServerError(@@ -478,7 +478,7 @@ export async function startExcerptRender(projectId, { startSec, endSec, aspect =};if (!composition) {- const { args } = buildMusicVideoFfmpegArgs(clips, audioPath, outputPath, { audioDurationSec, frameGrid: composed, excerpt: { startSec, endSec: endClamped }, soundBed, grade: composed ? project.composition?.grade : null });+ const { args } = buildMusicVideoFfmpegArgs(clips, audioPath, outputPath, { audioDurationSec, frameGrid: composed, excerpt: { startSec, endSec: endClamped }, soundBed, grade: composed ? project.composition?.grade : null, aspect: canvasAspect });startEncode(args);return { jobId, excerptId };}@@ -497,7 +497,7 @@ export async function startExcerptRender(projectId, { startSec, endSec, aspect =}).then((overlays) => {signal.throwIfAborted();job.overlayAbort = null;- const layered = buildMusicVideoFfmpegArgs(clips, audioPath, outputPath, { audioDurationSec, overlays, frameGrid: true, excerpt: { startSec, endSec: endClamped }, soundBed, grade: composed ? project.composition?.grade : null });+ const layered = buildMusicVideoFfmpegArgs(clips, audioPath, outputPath, { audioDurationSec, overlays, frameGrid: true, excerpt: { startSec, endSec: endClamped }, soundBed, grade: composed ? project.composition?.grade : null, aspect: canvasAspect });startEncode(layered.args, 0.5);}).catch(async (err) => {const canceled = signal.aborted;diff --git a/server/services/musicVideo/frameFit.test.js b/server/services/musicVideo/frameFit.test.jsnew file mode 100644index 0000000000..f032353e6d--- /dev/null+++ b/server/services/musicVideo/frameFit.test.js@@ -0,0 +1,58 @@+import { afterAll, describe, expect, it } from 'vitest';+import { execFileSync } from 'node:child_process';+import { mkdtempSync, rmSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { findFfmpeg } from '../../lib/ffmpeg.js';+import { buildMusicVideoFfmpegArgs } from './render.js';++const ffmpeg = await findFfmpeg();+const dir = mkdtempSync(join(tmpdir(), 'portos-mv-frame-fit-'));+afterAll(() => rmSync(dir, { recursive: true, force: true }));+const run = (args) => execFileSync(ffmpeg, ['-v', 'error', ...args], { maxBuffer: 64 * 1024 * 1024 });+const FPS = 12;++// One RGB pixel of the output's first frame.+function pixel(path, width, x, y) {+ const raw = run(['-i', path, '-frames:v', '1', '-f', 'rawvideo', '-pix_fmt', 'rgb24', '-']);+ const at = (y * width + x) * 3;+ return [raw[at], raw[at + 1], raw[at + 2]];+}+const near = (rgb, target, tolerance = 40) => rgb.every((value, i) => Math.abs(value - target[i]) <= tolerance);++// Uniquely catches a 3:2 local clip setting a 3:2 video, and each frame fit's+// filter graph failing in ffmpeg or covering the side gaps with the wrong thing.+describe.skipIf(!ffmpeg)('a 3:2 clip in a 16:9 music video', () => {+ const clipPath = join(dir, 'clip.mp4');+ const stillPath = join(dir, 'still.png');+ const song = join(dir, 'song.wav');+ const render = (frameFit) => {+ const output = join(dir, `${frameFit}.mp4`);+ const clip = { sceneId: 's1', videoPath: clipPath, width: 96, height: 64, fps: FPS, duration: 1, sourceSec: 1,+ loop: false, inSec: 0, outSec: 1, frameFit, ...(frameFit === 'still' ? { stillPath } : {}) };+ const plan = buildMusicVideoFfmpegArgs([clip], song, output, { audioDurationSec: 1, frameGrid: true, aspect: '16:9' });+ run(plan.args.filter((arg, i) => !(arg === '-progress' || plan.args[i - 1] === '-progress')));+ return { output, plan };+ };++ it('renders 16:9 and fills, covers or bars the side gaps as picked', () => {+ run(['-f', 'lavfi', '-i', `color=0x00ff00:s=96x64:r=${FPS}:d=1`, '-pix_fmt', 'yuv420p', '-y', clipPath]);+ run(['-f', 'lavfi', '-i', 'color=0xff0000:s=160x90', '-frames:v', '1', '-y', stillPath]);+ run(['-f', 'lavfi', '-i', 'sine=frequency=440:duration=1', '-y', song]);+ const green = [0, 255, 0];+ const edges = {};+ for (const fit of ['fill', 'still', 'vhs', 'black']) {+ const { output, plan } = render(fit);+ expect([plan.canonW, plan.canonH]).toEqual([114, 64]);+ expect(near(pixel(output, 114, 57, 32), green)).toBe(true);+ edges[fit] = pixel(output, 114, 2, 32);+ }+ expect(near(edges.fill, green)).toBe(true);+ expect(near(edges.still, [255, 0, 0])).toBe(true);+ expect(near(edges.black, [0, 0, 0], 24)).toBe(true);+ // A dimmed, faded blur of the clip: green-tinted, never the clip itself or a bar.+ expect(near(edges.vhs, green)).toBe(false);+ expect(near(edges.vhs, [0, 0, 0], 24)).toBe(false);+ expect(edges.vhs[1]).toBeGreaterThan(edges.vhs[0]);+ });+});diff --git a/server/services/musicVideo/projectsLogic.js b/server/services/musicVideo/projectsLogic.jsindex f64978599a..a1bc709f7d 100644--- a/server/services/musicVideo/projectsLogic.js+++ b/server/services/musicVideo/projectsLogic.js@@ -514,6 +514,7 @@ function buildScene(input, { order }) {cardText: input.cardText ?? null,...(input.codeOverlay ? { codeOverlay: true } : {}),...(input.codeClip ? { codeClip: true } : {}),+ ...(input.frameFit ? { frameFit: input.frameFit } : {}),cardColor: input.cardColor ?? null,// #8977: cutaway (any image-to-video lane) unless the director asks for a// lip-synced performance shot, which only a source-audio provider renders.@@ -594,6 +595,7 @@ export function replaceScenes(project, sceneInputs) {videoHistoryId: prior.videoHistoryId ?? null,...(prior.endImageId ? { endImageId: prior.endImageId } : {}),...(prior.endFramePrompt ? { endFramePrompt: prior.endFramePrompt } : {}),+ ...(prior.frameFit ? { frameFit: prior.frameFit } : {}),takes: prior.takes || [],...(prior.direction ? { direction: prior.direction } : {}),};@@ -604,7 +606,7 @@ export function replaceScenes(project, sceneInputs) {// Scene fields a director edits within an approved shot (its span, wording and// selected takes) without adding a shot or lyric the storyboard approval did not cover.const SCENE_SHOT_EDIT_FIELDS = ['startSec', 'endSec', 'beatAligned', 'label', 'prompt', 'framePrompt', 'visualIntent',- 'referenceImageId', 'videoHistoryId', 'endImageId', 'codeClip'];+ 'referenceImageId', 'videoHistoryId', 'endImageId', 'codeClip', 'frameFit'];/*** Apply a patch to a single scene. Returns `{ project, updated }`. Throws if thediff --git a/server/services/musicVideo/render.js b/server/services/musicVideo/render.jsindex 25b3ca2cd2..30522955bd 100644--- a/server/services/musicVideo/render.js+++ b/server/services/musicVideo/render.js@@ -41,7 +41,8 @@ import { loadHistory, mutateVideoHistory } from '../videoGen/local.js';import { getTrack } from '../tracks/index.js';import { getProject, listProjects, updateProject, mutateProjectRecord } from './projects.js';import { applyProjectPatch } from './projectsLogic.js';-import { isSelfDrawnLayer, sceneHasAuthoredSpan, sceneVisualLayer } from '../../lib/musicVideoLayers.js';+import { MUSIC_VIDEO_FRAME_FITS, isSelfDrawnLayer, sceneHasAuthoredSpan, sceneVisualLayer } from '../../lib/musicVideoLayers.js';+import { musicVideoAspect, musicVideoRenderCanvas } from '../../lib/musicVideoAspect.js';import { projectTypographyPlan } from './composition.js';import { encodeCodeComposition, prepareCodeRender, writeCodeProofSheet } from './codeRender.js';import { documentRenderInitScripts, encodeDocumentComposition, prepareDocumentRender, sweepDocumentScratch } from './documentRender.js';@@ -283,6 +284,7 @@ export async function resolveSceneClips(project, { layered = false, stillForMissloop: edit ? false : sceneLoops(scene),inSec,outSec,+ ...footageFrameFit(scene),});}if (missing.length > 0) {@@ -381,6 +383,17 @@ export function beatSnapClips(clips, beats, { toleranceSec = 0.12, minClipSec =});}+// How a clip whose shape is not the video's fills the frame: zoomed+// to fill (the default), or kept whole with its side gaps covered by the shot's+// still, a VHS-style blur of the clip, or black. The still edge needs the+// still on disk; without it the gaps fall back to black.+function footageFrameFit(scene) {+ const fit = MUSIC_VIDEO_FRAME_FITS.includes(scene.frameFit) ? scene.frameFit : 'fill';+ if (fit !== 'still') return { frameFit: fit };+ const stillPath = scene.referenceImageId ? safeUnder(PATHS.images, scene.referenceImageId) : null;+ return stillPath && existsSync(stillPath) ? { frameFit: 'still', stillPath } : { frameFit: 'black' };+}+// The frame for a composed render with no footage to take dimensions from.const DEFAULT_CANVAS = Object.freeze({ width: 1280, height: 720, fps: 24 });// A still's push-in ends this much closer; a pan crosses this much extra width.@@ -420,9 +433,23 @@ function sectionChain(c, input, { canonW, canonH, fps, frames, frameGrid }) {const holdSec = c.loop === false ? (c.outSec - c.inSec) - (c.sourceSec ?? c.duration) : 0;const padSec = c.loop === false && frameGrid ? Math.max(0, holdSec) + 2 / fps : holdSec;const hold = padSec > 0 ? `tpad=stop_mode=clone:stop_duration=${round3(padSec)},` : '';- return `[${input}:v]scale=${canonW}:${canonH}:force_original_aspect_ratio=decrease,`- + `pad=${canonW}:${canonH}:(ow-iw)/2:(oh-ih)/2,setsar=1,fps=${fps},`- + `${hold}${trim},setpts=PTS-STARTPTS`;+ const timed = `fps=${fps},${hold}${trim},setpts=PTS-STARTPTS`;+ const cover = `scale=${canonW}:${canonH}:force_original_aspect_ratio=increase,crop=${canonW}:${canonH},setsar=1`;+ const fit = `scale=${canonW}:${canonH}:force_original_aspect_ratio=decrease,setsar=1`;+ const centered = `overlay=(W-w)/2:(H-h)/2:shortest=1`;+ const id = typeof input === 'number' ? input : input.clip;+ if (c.frameFit === 'fill') return `[${id}:v]${cover},${timed}`;+ // The shot's still, cover-fitted like a still section, fills the gaps beside the whole clip.+ if (c.frameFit === 'still' && typeof input === 'object') {+ return `[${input.still}:v]fps=${fps},${cover}[edge${id}];[${id}:v]${fit},${timed}[clip${id}];[edge${id}][clip${id}]${centered}`;+ }+ // The clip itself, zoomed, blurred, faded and noisy with scanlines, like a worn tape behind it.+ if (c.frameFit === 'vhs') {+ return `[${id}:v]${fit},${timed},split[clip${id}][tape${id}];`+ + `[tape${id}]${cover},boxblur=lr=min(h\\,w)/20:lp=2:cr=min(ch\\,cw)/20:cp=2,eq=saturation=0.55:brightness=-0.12,noise=alls=24:allf=t+u,`+ + `drawgrid=w=iw:h=3:t=1:[email protected][edge${id}];[edge${id}][clip${id}]${centered}`;+ }+ return `[${id}:v]${fit},pad=${canonW}:${canonH}:(ow-iw)/2:(oh-ih)/2,${timed}`;}// Pure: build the ffmpeg args for the master-bed render. Concats the clips@@ -448,14 +475,14 @@ function sectionChain(c, input, { canonW, canonH, fps, frames, frameGrid }) {// overlap the window, clipped to it and re-based to the excerpt's own timeline// (0 = `startSec`) so a contact sheet built from the excerpt file can sample// cut boundaries directly. `totalDuration` becomes the excerpt's own length.-export function buildMusicVideoFfmpegArgs(clips, audioPath, outputPath, { audioDurationSec = null, overlays = [], frameGrid: gridOption = false, excerpt = null, soundBed = null, grade = null } = {}) {+export function buildMusicVideoFfmpegArgs(clips, audioPath, outputPath, { audioDurationSec = null, overlays = [], frameGrid: gridOption = false, excerpt = null, soundBed = null, grade = null, aspect = null } = {}) {if (!Array.isArray(clips) || clips.length === 0) throw new Error('buildMusicVideoFfmpegArgs: empty clips');const frameGrid = gridOption || clips.some((c) => c.layer);// Stills and cards have no dimensions of their own: the first footage clip// sets the frame, or a default one when the render has no footage at all.+ // The project's aspect (when given) wins over a lead clip of another shape.const lead = clips.find((c) => !c.layer) || DEFAULT_CANVAS;- const canonW = lead.width;- const canonH = lead.height;+ const { width: canonW, height: canonH } = aspect ? musicVideoRenderCanvas(aspect, lead) : lead;const fps = lead.fps || 24;let cursorSec = 0;@@ -487,12 +514,17 @@ export function buildMusicVideoFfmpegArgs(clips, audioPath, outputPath, { audioDlet nextInput = 0;for (const { c } of plan) {if (c.layer === 'card') { inputOf.push(null); continue; }- inputOf.push(nextInput++);+ const clipInput = nextInput++;if (c.layer === 'still') inputs.push('-loop', '1', '-framerate', String(fps), '-i', c.imagePath);else {if (c.loop !== false) inputs.push('-stream_loop', '-1');inputs.push('-i', c.videoPath);}+ // A still edge reads the shot's still as one more looping input.+ if (!c.layer && c.frameFit === 'still' && c.stillPath) {+ inputOf.push({ clip: clipInput, still: nextInput++ });+ inputs.push('-loop', '1', '-framerate', String(fps), '-i', c.stillPath);+ } else inputOf.push(clipInput);}const audioIdx = nextInput; // master audio follows the section inputsinputs.push('-i', audioPath);@@ -651,7 +683,7 @@ export async function planMusicVideoRender(project, { draft = false } = {}) {}): snapped;const soundBed = await resolveSoundBedPath(project);- return { ffmpeg, audioPath, composed, clips, audioDurationSec, soundBed };+ return { ffmpeg, audioPath, composed, clips, audioDurationSec, soundBed, aspect: musicVideoAspect(project) };}// Code-rendered mode (#9076) and the composition-document mode seek a@@ -837,7 +869,7 @@ async function renderAdmittedMusicVideo(projectId, options, permit) {if (seeked) {return await renderSeekedMode(projectId, project, () => { handedOff = true; }, seeked, { ...options, maintenancePermit: permit });}- const { ffmpeg, audioPath, composed, clips, audioDurationSec, soundBed } = await planMusicVideoRender(project);+ const { ffmpeg, audioPath, composed, clips, audioDurationSec, soundBed, aspect } = await planMusicVideoRender(project);await ensureDir(PATHS.videos);await ensureDir(PATHS.videoThumbnails);@@ -846,7 +878,7 @@ async function renderAdmittedMusicVideo(projectId, options, permit) {const jobId = randomUUID();const filename = `music-video-${projectId.slice(0, 8)}-${Date.now()}.mp4`;const outputPath = join(PATHS.videos, filename);- const { args, totalDuration, canonW, canonH, fps, sections } = buildMusicVideoFfmpegArgs(clips, audioPath, outputPath, { audioDurationSec, frameGrid: composed, soundBed, grade: composed ? project.composition?.grade : null });+ const { args, totalDuration, canonW, canonH, fps, sections } = buildMusicVideoFfmpegArgs(clips, audioPath, outputPath, { audioDurationSec, frameGrid: composed, soundBed, grade: composed ? project.composition?.grade : null, aspect });// #8984: a composed project lays its timed text cues over the cut, and a// title card's text (#8985) joins them over its own section. No renderable// cue (plain mode, or nothing timed) skips the overlay capture entirely.diff --git a/server/services/musicVideo/render.terminal.test.js b/server/services/musicVideo/render.terminal.test.jsindex 3c1c515292..42ea183557 100644--- a/server/services/musicVideo/render.terminal.test.js+++ b/server/services/musicVideo/render.terminal.test.js@@ -513,7 +513,8 @@ describe('composed render lifecycle (#8984)', () => {it('lays the captured overlays over the cut and honors the chosen poster frame', async () => {primeComposed('composed-1', { mode: 'composed', textCues: [cue], posterSec: 1 });const { jobId } = await renderMusicVideo('composed-1');- expect(h.overlays.calls[0]).toMatchObject({ jobId, width: 768, height: 512, fps: 24, cues: [expect.objectContaining({ id: 'c1' })] });+ // The 768x512 fixture clips sit in a 16:9 video, at their height.+ expect(h.overlays.calls[0]).toMatchObject({ jobId, width: 910, height: 512, fps: 24, cues: [expect.objectContaining({ id: 'c1' })] });h.overlays.resolve([{ path: '/data/overlay-0.mov', startSec: 0.5, durationSec: 1 }]);await tick();const { args } = lastProc();@@ -564,7 +565,7 @@ describe('layered sections (#8985)', () => {primeLayered('layers-1', 'composed');const { jobId } = await renderMusicVideo('layers-1');// The card's title is captured for exactly its section: [2s clip][2s still][1.01s card → 24 frames].- expect(h.overlays.calls[0]).toMatchObject({ jobId, width: 768, height: 512,+ expect(h.overlays.calls[0]).toMatchObject({ jobId, width: 910, height: 512,cues: [{ id: 'card-s3', text: 'Verse two', startSec: 4, endSec: 5, placement: 'center', emphasis: 'hero' }] });h.overlays.resolve([{ path: '/data/overlay-0.mov', startSec: 4, durationSec: 1 }]);await tick();diff --git a/server/services/videoGen/prepareParams.js b/server/services/videoGen/prepareParams.jsindex 8a3b851599..18f51f1bf6 100644--- a/server/services/videoGen/prepareParams.js+++ b/server/services/videoGen/prepareParams.js@@ -51,6 +51,7 @@ import {} from '../../lib/icLoraWeights.js';import { getSettings } from '../settings.js';import { getProject as getMusicVideoProject } from '../musicVideo/projects.js';+import { musicVideoLocalClipSize } from '../../lib/musicVideoAspect.js';import { getTrack } from '../tracks/index.js';import { VIDEO_GEN_MODE, resolveVideoMode } from './modes.js';import { getFalVideoModel } from '../../lib/falVideoModels.js';@@ -327,6 +328,17 @@ export async function prepareVideoGenParams({ body, uploads, localOnlyParamKeys{ status: 400, code: 'VIDEO_GEN_UNKNOWN_MODEL' },);}+ // A local Music Video clip left unsized would render the model's 768x512+ // (3:2) default, cropping its 16:9 still and leaving side gaps in a 16:9+ // video; it renders at the project's aspect instead.+ if (backend === VIDEO_GEN_MODE.LOCAL && body.musicVideo?.projectId && body.width == null && body.height == null) {+ const project = await getMusicVideoProject(body.musicVideo.projectId)+ .catch(async (error) => { await cleanupMultipartTemp(uploads); throw error; });+ if (project) {+ const endFrame = body.mode === 'fflf' || !!body.lastImageFile || !!uploads.lastImage;+ Object.assign(body, musicVideoLocalClipSize(project, effectiveModel, { endFrame }));+ }+ }validateVideoBatch({ ...body, backend }, effectiveModel);if (effectiveModel && !isHardwareCompatible(effectiveModel.hardwareCompatibility)) {await cleanupMultipartTemp(uploads);diff --git a/server/services/videoGen/prepareParams.test.js b/server/services/videoGen/prepareParams.test.jsindex 69f6fd6b78..a6efebe552 100644--- a/server/services/videoGen/prepareParams.test.js+++ b/server/services/videoGen/prepareParams.test.js@@ -256,6 +256,25 @@ describe('prepareVideoGenParams', () => {expect(unlinkedDurablePaths()).toEqual([posix(prepared.audioFilePath)]);});+ // Uniquely catches a local Music Video clip falling back to the model's+ // 768x512 (3:2) default, which crops its still and leaves side gaps in the+ // 16:9 video, and an end-frame clip losing length to the FFLF pixel budget.+ it('sizes an unsized local Music Video clip to the project aspect', async () => {+ getMusicVideoProject.mockResolvedValue({ treatment: { brief: { aspectRatio: '16:9' } }, scenes: [] });+ const musicVideo = { projectId: 'project-example', sceneId: 'scene-example' };+ const body = { prompt: 'a clip', backend: 'local', mode: 'image', sourceImageFile: 'still.png', musicVideo };+ await prepareVideoGenParams({ body, uploads: {}, localOnlyParamKeys: LOCAL_ONLY_KEYS });+ expect([body.width, body.height]).toEqual([1024, 576]);++ const endFrame = { ...body, width: undefined, height: undefined, mode: 'fflf', lastImageFile: 'end.png' };+ await prepareVideoGenParams({ body: endFrame, uploads: {}, localOnlyParamKeys: LOCAL_ONLY_KEYS });+ expect([endFrame.width, endFrame.height]).toEqual([896, 512]);++ const picked = { ...body, width: 768, height: 512 };+ await prepareVideoGenParams({ body: picked, uploads: {}, localOnlyParamKeys: LOCAL_ONLY_KEYS });+ expect([picked.width, picked.height]).toEqual([768, 512]);+ });+it('short-circuits for grok without staging local-only inputs', async () => {const prepared = await prepare({ backend: 'grok', sourceImageFile: 'still.png' });expect(prepared.backend).toBe('grok');