Skip to content

Create polished demo videos without editing skills. Mac/Windows/Linux

Add subtitle export IPC and keep click effects visible when cursor is hidden

webadderallc8e8d90b602b
diff --cc src/components/video-editor/videoPlayback/cursorRenderer.ts
index f9207d60,644cf899..2055c607
--- a/src/components/video-editor/videoPlayback/cursorRenderer.ts
+++ b/src/components/video-editor/videoPlayback/cursorRenderer.ts
@@@ -1122,6 -898,6 +1122,7 @@@ export class PixiCursorOverlay
private config: CursorRenderConfig;
private lastRenderedPoint: { px: number; py: number } | null = null;
private lastRenderedTimeMs: number | null = null;
++ private cursorVisible = false;
private swayRotation = 0;
private swaySpring = createSpringState(0);
@@@ -1292,7 -1044,7 +1293,7 @@@
cy: number;
trail: Array<{ cx: number; cy: number }>;
} | null {
-- if (!this.container.visible) {
++ if (!this.container.visible || !this.cursorVisible) {
return null;
}
@@@ -1310,70 -1062,57 +1311,117 @@@
visible: boolean,
freeze = false,
): void {
-- if (!visible || samples.length === 0 || viewport.width <= 0 || viewport.height <= 0) {
++ if (samples.length === 0 || viewport.width <= 0 || viewport.height <= 0) {
this.container.visible = false;
++ this.cursorVisible = false;
++ this.clickRingGraphics.clear();
this.lastRenderedPoint = null;
this.lastRenderedTimeMs = null;
this.swayRotation = 0;
resetSpringState(this.swaySpring, 0);
this.cursorMotionBlurFilter.velocity = { x: 0, y: 0 };
++ this.customCursorShadowSprite.visible = false;
++ this.customCursorSprite.visible = false;
++ for (const shadowSprite of Object.values(this.cursorShadowSprites)) {
++ shadowSprite.visible = false;
++ }
++ for (const sprite of Object.values(this.cursorSprites)) {
++ sprite.visible = false;
++ }
return;
}
const target = interpolateCursorPosition(samples, timeMs);
if (!target) {
this.container.visible = false;
++ this.cursorVisible = false;
++ this.clickRingGraphics.clear();
return;
}
const projectedTarget = projectCursorPositionToViewport(target, viewport.sourceCrop);
-- if (!projectedTarget.visible) {
- this.container.visible = false;
- this.lastRenderedPoint = null;
- this.lastRenderedTimeMs = null;
- this.swayRotation = 0;
- resetSpringState(this.swaySpring, 0);
- this.cursorMotionBlurFilter.velocity = { x: 0, y: 0 };
- return;
- }
-
- const sameFrameTime =
- this.lastRenderedTimeMs !== null && Math.abs(this.lastRenderedTimeMs - timeMs) < 0.0001;
- const hasTimeDiscontinuity =
- this.lastRenderedTimeMs !== null &&
- Math.abs(timeMs - this.lastRenderedTimeMs) > CURSOR_TIME_DISCONTINUITY_MS;
- const shouldFreezeCursorMotion = freeze || hasTimeDiscontinuity;
+
- if (shouldFreezeCursorMotion) {
- if (!sameFrameTime || !this.lastRenderedPoint) {
- this.state.snapTo(projectedTarget.cx, projectedTarget.cy, timeMs);
- }
- } else {
- this.state.update(projectedTarget.cx, projectedTarget.cy, timeMs);
- }
- this.container.visible = true;
-
- const px = viewport.x + this.state.x * viewport.width;
- const py = viewport.y + this.state.y * viewport.height;
+ const h = this.config.dotRadius * getCursorViewportScale(viewport);
+ const { cursorType, clickSample, clickBounceProgress, clickProgress } =
+ getCursorVisualState(
+ samples,
+ timeMs,
+ this.config.clickBounceDuration,
+ this.config.clickEffectDurationMs,
+ );
+ const projectedClickSample = clickSample
+ ? projectCursorPositionToViewport(clickSample, viewport.sourceCrop)
+ : null;
+ const clickEffectPx =
+ projectedClickSample && projectedClickSample.visible
+ ? viewport.x + projectedClickSample.cx * viewport.width
- : px;
++ : viewport.x + projectedTarget.cx * viewport.width;
+ const clickEffectPy =
+ projectedClickSample && projectedClickSample.visible
+ ? viewport.y + projectedClickSample.cy * viewport.height
- : py;
++ : viewport.y + projectedTarget.cy * viewport.height;
++ const shouldShowCursorSprite = visible && projectedTarget.visible;
++ const shouldDrawClickEffect =
++ this.config.clickEffect !== "none" &&
++ clickProgress > 0 &&
++ Boolean(projectedClickSample?.visible);
++
++ if (!shouldShowCursorSprite && !shouldDrawClickEffect) {
+ this.container.visible = false;
++ this.cursorVisible = false;
++ this.clickRingGraphics.clear();
++ this.customCursorShadowSprite.visible = false;
++ this.customCursorSprite.visible = false;
++ for (const shadowSprite of Object.values(this.cursorShadowSprites)) {
++ shadowSprite.visible = false;
++ }
++ for (const sprite of Object.values(this.cursorSprites)) {
++ sprite.visible = false;
++ }
+ this.lastRenderedPoint = null;
+ this.lastRenderedTimeMs = null;
+ this.swayRotation = 0;
+ resetSpringState(this.swaySpring, 0);
+ this.cursorMotionBlurFilter.velocity = { x: 0, y: 0 };
+ return;
+ }
+
- const sameFrameTime =
- this.lastRenderedTimeMs !== null && Math.abs(this.lastRenderedTimeMs - timeMs) < 0.0001;
- const hasTimeDiscontinuity =
- this.lastRenderedTimeMs !== null &&
- Math.abs(timeMs - this.lastRenderedTimeMs) > CURSOR_TIME_DISCONTINUITY_MS;
- const shouldFreezeCursorMotion = freeze || hasTimeDiscontinuity;
-
- if (shouldFreezeCursorMotion) {
- if (!sameFrameTime || !this.lastRenderedPoint) {
- this.state.snapTo(projectedTarget.cx, projectedTarget.cy, timeMs);
++ this.container.visible = true;
++ this.cursorVisible = shouldShowCursorSprite;
++
++ let px = viewport.x + projectedTarget.cx * viewport.width;
++ let py = viewport.y + projectedTarget.cy * viewport.height;
++ let shouldFreezeCursorMotion = true;
++
++ if (shouldShowCursorSprite) {
++ const sameFrameTime =
++ this.lastRenderedTimeMs !== null && Math.abs(this.lastRenderedTimeMs - timeMs) < 0.0001;
++ const hasTimeDiscontinuity =
++ this.lastRenderedTimeMs !== null &&
++ Math.abs(timeMs - this.lastRenderedTimeMs) > CURSOR_TIME_DISCONTINUITY_MS;
++ shouldFreezeCursorMotion = freeze || hasTimeDiscontinuity;
++
++ if (shouldFreezeCursorMotion) {
++ if (!sameFrameTime || !this.lastRenderedPoint) {
++ this.state.snapTo(projectedTarget.cx, projectedTarget.cy, timeMs);
++ }
++ } else {
++ this.state.update(projectedTarget.cx, projectedTarget.cy, timeMs);
+ }
++
++ px = viewport.x + this.state.x * viewport.width;
++ py = viewport.y + this.state.y * viewport.height;
+ } else {
- this.state.update(projectedTarget.cx, projectedTarget.cy, timeMs);
++ this.customCursorShadowSprite.visible = false;
++ this.customCursorSprite.visible = false;
++ for (const shadowSprite of Object.values(this.cursorShadowSprites)) {
++ shadowSprite.visible = false;
++ }
++ for (const sprite of Object.values(this.cursorSprites)) {
++ sprite.visible = false;
++ }
+ }
- this.container.visible = true;
+
- const px = viewport.x + this.state.x * viewport.width;
- const py = viewport.y + this.state.y * viewport.height;
- const h = this.config.dotRadius * getCursorViewportScale(viewport);
- const { cursorType, clickBounceProgress } = getCursorVisualState(
- samples,
- timeMs,
- this.config.clickBounceDuration,
- );
const bounceScale = Math.max(
0.72,
1 - Math.sin(clickBounceProgress * Math.PI) * (0.08 * this.config.clickBounce),
@@@ -1397,7 -1126,7 +1445,7 @@@
cursorType in this.cursorSprites ? cursorType : "arrow"
) as CursorAssetKey;
-- if (isStatefulCursorStyle(this.config.style)) {
++ if (shouldShowCursorSprite && isStatefulCursorStyle(this.config.style)) {
this.customCursorShadowSprite.visible = false;
this.customCursorSprite.visible = false;
@@@ -1432,7 -1161,7 +1480,7 @@@
sprite.position.set(px, py);
sprite.rotation = swayRotation;
}
-- } else {
++ } else if (shouldShowCursorSprite) {
for (const currentShadowSprite of Object.values(this.cursorShadowSprites)) {
currentShadowSprite.visible = false;
}
@@@ -1469,7 -1198,7 +1517,7 @@@
}
this.applyCursorMotionBlur(px, py, timeMs, shouldFreezeCursorMotion);
-- this.lastRenderedPoint = { px, py };
++ this.lastRenderedPoint = shouldShowCursorSprite ? { px, py } : null;
this.lastRenderedTimeMs = timeMs;
}
@@@ -1534,6 -1263,6 +1582,7 @@@
reset(): void {
this.state.reset();
this.clickRingGraphics.clear();
++ this.cursorVisible = false;
for (const shadowSprite of Object.values(this.cursorShadowSprites)) {
shadowSprite.visible = false;
shadowSprite.scale.set(1);
diff --cc src/lib/exporter/modernVideoExporter.nativeStaticLayout.test.ts
index 9509f4e3,aee1b51d..d3279110
--- a/src/lib/exporter/modernVideoExporter.nativeStaticLayout.test.ts
+++ b/src/lib/exporter/modernVideoExporter.nativeStaticLayout.test.ts
@@@ -235,28 -235,6 +235,50 @@@ describe("ModernVideoExporter native st
).toBeNull();
});
+ it("skips native static-layout when cursor click effects are enabled", () => {
+ const exporter = createExporter({
+ showCursor: true,
+ cursorClickEffect: "echo",
+ cursorTelemetry: [
+ { timeMs: 0, cx: 0.25, cy: 0.35 },
+ { timeMs: 1_000, cx: 0.5, cy: 0.55, interactionType: "click" },
+ ],
+ });
+
++ expect(
++ exporter.getNativeStaticLayoutSkipReason(
++ {
++ audioMode: "copy-source",
++ audioSourcePath: "recording.mp4",
++ },
++ videoInfo,
++ 60,
++ ),
++ ).toBe("unsupported-cursor-click-effect");
++ });
++
++ it("skips native static-layout when click effects are enabled and cursor is hidden", () => {
++ const exporter = createExporter({
++ showCursor: false,
++ cursorClickEffect: "echo",
++ cursorTelemetry: [
++ { timeMs: 0, cx: 0.25, cy: 0.35 },
++ { timeMs: 1_000, cx: 0.5, cy: 0.55, interactionType: "click" },
++ ],
++ });
++
+ expect(
+ exporter.getNativeStaticLayoutSkipReason(
+ {
+ audioMode: "copy-source",
+ audioSourcePath: "recording.mp4",
+ },
+ videoInfo,
+ 60,
+ ),
+ ).toBe("unsupported-cursor-click-effect");
+ });
+
it("reports frame overlays as the remaining native overlay blocker", () => {
const exporter = createExporter({ frame: "macbook" });
diff --cc src/lib/exporter/modernVideoExporter.ts
index a68278db,dc22bee0..5b65882b
--- a/src/lib/exporter/modernVideoExporter.ts
+++ b/src/lib/exporter/modernVideoExporter.ts
@@@ -1518,10 -1507,6 +1518,9 @@@ export class ModernVideoExporter
}
const speedRegions = this.config.speedRegions ?? [];
+ const hasCursorClickEffect =
- this.config.showCursor === true &&
+ (this.config.cursorTelemetry?.length ?? 0) > 0 &&
+ (this.config.cursorClickEffect ?? "none") !== "none";
const configuredWallpaper = this.config.wallpaper?.trim() ?? "";
if (isVideoWallpaperSource(configuredWallpaper)) {
reasons.push("unsupported-background-video");