From 0709c7e6ae342ff6b13bfc0ab63c9ccaf4f93b25 Mon Sep 17 00:00:00 2001 From: Sxela Date: Sat, 8 Feb 2025 23:50:52 +0100 Subject: [PATCH] fix auto queue + video export --- frame_nodes.py | 2 +- js/main.js | 112 ++++++++++++++++++++++++++++--------------------- 2 files changed, 66 insertions(+), 48 deletions(-) diff --git a/frame_nodes.py b/frame_nodes.py index 7c1291a..0aa4101 100644 --- a/frame_nodes.py +++ b/frame_nodes.py @@ -424,7 +424,7 @@ class RenderVideo: print('Exporting video.') save_video(indir=frames_input_dir, video_out=output_dir, batch_name=batch_name, start_frame=first_frame, last_frame=last_frame, fps=fps, output_format=output_format, use_deflicker=use_deflicker) - raise Exception(f'Exported video successfully. This exception is raised to just stop the endless cycle :D.\n you can find your video at {output_dir}') + # raise Exception(f'Exported video successfully. This exception is raised to just stop the endless cycle :D.\n you can find your video at {output_dir}') return () class SchedulerInt: diff --git a/js/main.js b/js/main.js index 8eb9c41..2749555 100644 --- a/js/main.js +++ b/js/main.js @@ -1,54 +1,72 @@ import { app } from "../../scripts/app.js"; class QueueMany { - constructor(node) { - this.serializedCtx = {}; - this.node = node; - for (const [i, w] of this.node.widgets.entries()) { - if (w.name === 'start') { - this.start = w; - } - if (w.name === 'end') { - this.end = w; - } - if (w.name === 'current_number') { - this.current_number = w; - } - } - this.current_number.value = this.start.value - console.log(this.start, this.end, this.current_number) - - this.QueueButton = this.node.addWidget("button", 'Queue Many', null, () => { - console.log('lolo') - this.current_number.value = this.start.value - for (let i=this.start.value; i<=this.end.value; i++){ - console.log('iiii', i) - app.queuePrompt(0, 1) - - } - }) - - this.current_number.serializeValue = async (node, index) => {return this.current_number.value} - - this.current_number.afterQueued = () => { - this.current_number.value += 1 - if (this.current_number.value > this.end.value) { - this.current_number.value = this.start.value - } - } + constructor(node) { + this.serializedCtx = {}; + this.node = node; + for (const [i, w] of this.node.widgets.entries()) { + if (w.name === "start") { + this.start = w; + } + if (w.name === "end") { + this.end = w; + } + if (w.name === "current_number") { + this.current_number = w; + } } + + this.QueueButton = this.node.addWidget( + "button", + "Queue from " + this.start.value, + null, + () => { + const ui = window.comfyAPI.app.app.ui; + ui.autoQueueMode = "instant"; // or whatever mode you want + ui.autoQueueEnabled = true; // or false to disable + this.current_number.value = this.start.value; + if (this.current_number.value <= this.end.value) { + app.queuePrompt(0, 1); + } + } + ); + + this.current_number.serializeValue = async (node, index) => { + return this.current_number.value; + }; + + this.current_number.afterQueued = () => { + this.current_number.value += 1; + for (const [i, w] of this.node.widgets.entries()) { + if (w.name === "start") { + this.start = w; + } + if (w.name === "end") { + this.end = w; + } + if (w.name === "current_number") { + this.current_number = w; + } + } + if (this.current_number.value > this.end.value) { + const ui = window.comfyAPI.app.app.ui; + ui.autoQueueMode = "disabled"; + ui.autoQueueEnabled = false; + } + }; + + } } app.registerExtension({ - name: "warpfusion.queuemany", - async beforeRegisterNodeDef(nodeType, nodeData, _app) { - // console.log(nodeData.name) - if (nodeData.name === "FixedQueue"){ - const onNodeCreated = nodeType.prototype.onNodeCreated; - nodeType.prototype.onNodeCreated = function () { - onNodeCreated ? onNodeCreated.apply(this, []) : undefined; - this.queueMany = new QueueMany(this); - } - }; - }}) - + name: "warpfusion.queuemany", + async beforeRegisterNodeDef(nodeType, nodeData, _app) { + if (nodeData.name === "FixedQueue") { + const onNodeCreated = nodeType.prototype.onNodeCreated; + nodeType.prototype.onNodeCreated = function () { + onNodeCreated ? onNodeCreated.apply(this, []) : undefined; + this.queueMany = new QueueMany(this); + }; + } + }, +});