@open-take/compositor 0.5.0 → 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.js.map +1 -1
- package/package.json +2 -2
- package/src/launch-evaluate.ts +18 -0
- package/src/scene/launch-scene.tsx +14 -3
- package/src/scene/motion-layers.tsx +4 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-take/compositor",
|
|
3
|
-
"version": "0.5.
|
|
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.5.
|
|
26
|
+
"@open-take/revideo-renderer": "0.5.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^22.10.1",
|
package/src/launch-evaluate.ts
CHANGED
|
@@ -127,3 +127,21 @@ export function transitionOpacity(scene: LaunchScene, localS: number): number {
|
|
|
127
127
|
const d = Math.min(t.durationS ?? 0.45, duration / 2);
|
|
128
128
|
return Math.min(launchEase(localS / d), launchEase((duration - localS) / d));
|
|
129
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
|
+
}
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
launchEase,
|
|
6
6
|
launchSceneWindows,
|
|
7
7
|
transitionOpacity,
|
|
8
|
+
frameCentreS,
|
|
9
|
+
quantizeToFrame,
|
|
8
10
|
} from "../launch-evaluate";
|
|
9
11
|
import comp from "./.launch-composition.json";
|
|
10
12
|
import { createMotionLayers } from "./motion-layers";
|
|
@@ -164,8 +166,11 @@ export default makeScene2D("launch", function* (view) {
|
|
|
164
166
|
<Video
|
|
165
167
|
src={scene.asset}
|
|
166
168
|
time={() =>
|
|
167
|
-
(
|
|
168
|
-
|
|
169
|
+
frameCentreS(
|
|
170
|
+
(scene.trimStartS ?? 0) +
|
|
171
|
+
Math.max(0, Math.min(scene.durationS - 1 / comp.output.fps, local())),
|
|
172
|
+
comp.output.fps,
|
|
173
|
+
)
|
|
169
174
|
}
|
|
170
175
|
alpha={() => (active() ? 1 : 0)}
|
|
171
176
|
decoder="slow"
|
|
@@ -411,5 +416,11 @@ export default makeScene2D("launch", function* (view) {
|
|
|
411
416
|
}
|
|
412
417
|
view.add(root);
|
|
413
418
|
}
|
|
414
|
-
|
|
419
|
+
// Snap the accumulated clock to the output frame grid so keyframes authored on
|
|
420
|
+
// a frame are reached on that frame, not the next.
|
|
421
|
+
yield* tween(
|
|
422
|
+
windows.at(-1).endS,
|
|
423
|
+
(v) => t(quantizeToFrame(v * windows.at(-1).endS, comp.output.fps)),
|
|
424
|
+
linear,
|
|
425
|
+
);
|
|
415
426
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Circle, Img, Line, Node, Rect, Txt, Video } from "@revideo/2d";
|
|
2
|
+
import { frameCentreS } from "../launch-evaluate";
|
|
2
3
|
import { evaluateMotionScene } from "../motion-evaluate";
|
|
3
4
|
import type { EvaluatedMotionLayer, MotionLayer, MotionScene } from "../motion-types";
|
|
4
5
|
|
|
@@ -216,7 +217,9 @@ export function createMotionLayers({
|
|
|
216
217
|
time={() => {
|
|
217
218
|
const layer = get();
|
|
218
219
|
const lastSample = layer.trimStartS + Math.max(0, layer.durationS - 1 / output.fps);
|
|
219
|
-
|
|
220
|
+
// Prepared media runs at the output rate; seek to the centre of the
|
|
221
|
+
// intended frame so millisecond timestamps never select the previous one.
|
|
222
|
+
return frameCentreS(Math.min(layer.mediaTimeS, lastSample), output.fps);
|
|
220
223
|
}}
|
|
221
224
|
/>
|
|
222
225
|
) as FittedVideo;
|