The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Runs: a clip's own header gives its length in a run's facts
Adarsh2a8de9f85bad
diff --git a/src/server/hosted.ts b/src/server/hosted.tsindex 7137cb7c..8faca015 100644--- a/src/server/hosted.ts+++ b/src/server/hosted.ts@@ -650,11 +650,11 @@ const r3 = (n: number) => Math.round(n * 1000) / 1000;/*** The seconds a run makes whose result follows its input clip (CLIP_LENGTH_OPS) or, for a talking avatar or lip re-sync- * that follows its voice, the voice, as the run reads it: the length the request states for its clip (params.sourceDuration: a studio's part, the composer's- * read of the upload), else the header of the uploaded file, as the GPUs' own job size reads it; within the range the- * request keeps where the run cuts one (params.startTime / endTime); slow motion stretched by its factor. A length the- * request asks for wins where the run makes that length. Undefined for any other run, null when the clip's length can't be- * read.+ * that follows its voice, the voice: the header of the file it reads, as the GPUs' own job size reads it (never a length+ * the request says instead, which could understate it), else the length the request states (params.sourceDuration: a+ * chain's clip made by an earlier step, a file only the composer read); within the range the request keeps where the run+ * cuts one (params.startTime / endTime); slow motion stretched by its factor. A length the request asks for wins where+ * the run makes that length. Undefined for any other run, null when the length can't be read.*/export function clipRunSeconds(req: GenerationRequest,@@ -685,12 +685,9 @@ export function clipRunSeconds(// A talking avatar, and lip re-sync with no clip or on a graph that counts its frames, run as long as the voice// (comfy-compose.ts voiceLength); the length the request states is the voice's only for an avatar or with no clip.const voice = op === "avatar" || (op === "lipsync" && (!req.inputs?.video || (run.providerId === "comfyui" && binds("frames"))));- let length = voice && req.inputs?.video ? null : positive(params.sourceDuration);- if (!length) {- const file = voice ? (req.inputs?.audio ?? req.inputs?.voiceAudio) : (req.inputs?.video ?? req.inputs?.videos?.[0]);- const info = file ? storedMedia(file)?.info : null;- length = positive(voice ? info?.duration : (info?.videoDuration ?? info?.duration));- }+ const file = voice ? (req.inputs?.audio ?? req.inputs?.voiceAudio) : (req.inputs?.video ?? req.inputs?.videos?.[0]);+ const info = file ? storedMedia(file)?.info : null;+ let length = positive(voice ? info?.duration : (info?.videoDuration ?? info?.duration)) ?? (voice && req.inputs?.video ? null : positive(params.sourceDuration));if (!length) return asked ?? null;if (voice) return r3(length);// The part a range keeps: a trim's, or a graph or route that cuts the clip there.diff --git a/tests/clip-run-facts.test.ts b/tests/clip-run-facts.test.tsindex 57509a6f..d9610960 100644--- a/tests/clip-run-facts.test.ts+++ b/tests/clip-run-facts.test.ts@@ -132,6 +132,10 @@ describe("a run that follows a clip carries the clip's length", () => {expect(clipRunSeconds(req, "motion-transfer", { modelId: req.modelId, providerId: "comfyui", workflow: "wan-animate2" })).toBe(12.5);});+ it("a stated length never stands for the length of a clip whose header is read", () => {+ expect(factsOf({ ...motionLite(), params: { resolution: "480p", sourceDuration: 3, extra: { steps: 4 } } }).seconds).toBe(30);+ });+it("a length the graph doesn't make (a default left in the request) doesn't stand for the clip's", () => {expect(factsOf({ ...motionLite(), params: { resolution: "480p", duration: 5 } }).seconds).toBe(30);});