Open source CapCut alternative.
TypeScript
feat(site): chat tools for soundtrack speed and video clip volume [rebuild]
David Leaa27bc5d6ac0
diff --git a/site/src/cut/lib/aiTools.ts b/site/src/cut/lib/aiTools.tsindex a9290895..12a4e2e2 100644--- a/site/src/cut/lib/aiTools.ts+++ b/site/src/cut/lib/aiTools.ts@@ -405,6 +405,15 @@ export async function runAiTool(return { muted: Boolean(input.muted) };}+ case "set_clip_volume": {+ const clip = requireItem(s.clips, input.clipId, "video clip");+ if (!isNum(input.volume)) throw new ToolError("volume is required (0..1.5).");+ const volume = clamp(input.volume, 0, 1.5);+ s.updateClip(clip.id, { volume: Math.abs(volume - 1) < 1e-4 ? undefined : volume });+ const next = useEditor.getState().clips.find((c) => c.id === clip.id)!;+ return { id: next.id, volume: next.volume ?? 1 };+ }+case "detach_audio": {const id = input.clipId ? String(input.clipId) : s.selection?.kind === "clip" ? s.selection.id : null;if (!id) throw new ToolError("Pass clipId or select a video clip first.");@@ -469,6 +478,9 @@ export async function runAiTool(if (isNum(input.start)) patch.start = Math.max(0, input.start);if (isNum(input.in)) patch.in = Math.max(0, input.in);if (isNum(input.out)) patch.out = input.out;+ if (isNum(input.speed))+ patch.speed =+ Math.abs(input.speed - 1) < 1e-4 ? undefined : Math.max(SPEED_FLOOR, input.speed);// duck >= 1 clears ducking (undefined); below 1 sets the gain.if (isNum(input.duck)) patch.duck = input.duck >= 1 ? undefined : clamp(input.duck, 0, 1);if (isNum(patch.in ?? NaN) || isNum(patch.out ?? NaN)) {diff --git a/site/src/cut/server/ai/catalog.ts b/site/src/cut/server/ai/catalog.tsindex f48a961a..4a173460 100644--- a/site/src/cut/server/ai/catalog.ts+++ b/site/src/cut/server/ai/catalog.ts@@ -131,6 +131,11 @@ export const AI_TOOLS: AiToolDef[] = [description: "Mute or unmute a video clip's own audio.",inputSchema: obj({ clipId: str("Video clip id"), muted: bool("true to mute") }, ["clipId", "muted"]),},+ {+ name: "set_clip_volume",+ description: "Set the gain on a video clip's own audio (soundtrack clips use update_audio).",+ inputSchema: obj({ clipId: str("Video clip id"), volume: num("0..1.5 (1 = unchanged)") }, ["clipId", "volume"]),+ },{name: "detach_audio",description:@@ -228,7 +233,7 @@ export const AI_TOOLS: AiToolDef[] = [{name: "update_audio",description:- "Update a soundtrack clip: volume (0..1.5), fadeIn/fadeOut seconds, start position, in/out trim, or duck. `duck` is voiceover ducking — while this clip plays, ALL other audio (video-clip sound and other music) drops to that gain (0..1); pass 1 to clear ducking. Use it to make a voiceover sit over quieter music.",+ "Update a soundtrack clip: volume (0..1.5), fadeIn/fadeOut seconds, start position, in/out trim, speed, or duck. `duck` is voiceover ducking — while this clip plays, ALL other audio (video-clip sound and other music) drops to that gain (0..1); pass 1 to clear ducking. Use it to make a voiceover sit over quieter music.",inputSchema: obj({id: str("Soundtrack clip id"),volume: num("0..1.5"),@@ -237,6 +242,7 @@ export const AI_TOOLS: AiToolDef[] = [start: num("Timeline start s"),in: num("Source in s"),out: num("Source out s"),+ speed: num("Playback rate (1 = normal, no upper limit)"),duck: num("Duck other audio to this gain while this clip plays, 0..1 (1 clears ducking)"),}, ["id"]),},