@open-take/compositor 0.4.4 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +476 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2864 -22
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +35 -0
- package/src/launch-evaluate.ts +147 -0
- package/src/launch-render.ts +929 -0
- package/src/launch-starter.ts +57 -0
- package/src/launch-story.ts +258 -0
- package/src/launch-template.ts +125 -0
- package/src/launch-types.ts +127 -0
- package/src/launch-validate.ts +374 -0
- package/src/motion-evaluate.ts +145 -0
- package/src/motion-quality.ts +632 -0
- package/src/motion-recipes.ts +1021 -0
- package/src/motion-types.ts +163 -0
- package/src/motion-validate.ts +400 -0
- package/src/render-lock.ts +8 -0
- package/src/render.ts +2 -8
- package/src/scene/launch-project.ts +11 -0
- package/src/scene/launch-scene.tsx +426 -0
- package/src/scene/motion-layers.tsx +263 -0
- package/src/types.ts +17 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-take/compositor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Polish compositor (D3) — event log + captured frames -> polished mp4 + editable revideo composition.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"funding": "https://ko-fi.com/pascal18663",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@revideo/core": "0.11.0",
|
|
24
24
|
"@revideo/ui": "0.11.0",
|
|
25
25
|
"@revideo/vite-plugin": "0.11.0",
|
|
26
|
-
"@open-take/revideo-renderer": "0.
|
|
26
|
+
"@open-take/revideo-renderer": "0.5.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^22.10.1",
|
package/src/index.ts
CHANGED
|
@@ -16,7 +16,42 @@ export {
|
|
|
16
16
|
} from "./audit-cursor";
|
|
17
17
|
export { type Beat, directCamera, type Framing } from "./camera";
|
|
18
18
|
export { resolveFfmpeg, resolveFfprobe } from "./ffmpeg";
|
|
19
|
+
export {
|
|
20
|
+
evaluateUiMorph,
|
|
21
|
+
launchAudioAtS,
|
|
22
|
+
launchDurationS,
|
|
23
|
+
launchSceneDurationS,
|
|
24
|
+
launchSceneWindows,
|
|
25
|
+
uiMorphDurationS,
|
|
26
|
+
uiStateDurationS,
|
|
27
|
+
} from "./launch-evaluate";
|
|
28
|
+
export {
|
|
29
|
+
type RenderLaunchOpts,
|
|
30
|
+
type RenderLaunchResult,
|
|
31
|
+
renderLaunch,
|
|
32
|
+
validateLaunchAssets,
|
|
33
|
+
} from "./launch-render";
|
|
34
|
+
export { launchStarter } from "./launch-starter";
|
|
35
|
+
export { analyzeLaunchStory, validateLaunchStory } from "./launch-story";
|
|
36
|
+
export { launchTemplate } from "./launch-template";
|
|
37
|
+
export * from "./launch-types";
|
|
38
|
+
export { formatLaunchIssues, validateLaunchComposition } from "./launch-validate";
|
|
19
39
|
export * as math from "./math";
|
|
40
|
+
export { evaluateMotionScene, evaluateMotionTrack, motionGraphemes } from "./motion-evaluate";
|
|
41
|
+
export { analyzeMotionQuality } from "./motion-quality";
|
|
42
|
+
export {
|
|
43
|
+
type CompareMotionRecipe,
|
|
44
|
+
composeMotionStory,
|
|
45
|
+
type FocusMotionRecipe,
|
|
46
|
+
type MotionRecipe,
|
|
47
|
+
type MotionRecipeImage,
|
|
48
|
+
type MotionRecipeStyle,
|
|
49
|
+
type MotionStoryBrief,
|
|
50
|
+
type MotionStoryResult,
|
|
51
|
+
type StepsMotionRecipe,
|
|
52
|
+
} from "./motion-recipes";
|
|
53
|
+
export * from "./motion-types";
|
|
54
|
+
export { validateMotionScene } from "./motion-validate";
|
|
20
55
|
export { type PlanOpts, planComposition } from "./plan";
|
|
21
56
|
export * from "./presets";
|
|
22
57
|
export { type RenderTakeOpts, type RenderTakeResult, renderTake } from "./render";
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
LaunchComposition,
|
|
3
|
+
LaunchScene,
|
|
4
|
+
LaunchUiMorphScene,
|
|
5
|
+
LaunchUiState,
|
|
6
|
+
} from "./launch-types";
|
|
7
|
+
|
|
8
|
+
const clamp = (n: number, lo = 0, hi = 1) => Math.max(lo, Math.min(hi, n));
|
|
9
|
+
export const launchEase = (x: number): number => {
|
|
10
|
+
const p = clamp(x);
|
|
11
|
+
return 1 - (1 - p) ** 3;
|
|
12
|
+
};
|
|
13
|
+
export const launchSmooth = (x: number): number => {
|
|
14
|
+
const p = clamp(x);
|
|
15
|
+
return p * p * (3 - 2 * p);
|
|
16
|
+
};
|
|
17
|
+
export const mix = (a: number, b: number, t: number): number => a + (b - a) * t;
|
|
18
|
+
|
|
19
|
+
export type LaunchSceneWindow = { scene: LaunchScene; index: number; startS: number; endS: number };
|
|
20
|
+
export const uiStateDurationS = (state: LaunchUiState): number =>
|
|
21
|
+
Math.max(state.transitionS, state.typeDelayS + state.typeS) + state.holdS;
|
|
22
|
+
export const uiMorphDurationS = (scene: LaunchUiMorphScene): number =>
|
|
23
|
+
scene.states.reduce((sum, state) => sum + uiStateDurationS(state), 0);
|
|
24
|
+
export const launchSceneDurationS = (scene: LaunchScene): number =>
|
|
25
|
+
scene.type === "ui-morph" ? uiMorphDurationS(scene) : scene.durationS;
|
|
26
|
+
export function launchSceneWindows(comp: LaunchComposition): LaunchSceneWindow[] {
|
|
27
|
+
let cursor = 0;
|
|
28
|
+
return comp.scenes.map((scene, index) => {
|
|
29
|
+
const out = { scene, index, startS: cursor, endS: cursor + launchSceneDurationS(scene) };
|
|
30
|
+
cursor = out.endS;
|
|
31
|
+
return out;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export const launchDurationS = (comp: LaunchComposition): number =>
|
|
35
|
+
comp.scenes.reduce((sum, scene) => sum + launchSceneDurationS(scene), 0);
|
|
36
|
+
|
|
37
|
+
export function launchAudioAtS(
|
|
38
|
+
comp: LaunchComposition,
|
|
39
|
+
track: { atS?: number; afterSceneId?: string; offsetS?: number },
|
|
40
|
+
): number {
|
|
41
|
+
if (track.atS != null) return track.atS;
|
|
42
|
+
const win = launchSceneWindows(comp).find((x) => x.scene.id === track.afterSceneId);
|
|
43
|
+
return (win?.endS ?? 0) + (track.offsetS ?? 0);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type UiLayerState = {
|
|
47
|
+
from: LaunchUiState;
|
|
48
|
+
to: LaunchUiState;
|
|
49
|
+
progress: number;
|
|
50
|
+
panelWidth: number;
|
|
51
|
+
panelHeight: number;
|
|
52
|
+
chipWidth: number;
|
|
53
|
+
oldOpacity: number;
|
|
54
|
+
oldY: number;
|
|
55
|
+
newOpacity: number;
|
|
56
|
+
newY: number;
|
|
57
|
+
promptChars: number;
|
|
58
|
+
plusX: number;
|
|
59
|
+
sendX: number;
|
|
60
|
+
sendScale: number;
|
|
61
|
+
iconRotation: number;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export function evaluateUiMorph(scene: LaunchUiMorphScene, localS: number): UiLayerState {
|
|
65
|
+
const states = scene.states;
|
|
66
|
+
let index = 0;
|
|
67
|
+
let stateStart = 0;
|
|
68
|
+
for (let i = 0, cursor = 0; i < states.length; i++) {
|
|
69
|
+
const end = cursor + uiStateDurationS(states[i]!);
|
|
70
|
+
if (localS < end || i === states.length - 1) {
|
|
71
|
+
index = i;
|
|
72
|
+
stateStart = cursor;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
cursor = end;
|
|
76
|
+
}
|
|
77
|
+
const to = states[index]!;
|
|
78
|
+
const from = states[Math.max(0, index - 1)]!;
|
|
79
|
+
const transitionS = to.transitionS;
|
|
80
|
+
const p =
|
|
81
|
+
index === 0
|
|
82
|
+
? launchEase((localS - stateStart) / transitionS)
|
|
83
|
+
: launchSmooth((localS - stateStart) / transitionS);
|
|
84
|
+
const base = scene.panel ?? { width: 1100, compactHeight: 112, expandedHeight: 218, radius: 34 };
|
|
85
|
+
const fromW = from.panelWidth ?? base.width;
|
|
86
|
+
const toW = to.panelWidth ?? base.width;
|
|
87
|
+
const fromH = from.panelHeight ?? (index <= 1 ? base.compactHeight : base.expandedHeight);
|
|
88
|
+
const toH = to.panelHeight ?? (index === 0 ? base.compactHeight : base.expandedHeight);
|
|
89
|
+
const typeStart = stateStart + to.typeDelayS;
|
|
90
|
+
const typed = clamp((localS - typeStart) / Math.max(0.05, to.typeS));
|
|
91
|
+
const width = mix(index === 0 ? fromW * 0.82 : fromW, toW, p);
|
|
92
|
+
const height = mix(index === 0 ? fromH * 0.82 : fromH, toH, p);
|
|
93
|
+
const fromChip = 132 + from.label.length * 11;
|
|
94
|
+
const toChip = 132 + to.label.length * 11;
|
|
95
|
+
const emphasizeStart = stateStart + Math.max(to.transitionS, to.typeDelayS + to.typeS);
|
|
96
|
+
const emphasize =
|
|
97
|
+
index === states.length - 1
|
|
98
|
+
? Math.sin(
|
|
99
|
+
clamp((localS - emphasizeStart) / Math.min(0.55, Math.max(0.1, to.holdS))) * Math.PI,
|
|
100
|
+
)
|
|
101
|
+
: 0;
|
|
102
|
+
const sameChip = index > 0 && from.icon === to.icon && from.label === to.label;
|
|
103
|
+
return {
|
|
104
|
+
from,
|
|
105
|
+
to,
|
|
106
|
+
progress: p,
|
|
107
|
+
panelWidth: width,
|
|
108
|
+
panelHeight: height,
|
|
109
|
+
chipWidth: mix(fromChip, toChip, p),
|
|
110
|
+
oldOpacity: index === 0 || sameChip ? 0 : 1 - clamp(p / 0.42),
|
|
111
|
+
oldY: -32 * clamp(p / 0.5),
|
|
112
|
+
newOpacity: index === 0 ? p : sameChip ? 1 : clamp((p - 0.35) / 0.65),
|
|
113
|
+
newY: index === 0 || sameChip ? 0 : 32 * (1 - clamp((p - 0.25) / 0.75)),
|
|
114
|
+
promptChars: Math.round(to.prompt.length * typed),
|
|
115
|
+
plusX: -width / 2 - 64,
|
|
116
|
+
sendX: width / 2 - 58,
|
|
117
|
+
sendScale: 1 + 0.06 * emphasize,
|
|
118
|
+
iconRotation: to.icon === "style" ? 12 * (1 - p) : 0,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function transitionOpacity(scene: LaunchScene, localS: number): number {
|
|
123
|
+
if (scene.motion === "off") return 1;
|
|
124
|
+
const t = scene.transition;
|
|
125
|
+
if (!t || t.type === "cut") return 1;
|
|
126
|
+
const duration = launchSceneDurationS(scene);
|
|
127
|
+
const d = Math.min(t.durationS ?? 0.45, duration / 2);
|
|
128
|
+
return Math.min(launchEase(localS / d), launchEase((duration - localS) / d));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Frame-grid clock helpers.
|
|
133
|
+
*
|
|
134
|
+
* Revideo advances scene time by accumulating 1/fps in floating point, so the
|
|
135
|
+
* clock at frame n sits a hair below n/fps; a `step` keyframe authored exactly on
|
|
136
|
+
* a frame is then reached one frame late. Prepared media carries millisecond
|
|
137
|
+
* timestamps (17, 33, 50 ms …), so seeking an HTMLVideoElement to n/fps lands
|
|
138
|
+
* just before the frame it names and the browser shows the previous one: every
|
|
139
|
+
* third source frame was skipped and the one before it held. Snapping the clock
|
|
140
|
+
* to the grid and seeking to the centre of the intended frame removes both.
|
|
141
|
+
*/
|
|
142
|
+
export function quantizeToFrame(seconds: number, fps: number): number {
|
|
143
|
+
return Math.round(seconds * fps) / fps;
|
|
144
|
+
}
|
|
145
|
+
export function frameCentreS(seconds: number, fps: number): number {
|
|
146
|
+
return (Math.round(seconds * fps) + 0.5) / fps;
|
|
147
|
+
}
|