Open source CapCut alternative.
TypeScript
feat(site): track a replica's card over its whole stay, still or not [rebuild]
David Le69a572033a97
diff --git a/site/src/cut/server/ai/catalog.ts b/site/src/cut/server/ai/catalog.tsindex 113ed576..140306c2 100644--- a/site/src/cut/server/ai/catalog.ts+++ b/site/src/cut/server/ai/catalog.ts@@ -363,7 +363,7 @@ Someone points at a video — a file they imported, a link you brought in, a cli**Rebuild the text as elements.** One title per card, a stretch of cards per add_title call — the words exactly as they read, size in px at 1080 wide, and x/y where suggest_font sets it on that card — a title is set from the middle of its line, so the centre of its ink box (track_element, match ink, the text's colour) sits off it by the face's own offset. A run of lines timed one after another is add_text_sequence in one call. Match the case the reference uses, and its colour from sample_color. The face comes off the frame: suggest_font with the card's moment, a region close around its words and the words themselves ranks every face Donkey has and hands back the font, weight, size, tracking and x/y to set. Call it on each card: cards in one face share its weight, size and tracking, but each sits its own way in its space, so its x/y comes from its own read, never from a neighbour's place. A title that cycles through typefaces is one call per face it shows. A no_match verdict means the reference uses a face Donkey does not bundle: say so, and set the closest one it named. Without a suggestion, size comes off the ink: capitals stand about 0.7 of the size tall, so size is the ink height in px at 1080 wide ÷ 0.7 (h × 1920 ÷ 0.7 on 9:16). A cycle whose faces change on the music's beats times itself with set_overlay_animation font_cycle_beats on the soundtrack clip after detect_beats; one whose changes follow the reference's own rhythm takes font_cycle_switches, the timeline seconds detect_cuts reads each change at.-**Then the motion.** set_overlay_keyframes gives each card its own pose track — where it sits, at what scale, at what second. track_element over a move hands you the keys: each move's from/to, start/end and ease, with scale as w over the resting w. set_overlay_animation composes on top for the entrance, the exit, a loop, and what a line does while it holds; 0.3-0.6s reads as an entrance, and a per-letter style is what makes a card read as typed. A line whose letters land one at a time is a per-letter entrance read off detect_cuts' \`changes\`, and it is read in one call, never by eye from sheets: track_element with match letters, the line's \`text\`, a seed close around the landed line, \`from\` before the first letter shows and \`to\` just after the last one lands. Its \`entrance\` is the set_overlay_animation call — in_style, in_seconds, in_stagger, in_sequence, in_sequence_at, in_distance, in_ease, in_fade, in_blur — and \`starts\`, the source second the title's ramp begins; pass them as they come. Digits spinning into place like a slot machine and letters popping in where they stand are read by the same call: it hands back a slot entrance with the reel's turn, spacing, band and landing bounce (a fast spin seems to turn the wrong way between frames, so take the turn from the call, never from a sheet), or a typewriter. A zoom through a letter until its ink fills the frame is a dive exit: run track_camera over the zoom first, and when it hands back an \`anchor\` — the reference growing the letter where it stands rather than flying it to the centre — set out_anchor to it, end the dive where the reference's frame fills and match its pace with out_ease against compare_to_source. Its \`crosses\` says whether the letters pass in front of or behind other ink on their way in — a smaller line above them — and so which of the two takes the lower row. motion_blur on the element (update_overlay) is for letters that streak along their fall; one that comes in soft is in_blur. add_shape, a stretch per call, is the rest of the graphics: bars, cards, rules, a block of color behind a line.+**Then the motion.** set_overlay_keyframes gives each card its own pose track — where it sits, at what scale, at what second. track_element over a move hands you the keys: each move's from/to, start/end and ease, with scale as w over the resting w. Run it over a card's whole stay, \`from\` its first frame \`to\` its last, even when the card looks still: one frame reads where it sits and how big, never the slow drift or grow it makes while it holds, which the call hands back as a move like any other. set_overlay_animation composes on top for the entrance, the exit, a loop, and what a line does while it holds; 0.3-0.6s reads as an entrance, and a per-letter style is what makes a card read as typed. A line whose letters land one at a time is a per-letter entrance read off detect_cuts' \`changes\`, and it is read in one call, never by eye from sheets: track_element with match letters, the line's \`text\`, a seed close around the landed line, \`from\` before the first letter shows and \`to\` just after the last one lands. Its \`entrance\` is the set_overlay_animation call — in_style, in_seconds, in_stagger, in_sequence, in_sequence_at, in_distance, in_ease, in_fade, in_blur — and \`starts\`, the source second the title's ramp begins; pass them as they come. Digits spinning into place like a slot machine and letters popping in where they stand are read by the same call: it hands back a slot entrance with the reel's turn, spacing, band and landing bounce (a fast spin seems to turn the wrong way between frames, so take the turn from the call, never from a sheet), or a typewriter. A zoom through a letter until its ink fills the frame is a dive exit: run track_camera over the zoom first, and when it hands back an \`anchor\` — the reference growing the letter where it stands rather than flying it to the centre — set out_anchor to it, end the dive where the reference's frame fills and match its pace with out_ease against compare_to_source. Its \`crosses\` says whether the letters pass in front of or behind other ink on their way in — a smaller line above them — and so which of the two takes the lower row. motion_blur on the element (update_overlay) is for letters that streak along their fall; one that comes in soft is in_blur. add_shape, a stretch per call, is the rest of the graphics: bars, cards, rules, a block of color behind a line.**Look at what you made.** A build that reads right from your own notes is still a guess until you measure it. compare_to_source does: mode sweep scores every frame of the cut against the source — 0 is the same picture, under ${SWEEP_TARGET} reads as one — and names the worst stretches with a grid of where each differs; mode moments shows those peaks beside the source's frames. Sweep as you build, since an error in the first card is in every card after it: look at the worst stretches, fix what differs, sweep again, and stop when the median is under ${SWEEP_TARGET} and no stretch stands out. A \`shift\` means the right thing lands early or late by that much. Read each picture for colour, the words and their face, where a thing sits, its size, and how far along a move is; a title the same colour as the block behind it reads as correct in the document and shows up here, and a sweep's \`titles\` names each title whose letters are another colour than the source's. A block keeps its footage's difference, so judge a shot by the cells over what you built. That is the only difference no edit removes: a glow, a tint on type, a soft edge or a flash is built like everything else (a glow is a bright shadow at shadow_y 0 on the title or shape, keyed in by the opacity of a copy that wears it), so a stretch over what you built stands out until you build it.