Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.
TypeScript agentic-aiaiai-agentsai-videocompilerdslffmpeggenerative-aillmmarkup-languagemonorepoplugin-systemprogramming-languagetext-to-videotypescriptvideovideo-automationvideo-clonevideo-editingvideo-generation
fix(docs): trim demo video heads and tails
rponee935b89bc54f
diff --git a/docs/.vitepress/theme/components/SemanticVideoDemo.vue b/docs/.vitepress/theme/components/SemanticVideoDemo.vueindex fdabc588..9ecbe42b 100644--- a/docs/.vitepress/theme/components/SemanticVideoDemo.vue+++ b/docs/.vitepress/theme/components/SemanticVideoDemo.vue@@ -8,6 +8,7 @@ import {} from "./demo-audio";import { goodBetterBestMedia, resolveDemoMedia } from "./demo-media";import { demoPointerIsInside } from "./demo-pointer";+import { DEMO_VIDEO_TRIM_SECONDS } from "./demo-video-trim";import {semanticVideoDemos,type DemoId,@@ -325,7 +326,7 @@ function syncState(time: number, force = false) {function syncBaseVideos(force = false) {const activeIndex = sceneIndexAt(programTime);const scene = config.scenes[activeIndex];- const localTime = Math.max(0, programTime - scene.start);+ const localTime = scene.sourceStart + Math.max(0, programTime - scene.start);const sceneChanged = playbackSceneIndex !== activeIndex;baseVideos.forEach((video, index) => {if (!video) return;@@ -350,8 +351,16 @@ function syncOverlayVideos(force = false) {video.pause();return;}- const localTime = Math.max(0, programTime - selection.start);+ const requestedTime = DEMO_VIDEO_TRIM_SECONDS + Math.max(0, programTime - selection.start);+ const sourceEnd = Number.isFinite(video.duration)+ ? Math.max(DEMO_VIDEO_TRIM_SECONDS, video.duration - DEMO_VIDEO_TRIM_SECONDS)+ : requestedTime;+ const localTime = Math.min(requestedTime, sourceEnd);if (force || playbackOverlayId !== selection.id || Math.abs(video.currentTime - localTime) > .2) video.currentTime = localTime;+ if (requestedTime >= sourceEnd) {+ video.pause();+ return;+ }if (props.active && video.paused) void video.play().catch(() => undefined);});playbackOverlayId = activeOverlaySelection.value?.id ?? null;@@ -466,7 +475,9 @@ function renderFrame(timestamp: number) {previousTimestamp = timestamp;const scene = config.scenes[currentSceneIndex.value];const video = baseVideos[currentSceneIndex.value];- let nextTime = video && !video.paused && video.readyState >= 2 ? scene.start + video.currentTime : programTime + delta;+ let nextTime = video && !video.paused && video.readyState >= 2+ ? scene.start + video.currentTime - scene.sourceStart+ : programTime + delta;let looped = false;if (pinnedLoopSelection.value) {const loopSelection = config.selections.find((selection) => selection.id === pinnedLoopSelection.value);diff --git a/docs/.vitepress/theme/components/SvmlPlayground.vue b/docs/.vitepress/theme/components/SvmlPlayground.vueindex 3a60ce75..01e0544a 100644--- a/docs/.vitepress/theme/components/SvmlPlayground.vue+++ b/docs/.vitepress/theme/components/SvmlPlayground.vue@@ -8,7 +8,8 @@ import {} from "./demo-audio";import { rankingMedia, resolveDemoMedia } from "./demo-media";import { demoPointerIsInside } from "./demo-pointer";-import { wordCues, type WordCue } from "./regen-ranking-cues";+import { createTrimmedDemoTimeline } from "./demo-video-trim";+import { wordCues as rawWordCues, type WordCue } from "./regen-ranking-cues";import {buildFoldedSourceView,buildFullSourceView,@@ -45,6 +46,7 @@ type BaseScene = {src: string;start: number;end: number;+ sourceStart: number;};type BrollItem = {@@ -66,23 +68,25 @@ type SourceLine = {type DisplayedSourceLine = SourceDisplayEntry<SourceLine>;-const TOTAL_DURATION = 36.1;const ENTER_DURATION = .45;const MOVE_DURATION = .55;+const rankingTimeline = createTrimmedDemoTimeline([+ { src: rankingMedia.avatars[0], start: 0, end: 12.033333333333333 },+ { src: rankingMedia.avatars[1], start: 12.033333333333333, end: 24.066666666666666 },+ { src: rankingMedia.avatars[2], start: 24.066666666666666, end: 36.1 },+]);+const TOTAL_DURATION = rankingTimeline.duration;+const baseScenes: BaseScene[] = rankingTimeline.scenes;+const wordCues = rawWordCues.map((cue) => rankingTimeline.mapRange(cue));+const selections: RankingSelection[] = [{ id: "photoshop", label: "Photoshop", rank: 5, start: .08, end: 6.4, color: "#31add0", icon: rankingMedia.icons[4] },{ id: "facetune", label: "Facetune", rank: 4, start: 6.4, end: 12, color: "rgb(132, 198, 84)", icon: rankingMedia.icons[3] },{ id: "remini", label: "Remini", rank: 3, start: 12.043333333333333, end: 18.184444444444445, color: "rgb(234, 220, 42)", icon: rankingMedia.icons[2] },{ id: "chatgpt", label: "ChatGPT", rank: 2, start: 18.184444444444445, end: 24.066666666666666, color: "rgb(255, 167, 45)", icon: rankingMedia.icons[1] },{ id: "regen", label: "ReGen", rank: 1, start: 24.076666666666668, end: 36.06666666666666, color: "#ff3f56", icon: rankingMedia.icons[0] },-];--const baseScenes: BaseScene[] = [- { src: rankingMedia.avatars[0], start: 0, end: 12.033333333333333 },- { src: rankingMedia.avatars[1], start: 12.033333333333333, end: 24.066666666666666 },- { src: rankingMedia.avatars[2], start: 24.066666666666666, end: 36.1 },-];+].map((selection) => rankingTimeline.mapRange(selection));const brollItems: BrollItem[] = [{ id: "handsome-1", src: rankingMedia.broll[4], start: 791 / 30, end: 831 / 30, zoom: 1.02 },@@ -90,7 +94,7 @@ const brollItems: BrollItem[] = [{ id: "dating-photo", src: rankingMedia.broll[2], start: 925 / 30, end: 952 / 30, zoom: 1.02 },{ id: "linkedin-headshot", src: rankingMedia.broll[1], start: 952 / 30, end: 977 / 30, zoom: 1.03 },{ id: "instagram-post", src: rankingMedia.broll[0], start: 977 / 30, end: 1009 / 30, zoom: 1.02 },-];+].map((selection) => rankingTimeline.mapRange(selection));const semanticSelections: TimelineSelection[] = [...selections, ...brollItems];@@ -560,7 +564,7 @@ function updateContinuousVisuals(time: number) {function syncBaseVideos(force = false) {const activeIndex = sceneIndexAt(programTime);const scene = baseScenes[activeIndex];- const localTime = Math.max(0, programTime - scene.start);+ const localTime = scene.sourceStart + Math.max(0, programTime - scene.start);const sceneChanged = playbackSceneIndex !== activeIndex;baseVideos.forEach((video, index) => {@@ -681,7 +685,7 @@ function renderFrame(timestamp: number) {const scene = baseScenes[currentSceneIndex.value];const video = baseVideos[currentSceneIndex.value];let nextTime = video && !video.paused && video.readyState >= 2- ? scene.start + video.currentTime+ ? scene.start + video.currentTime - scene.sourceStart: programTime + delta;let looped = false;if (pinnedLoopSelection.value) {diff --git a/docs/.vitepress/theme/components/demo-video-trim.ts b/docs/.vitepress/theme/components/demo-video-trim.tsnew file mode 100644index 00000000..b7a7ee44--- /dev/null+++ b/docs/.vitepress/theme/components/demo-video-trim.ts@@ -0,0 +1,42 @@+export const DEMO_VIDEO_TRIM_SECONDS = .3;++type TimelineRange = {+ start: number;+ end: number;+};++export function createTrimmedDemoTimeline<T extends TimelineRange>(+ sourceScenes: readonly T[],+ trim = DEMO_VIDEO_TRIM_SECONDS,+) {+ let cursor = 0;+ const scenes = sourceScenes.map((scene) => {+ const sourceDuration = scene.end - scene.start;+ const duration = Math.max(0, sourceDuration - trim * 2);+ const nextScene = {+ ...scene,+ start: cursor,+ end: cursor + duration,+ sourceStart: trim,+ };+ cursor = nextScene.end;+ return nextScene;+ });++ function mapTime(time: number) {+ const index = sourceScenes.findIndex((scene) => time < scene.end);+ const resolvedIndex = index === -1 ? sourceScenes.length - 1 : index;+ const sourceScene = sourceScenes[resolvedIndex];+ const scene = scenes[resolvedIndex];+ const sourceDuration = sourceScene.end - sourceScene.start;+ const sourceTime = Math.max(trim, Math.min(sourceDuration - trim, time - sourceScene.start));+ return scene.start + sourceTime - trim;+ }++ function mapRange<R extends TimelineRange>(range: R) {+ const start = mapTime(range.start);+ return { ...range, start, end: Math.max(start, mapTime(range.end)) };+ }++ return { duration: cursor, mapRange, mapTime, scenes };+}diff --git a/docs/.vitepress/theme/components/semantic-video-demos.ts b/docs/.vitepress/theme/components/semantic-video-demos.tsindex fb487786..c0a5a302 100644--- a/docs/.vitepress/theme/components/semantic-video-demos.ts+++ b/docs/.vitepress/theme/components/semantic-video-demos.ts@@ -1,6 +1,7 @@import streetTranscript from "../../../public/street-interview/transcript.json";import goodBetterBestTranscript from "../../../public/good-better-best/transcript.json";import { goodBetterBestMedia, streetMedia } from "./demo-media";+import { createTrimmedDemoTimeline } from "./demo-video-trim";export type DemoId = "street" | "good-better-best";@@ -23,6 +24,7 @@ export type DemoScene = {src: string;start: number;end: number;+ sourceStart: number;};export type DemoSourceLine = {@@ -141,17 +143,29 @@ const goodBetterBestLines: DemoSourceLine[] = [{ html: '<span class="syn-tag"></deck></span>' },];+const streetTimeline = createTrimmedDemoTimeline([+ { src: streetMedia.scenes[0], start: 0, end: 5 },+ { src: streetMedia.scenes[1], start: 5, end: 11 },+ { src: streetMedia.scenes[2], start: 11, end: 22 },+ { src: streetMedia.scenes[3], start: 22, end: 31.1333333333 },+]);++const goodBetterBestTimeline = createTrimmedDemoTimeline([+ { src: goodBetterBestMedia.speakers[0], start: 0, end: 4 },+ { src: goodBetterBestMedia.speakers[1], start: 4, end: 8 },+ { src: goodBetterBestMedia.speakers[2], start: 8, end: 14 },+ { src: goodBetterBestMedia.speakers[3], start: 14, end: 18.05 },+ { src: goodBetterBestMedia.speakers[4], start: 18.05, end: 23.05 },+ { src: goodBetterBestMedia.speakers[5], start: 23.05, end: 28.05 },+ { src: goodBetterBestMedia.speakers[6], start: 28.05, end: 42.0333333333 },+]);+export const semanticVideoDemos: Record<DemoId, SemanticVideoDemoConfig> = {street: {id: "street",- duration: 31.1333333333,- words: streetWords,- scenes: [- { src: streetMedia.scenes[0], start: 0, end: 5 },- { src: streetMedia.scenes[1], start: 5, end: 11 },- { src: streetMedia.scenes[2], start: 11, end: 22 },- { src: streetMedia.scenes[3], start: 22, end: 31.1333333333 },- ],+ duration: streetTimeline.duration,+ words: streetWords.map((cue) => streetTimeline.mapRange(cue)),+ scenes: streetTimeline.scenes,selections: [{ id: "hook", start: .04, end: 5.12, layer: "scene" },{ id: "rainbow", start: 5.12, end: 11.12, layer: "scene" },@@ -160,22 +174,14 @@ export const semanticVideoDemos: Record<DemoId, SemanticVideoDemoConfig> = {{ id: "seven-bags", start: 7.08, end: 11.12, layer: "overlay", asset: streetMedia.broll[0] },{ id: "receipt", start: 18.81, end: 22.2, layer: "overlay", asset: streetMedia.broll[1] },{ id: "college", start: 26.22, end: 31.06, layer: "overlay", asset: streetMedia.broll[2] },- ],+ ].map((selection) => streetTimeline.mapRange(selection)),lines: streetLines,},"good-better-best": {id: "good-better-best",- duration: 42.0333333333,- words: goodBetterBestWords,- scenes: [- { src: goodBetterBestMedia.speakers[0], start: 0, end: 4 },- { src: goodBetterBestMedia.speakers[1], start: 4, end: 8 },- { src: goodBetterBestMedia.speakers[2], start: 8, end: 14 },- { src: goodBetterBestMedia.speakers[3], start: 14, end: 18.05 },- { src: goodBetterBestMedia.speakers[4], start: 18.05, end: 23.05 },- { src: goodBetterBestMedia.speakers[5], start: 23.05, end: 28.05 },- { src: goodBetterBestMedia.speakers[6], start: 28.05, end: 42.0333333333 },- ],+ duration: goodBetterBestTimeline.duration,+ words: goodBetterBestWords.map((cue) => goodBetterBestTimeline.mapRange(cue)),+ scenes: goodBetterBestTimeline.scenes,selections: [{ id: "hook", start: .19, end: 4.01, layer: "scene" },{ id: "good", start: 4.01, end: 14.12, layer: "scene" },@@ -184,7 +190,7 @@ export const semanticVideoDemos: Record<DemoId, SemanticVideoDemoConfig> = {{ id: "votes", start: 30.24, end: 33.45, layer: "overlay", asset: goodBetterBestMedia.decks[0] },{ id: "attract", start: 33.49, end: 36, layer: "overlay", asset: goodBetterBestMedia.decks[1] },{ id: "features", start: 36, end: 39.28, layer: "overlay", asset: goodBetterBestMedia.decks[2] },- ],+ ].map((selection) => goodBetterBestTimeline.mapRange(selection)),lines: goodBetterBestLines,},};