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

report an unmeasured reference-video cut rhythm as unmeasured, not as one continuous shot

[._.]/ Adam Eivyc0f2f2b917bc
diff --git a/server/services/codeAnimation/prompt.js b/server/services/codeAnimation/prompt.js
index 528b30052d..d180f646da 100644
--- a/server/services/codeAnimation/prompt.js
+++ b/server/services/codeAnimation/prompt.js
@@ -149,13 +149,15 @@ function referenceImagesSection(images, delivery) {
// reference images) plus the measured cut rhythm, and is told what to take.
function referenceVideoSection(video) {
if (!video) return '';
- const { durationSec, cuts = [] } = video;
- const shots = cuts.length + 1;
- const rhythm = cuts.length
+ const { durationSec, cuts } = video;
+ const shots = (cuts?.length ?? 0) + 1;
+ const rhythm = !cuts
+ ? `${durationSec.toFixed(1)}s long; its cut rhythm could not be measured, so read it from the contact sheet.`
+ : cuts.length
? `${shots} shots in ${durationSec.toFixed(1)}s (average ${(durationSec / shots).toFixed(1)}s per shot); cuts at ${cuts.map((t) => `${t.toFixed(1)}s`).join(', ')}.`
: `One continuous ${durationSec.toFixed(1)}s shot with no detected cuts.`;
const note = isNonBlankStr(video.note) ? `\nWhat to take from it: ${trimTo(video.note, CODE_ANIMATION_LIMITS.referenceNoteMax)}` : '';
- return `REFERENCE VIDEO — "${video.label}": the quality bar to match. Its contact sheet and two keyframes are among the reference images below. Measured rhythm: ${rhythm}${note}
+ return `REFERENCE VIDEO — "${video.label}": the quality bar to match. Its contact sheet and two keyframes are among the reference images below. ${cuts ? 'Measured rhythm: ' : ''}${rhythm}${note}
Study and match its craft, not its content: shot rhythm and coverage (wides, close-ups, inserts), camera moves and focus pulls, lighting and time of day, how it renders surfaces, and its finish (depth of field, bloom on light sources, colour grade, grain). Scale its cut rhythm to this piece's duration. Reproduce that fidelity with your own original subject, characters and story — never copy its characters, logos, text or shots.`;
}
diff --git a/server/services/codeAnimation/prompt.test.js b/server/services/codeAnimation/prompt.test.js
index 66ff9a276c..72579a6c7a 100644
--- a/server/services/codeAnimation/prompt.test.js
+++ b/server/services/codeAnimation/prompt.test.js
@@ -161,6 +161,16 @@ describe('extractAnimationHtml', () => {
});
});
+describe('reference video rhythm', () => {
+ // A failed scene-detection pass must not read as a measured "no cuts".
+ it('says an unmeasured rhythm is unmeasured instead of reporting one continuous shot', () => {
+ const video = (cuts) => buildCodeAnimationPrompt({ concept: 'x', format, referenceVideo: { label: 'Reference', durationSec: 12, cuts, note: '' } });
+ expect(video(null)).toContain('its cut rhythm could not be measured');
+ expect(video(null)).not.toContain('Measured rhythm');
+ expect(video([])).toContain('Measured rhythm: One continuous 12.0s shot with no detected cuts.');
+ });
+});
+
// Exercise the production song adapter, not a prompt-only field nobody supplies.
describe('music-video craft and measured choreography', () => {
const builders = [
diff --git a/server/services/codeAnimation/referenceVideo.js b/server/services/codeAnimation/referenceVideo.js
index f2238b83e4..6e7349263f 100644
--- a/server/services/codeAnimation/referenceVideo.js
+++ b/server/services/codeAnimation/referenceVideo.js
@@ -37,11 +37,13 @@ export function parseCutTimes(stderr) {
async function detectCuts(ffmpeg, videoPath) {
const result = await runFfmpegProcess({
bin: ffmpeg,
- args: ['-hide_banner', '-i', videoPath, '-an', '-vf', `scale=320:-2,select='gt(scene,${CUT_THRESHOLD})',showinfo`, '-f', 'null', '-'],
+ // -nostats keeps progress lines out of the stderr tail the stamps are read from.
+ args: ['-hide_banner', '-nostats', '-loglevel', 'info', '-i', videoPath, '-an', '-vf', `scale=320:-2,select='gt(scene,${CUT_THRESHOLD})',showinfo`, '-f', 'null', '-'],
returnStderr: true,
stderrTailBytes: 400000,
});
- return result.ok ? parseCutTimes(result.stderr) : [];
+ // null, not [], so a failed pass never reads as "no cuts".
+ return result.ok ? parseCutTimes(result.stderr) : null;
}
async function extractKeyframe(ffmpeg, videoPath, atSec, outputPath) {
@@ -76,7 +78,8 @@ export async function resolveReferenceVideo(ref) {
await extractKeyframe(ffmpeg, path, durationSec * 0.3, at(names.early));
await extractKeyframe(ffmpeg, path, durationSec * 0.7, at(names.late));
meta = { durationSec, cuts: await detectCuts(ffmpeg, path), sheetEverySec: times.length > 1 ? times[1] - times[0] : durationSec };
- await writeFile(at(names.meta), JSON.stringify(meta));
+ // An unmeasured rhythm is not cached, so the next request measures again.
+ if (meta.cuts) await writeFile(at(names.meta), JSON.stringify(meta));
}
const label = trimTo(ref.label, 120) || ref.filename;
const image = (name, what) => ({ label: `${label} — ${what}`, origin: 'reference-video', note: '', path: at(name), url: thumbUrl(name) });