Open source CapCut alternative.
TypeScript
feat(site): tell the video model which frame a clip is for
David Le90319a76638c
diff --git a/site/src/cut/lib/generate.ts b/site/src/cut/lib/generate.tsindex 9945f3a7..d7419d5f 100644--- a/site/src/cut/lib/generate.ts+++ b/site/src/cut/lib/generate.ts@@ -23,7 +23,7 @@ import { useGenNotify } from "./genNotify";import { IMAGE_ASPECTS, useImageGen } from "./imageGen";import { useEditor } from "./store";import { mediaSlug, nearestAspect, type MediaAsset, type RenderRecord } from "./types";-import { defaultVideoAspects, videoModel } from "./videoModels";+import { aspectFramingNote, defaultVideoAspects, videoModel } from "./videoModels";import { walkLadder, type VideoAttempt } from "./videoLadder";// AI generation jobs, held outside the panels so a tab switch (which unmounts@@ -729,9 +729,14 @@ export const useGenerate = create<GenerateState>((set, get) => {? { prompt, images: [] as InlineImage[] }: await promptAndImages("video", prompt, opts?.refs ?? [], opts?.composeRefs !== false, 1);const images = await Promise.all(rawImages.map(videoSafeInline));+ const projectAspect = useEditor.getState().aspect;+ const aspectRatio = opts?.aspect ?? nearestAspect(projectAspect, defaultVideoAspects());+ // A project on a shape the model can't render gets its clip cropped, so+ // the prompt carries the frame the take is really for.+ const framing = aspectFramingNote(projectAspect, aspectRatio);const res = await hostedPost("/api/inference/assets", {kind: "video",- prompt: sent,+ prompt: framing ? `${sent}\n\n${framing}` : sent,provider: "gemini-omni",...(anchors.length > 0? { inputs: { referenceImages: anchors } }@@ -739,8 +744,7 @@ export const useGenerate = create<GenerateState>((set, get) => {? { inputs: { images } }: {}),parameters: {- aspectRatio:- opts?.aspect ?? nearestAspect(useEditor.getState().aspect, defaultVideoAspects()),+ aspectRatio,...(opts?.negativePrompt ? { negativePrompt: opts.negativePrompt } : {}),},});diff --git a/site/src/cut/lib/videoModels.ts b/site/src/cut/lib/videoModels.tsindex 9599bbb3..a7e42e2c 100644--- a/site/src/cut/lib/videoModels.ts+++ b/site/src/cut/lib/videoModels.ts@@ -52,3 +52,22 @@ export function videoModel(tier: VideoTier): VideoModelOption {export function defaultVideoAspects(): VideoAspect[] {return VIDEO_MODELS[0].aspects;}++/**+ * Composition guidance for a project the renderer can't shoot natively. The+ * models render 16:9 or 9:16 only, so a project on any other ratio gets a clip+ * of a different shape than its frame. A clip letterboxes by default (`fit`+ * defaults to "fit"), and filling the frame instead — the Inspector's Fill, the+ * usual next move — crops whatever sits outside a centered slice. Naming the+ * target shape keeps the subject inside the part that survives either way.+ * Empty when the project already is a shape the model renders, so those prompts+ * stay exactly as written.+ */+export function aspectFramingNote(projectAspect: string, renderAspect: VideoAspect): string {+ if ((defaultVideoAspects() as string[]).includes(projectAspect)) return "";+ return (+ `Compose for a ${projectAspect} frame. This renders ${renderAspect}, a different shape, and sits ` ++ `in a ${projectAspect} project where it may be cropped to fill the frame — so keep the subject ` ++ `and any important action within a centered ${projectAspect} area, clear of the edges.`+ );+}