Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

Music video: intercut never plays a shot's tail right before that shot starts (#11627)

[._.]/2010c193dfca
diff --git a/server/services/musicVideo/intercut.js b/server/services/musicVideo/intercut.js
index 347fc420a5..db1ab689f9 100644
--- a/server/services/musicVideo/intercut.js
+++ b/server/services/musicVideo/intercut.js
@@ -229,8 +229,12 @@ export function intercutClips(clips, { scenes = [], sections = [], beats = [], b
.filter(({ clip }) => !clip.layer && clip.videoPath && modes.get(clip.sceneId) !== 'performance' && !locked.has(clip.sceneId) && finite(clip.sourceSec) && clip.sourceSec > MIN_PIECE_SEC)
.map((p) => ({ ...p, head: p.clip.outSec, start: p.clip.inSec, end: p.clip.inSec + p.clip.sourceSec }));
- function takePartner(host, len) {
- const pool = partners.filter((p) => p.clip.sceneId !== host.clip.sceneId && p.clip.videoPath !== host.clip.videoPath && p.end - p.start >= len - EPS);
+ // A piece ending where its partner's own shot begins would show that take's
+ // tail and then its start, which reads as the clip looping, so that shot is
+ // never the partner.
+ function takePartner(host, len, endT) {
+ const pool = partners.filter((p) => p.clip.sceneId !== host.clip.sceneId && p.clip.videoPath !== host.clip.videoPath && p.end - p.start >= len - EPS
+ && Math.abs(p.t0 - endT) > EPS);
if (!pool.length) return null;
const sameSection = pool.filter((p) => p.section?.index === host.section?.index);
const candidates = sameSection.length ? sameSection : pool;
@@ -257,7 +261,7 @@ export function intercutClips(clips, { scenes = [], sections = [], beats = [], b
for (let k = 0; k < bounds.length - 1; k += 1) {
const a = bounds[k];
const len = round3(bounds[k + 1] - a);
- const partner = k % 2 === 1 ? takePartner(host, len) : null;
+ const partner = k % 2 === 1 ? takePartner(host, len, bounds[k + 1]) : null;
if (partner) { out.push(partner); continue; }
if (still) { out.push({ ...clip, inSec: 0, outSec: len, duration: len, sourceSec: len, ...(clip.effect ? { effectAtSec: round3(a - t0) } : {}) }); continue; }
// The host keeps its own continuous time (a performance stays in sync).
diff --git a/server/services/musicVideo/intercut.test.js b/server/services/musicVideo/intercut.test.js
index c99afbf58c..60b6a0dda0 100644
--- a/server/services/musicVideo/intercut.test.js
+++ b/server/services/musicVideo/intercut.test.js
@@ -75,6 +75,19 @@ describe('intercutClips (#9290)', () => {
expect(spanOf(out)).toBeCloseTo(spanOf(clips), 2);
});
+ // Uniquely catches a partner piece that shows a shot's tail right before that shot starts (it reads as a loop).
+ it('never ends a piece on its partner\'s own tail right where that shot begins', () => {
+ const loud = [{ startSec: 0, endSec: 12, energy: 1 }, { startSec: 12, endSec: 13, energy: 0 }];
+ const pair = [footage('a', 0, 4, 10), footage('b', 0, 4, 10), footage('c', 0, 4, 10)];
+ const out = intercutClips(pair, { scenes: [], sections: loud, beats, bpm });
+ expect(out.some((c) => c.intercutOf)).toBe(true);
+ out.forEach((c, i) => {
+ const next = out[i + 1];
+ if (c.intercutOf && next && !next.intercutOf) expect(next.sceneId).not.toBe(c.sceneId);
+ });
+ expect(spanOf(out)).toBeCloseTo(12, 2);
+ });
+
it('prefers a sung word onset near the target cut', () => {
const one = [footage('perf', 0, 4, 4), footage('b-roll', 0, 4, 10)];
const loudOnly = [{ startSec: 0, endSec: 8, energy: 1 }, { startSec: 8, endSec: 9, energy: 0 }];