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.
Treat empty, blank and none-words as not given for optional inputs
Bowen Xue794b1ad09ae6
diff --git a/freevideo_engine/agent/edit.py b/freevideo_engine/agent/edit.pyindex 64b26dc..46aa3cd 100644--- a/freevideo_engine/agent/edit.py+++ b/freevideo_engine/agent/edit.py@@ -114,7 +114,7 @@ def _apply(m, x, y):# Colour and rasters: float32 premultiplied RGBA in 0..1, like a canvas.def _color(value, path='/'):- if value is None or value == 'transparent':+ if value is None or isinstance(value, str) and value.strip().lower() in ('transparent', 'none'):return (0., 0., 0., 0.)try:r, g, b, a = ImageColor.getcolor(str(value), 'RGBA')diff --git a/freevideo_engine/comfy_assets.py b/freevideo_engine/comfy_assets.pyindex 29d2cb8..9bf3679 100644--- a/freevideo_engine/comfy_assets.py+++ b/freevideo_engine/comfy_assets.py@@ -4,6 +4,7 @@ import mathimport osfrom pathlib import Path, PurePosixPath, PureWindowsPathfrom . import launcher_bridge+from .comfy_continuation import optional_textfrom .monitoring import thermal_slowdown, shared_gpu_note, worker_gpufrom .paths import data_rootfrom .support_report import encoder_sizes@@ -30,6 +31,7 @@ REFERENCE_INPUTS = ('reference', *(f'reference_{i}' for i in range(2, 9)))def resolve_loras(serialized, names, resolve, previous=None):"""Resolve a UI stack through Comfy's registered libraries, never raw paths."""+ serialized = optional_text(serialized, '[]')if not isinstance(serialized, str) or len(serialized) > 128 * 1024:raise ValueError('Invalid LoRA selection')rows = json.loads(serialized)@@ -64,6 +66,7 @@ def media_kind(filename):def resolve_assets(serialized, input_directory):+ serialized = optional_text(serialized, '[]')if not isinstance(serialized, str) or len(serialized) > 128 * 1024:raise ValueError('Invalid media selection')rows = json.loads(serialized)diff --git a/freevideo_engine/comfy_continuation.py b/freevideo_engine/comfy_continuation.pyindex ccbcea2..4af4bec 100644--- a/freevideo_engine/comfy_continuation.py+++ b/freevideo_engine/comfy_continuation.py@@ -5,21 +5,20 @@ from .continuation import (INVALID_FILE, INVALID_FRAMES, LEAD_IN_SAMPLES,LEAD_IN_FADE, LEAD_IN_RATE)-# ComfyUI turns an empty string widget into str(None) when a saved workflow or an API-# client leaves it out, so these spellings all mean "not set". Real paths are untouched.-EMPTY_TEXT = frozenset(('none', 'null', 'undefined'))+_EMPTY_TEXT = frozenset(('none', 'null', 'undefined', 'nan'))-def optional_text(value):- """The one place an optional text input (refine_from, continue_from) is read as set or not.+def optional_text(value, default=''):+ """Return an optional text input, or default when it was not given.- None, blank text and "None"/"null"/"undefined" (any case) become ''; any other- value is returned unchanged so later validation still rejects what is not a path.+ A missing optional widget can arrive as None, a blank string or the word a+ script or an older workflow wrote for "nothing" ("None", "null",+ "undefined", "NaN"). Other values are returned unchanged for the caller's+ own checks, so a real value is never reinterpreted."""- if value is None:- return ''- if isinstance(value, str) and (not value.strip() or value.strip().lower() in EMPTY_TEXT):- return ''+ if value is None or isinstance(value, str) and (+ not value.strip() or value.strip().lower() in _EMPTY_TEXT):+ return defaultreturn valuediff --git a/freevideo_engine/image_gen/service.py b/freevideo_engine/image_gen/service.pyindex db3d62c..bf51427 100644--- a/freevideo_engine/image_gen/service.py+++ b/freevideo_engine/image_gen/service.py@@ -126,7 +126,9 @@ class Service:seed = value.get('seed')if seed is not None and (type(seed) is not int or not -2**63 <= seed < 2**64):raise ValueError('invalid_seed')- images = value.get('images', [])+ images = value.get('images')+ if images is None:+ images = []if not isinstance(images, list):raise ValueError('invalid_media')if len(images) > MAX_IMAGES:diff --git a/freevideo_engine/media_request.py b/freevideo_engine/media_request.pyindex fb6ea66..256e3ff 100644--- a/freevideo_engine/media_request.py+++ b/freevideo_engine/media_request.py@@ -44,7 +44,9 @@ def read(path):if value.get(anchor):result[anchor] = file_info(value[anchor])for field in ('references', 'loras'):- entries = value.get(field, [])+ entries = value.get(field)+ if entries is None:+ entries = []if not isinstance(entries, list) or len(entries) > 32:raise ValueError('At most 32 ' + field + ' per request')result[field] = []diff --git a/web/editor.js b/web/editor.jsindex ff98c0c..6dc9f6f 100644--- a/web/editor.js+++ b/web/editor.js@@ -26,6 +26,7 @@ import {createBlockNotes, describedTrack} from './editor_notes.js';import {createFirstRunGuide} from './first_run_guide.js';import {createEditorFailures} from './editor_failure.js';import {fitEditorHeader} from './editor_header_fit.js';+import {optionalText} from './optional_inputs.js';const editorStyles = Promise.all(['result_actions.css', 'editor.css', 'editor_tracks.css', 'editor_frame.css', 'editor_adjust.css', 'editor_adjust_picture.css', 'editor_preview_picture.css', 'editor_select.css', 'editor_menu.css', 'editor_text.css', 'editor_notes.css', 'editor_transport.css'].map(name => {const style = document.createElement('link'); style.rel = 'stylesheet'; style.href = new URL(name, import.meta.url).href;const ready = 'sheet' in style ? new Promise(resolve => { style.onload = style.onerror = resolve; }) : Promise.resolve();@@ -1227,7 +1228,7 @@ export function openEditor({api, app, from = null, panel = {}, components: givenhas_video: true, has_audio: true, path: work.video, missing: false, thumbnail: '/freevideo/library/thumbnail?' + new URLSearchParams({id})}});}} else {- let id; try { id = localStorage.getItem('fv-editor-last'); } catch {}+ let id; try { id = optionalText(localStorage.getItem('fv-editor-last')); } catch {}let draft; try { draft = globalThis.sessionStorage?.getItem('fv-editor-draft'); } catch { draft = lastDraft; }if (draft?.startsWith('draft:')) key = draft;else if (id) { record = await store.load(id); if (record) key = id; }diff --git a/web/optional_inputs.js b/web/optional_inputs.jsindex 4309150..240a3b0 100644--- a/web/optional_inputs.js+++ b/web/optional_inputs.js@@ -4,12 +4,14 @@// request. Keep each of them to a value the server accepts.const DEFAULTS = {refine_from: '', continue_from: '', frames: 0, first_frame_reference: false};-// Comfy turns a missing text value into the string "None" on its way to the server,-// so those spellings are an unset path here too. Mirrors optional_text in the engine.-function optionalText(value) {+// The words a script, an older workflow or String(null) leaves behind for "not given".+const EMPTY_WORDS = new Set(['none', 'null', 'undefined', 'nan']);++// Text of an optional input, or '' when it was not given.+export function optionalText(value) {if (typeof value !== 'string') return '';- const text = value.trim().toLowerCase();- return !text || ['none', 'null', 'undefined'].includes(text) ? '' : value;+ const text = value.trim();+ return !text || EMPTY_WORDS.has(text.toLowerCase()) ? '' : value;}export function optionalInputValue(name, value) {