Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.
Read a Total frames value that is not a frame count as the duration, in the page and the server
Bowen Xue5debe1f79ecd
diff --git a/__init__.py b/__init__.pyindex 3f20b50..2ce8c69 100644--- a/__init__.py+++ b/__init__.py@@ -49,5 +49,6 @@ async def comfy_entrypoint():except Exception as error:import logginglogging.warning('[FreeVideo] Agent routes not registered: %s', error)- from .freevideo_engine.comfy_nodes import FreeVideoExtension+ from .freevideo_engine.comfy_nodes import FreeVideoExtension, register_prompt_cleanup+ register_prompt_cleanup()return FreeVideoExtension()diff --git a/freevideo_engine/comfy_continuation.py b/freevideo_engine/comfy_continuation.pyindex 4af4bec..9a26d55 100644--- a/freevideo_engine/comfy_continuation.py+++ b/freevideo_engine/comfy_continuation.py@@ -22,6 +22,25 @@ def optional_text(value, default=''):return value+def node_frames(value):+ """The node's Total frames, or 0 (follow Duration) for anything that is not a count the model makes.++ Workflows saved by earlier versions and restored tabs can leave '', None, a word or another+ widget's number in this optional input. Such a value is not a request for that length, so it+ is read as "not given" instead of refusing the whole request.+ """+ if isinstance(value, str):+ try:+ value = int(value.strip())+ except ValueError:+ return 0+ if isinstance(value, float) and value.is_integer():+ value = int(value)+ if type(value) is not int or value < 39 or (value - 5) % 17:+ return 0+ return value++def request_frames(value):"""Translate the node's duration sentinel into the bridge's optional count."""if type(value) is not int or value != 0 and (value < 39 or (value - 5) % 17):diff --git a/freevideo_engine/comfy_nodes.py b/freevideo_engine/comfy_nodes.pyindex f78f155..d3be9e3 100644--- a/freevideo_engine/comfy_nodes.py+++ b/freevideo_engine/comfy_nodes.py@@ -5,7 +5,7 @@ from pathlib import Pathfrom comfy_api.latest import ComfyExtension, InputImpl, io, uifrom . import comfy_bridge-from .comfy_continuation import optional_text, request_options+from .comfy_continuation import node_frames, optional_text, request_optionsfrom .default_prompt import DEFAULT_PROMPTReferences = io.Custom('FREEVIDEO_REFERENCES')@@ -15,6 +15,34 @@ NO_LORA = 'None'STEP_CACHE_OPTIONS = ('none', 'easycache-av', 'fbcache')+def clean_prompt(json_data):+ """POST /prompt hook: read Total frames before ComfyUI converts it.++ ComfyUI rejects '' or None for an integer input before validate_inputs runs, so the value is+ read here the same way the node reads it (node_frames): anything that is not a count the model+ makes follows Duration. Links and other nodes are left as they are.+ """+ prompt = json_data.get('prompt') if isinstance(json_data, dict) else None+ for node in prompt.values() if isinstance(prompt, dict) else ():+ inputs = node.get('inputs') if isinstance(node, dict) and node.get('class_type') == 'FreeVideoGenerate' else None+ if isinstance(inputs, dict) and 'frames' in inputs and not isinstance(inputs['frames'], list):+ frames = node_frames(inputs['frames'])+ if frames != inputs['frames'] or type(frames) is not type(inputs['frames']):+ logging.info('[FreeVideo] Total frames %r is not a frame count; the length follows Duration.',+ str(inputs['frames'])[:40])+ inputs['frames'] = frames+ return json_data+++def register_prompt_cleanup():+ from server import PromptServer+ server = PromptServer.instance+ if server is None or getattr(server, '_freevideo_prompt_cleanup', False):+ return+ server._freevideo_prompt_cleanup = True+ server.add_on_prompt_handler(clean_prompt)++def step_cache_option(value):"""Bridge keyword for the Step cache widget; a workflow without it, with 'none' or with a value that isnot an option adds nothing. Workflows saved before the widget existed hold '' in its position."""@@ -97,7 +125,7 @@ class FreeVideoGenerate(io.ComfyNode):# and execute samples in full for any value that is not an option.refine_from = optional_text(refine_from)try:- options = request_options(continue_from, frames)+ options = request_options(continue_from, node_frames(frames))if options.get('continue_from'):# A continued part turns on two passes, skips the preview and takes keyframes as pictures (execute).two_pass, preview = True, False@@ -136,7 +164,7 @@ class FreeVideoGenerate(io.ComfyNode):refine_from, continue_from = optional_text(refine_from), optional_text(continue_from)node_id = cls.hidden.unique_idchain = block_context(PromptServer.instance, node_id)- options = request_options(continue_from, frames)+ options = request_options(continue_from, node_frames(frames))notes = []if options.get('continue_from') and not two_pass:two_pass = Truediff --git a/web/optional_inputs.js b/web/optional_inputs.jsindex b089de3..3bf7416 100644--- a/web/optional_inputs.js+++ b/web/optional_inputs.js@@ -16,8 +16,14 @@ export function optionalText(value) {return !text || EMPTY_WORDS.has(text.toLowerCase()) ? '' : value;}+// Total frames is 0 (follow Duration) or 5 + 17n from 39 on, as the engine reads it (node_frames).+// Any other number came from somewhere else, such as a moved widget, and is not a requested length.+export function frameCount(value) {+ return Number.isSafeInteger(value) && value >= 39 && (value - 5) % 17 === 0 ? value : 0;+}+export function optionalInputValue(name, value) {- if (name === 'frames') return Number.isSafeInteger(value) && value >= 0 ? value : 0;+ if (name === 'frames') return frameCount(value);if (name === 'refine_from' || name === 'continue_from') return optionalText(value);if (name === 'first_frame_reference') return value === true;if (name === 'step_cache') return STEP_CACHE_OPTIONS.includes(value) ? value : 'none';