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.
A reference video can be used without its own sound
Bowen Xue340041e83c42
diff --git a/freevideo_engine/comfy_assets.py b/freevideo_engine/comfy_assets.pyindex ecbf311..8d4f8a7 100644--- a/freevideo_engine/comfy_assets.py+++ b/freevideo_engine/comfy_assets.py@@ -75,7 +75,7 @@ def resolve_assets(serialized, input_directory):root = Path(input_directory).resolve()result = {}for row in rows:- if not isinstance(row, dict) or set(row) - {'file', 'role', 'enabled', 'cast', 'early_steps'}:+ if not isinstance(row, dict) or set(row) - {'file', 'role', 'enabled', 'cast', 'early_steps', 'sound'}:raise ValueError('Invalid media item')# The character an @ mention added the row for; a continued part keeps one picture per character.if 'cast' in row and (set(row['cast'] if isinstance(row['cast'], dict) else ('?',)) != {'id'}@@ -112,6 +112,11 @@ def resolve_assets(serialized, input_directory):from .media_request import validate_early_stepsvalidate_early_steps(dict(row, kind=kind))reference['early_steps'] = row['early_steps']+ if 'sound' in row:+ from .media_request import validate_sound+ validate_sound(dict(row, kind=kind))+ if not row['sound']:+ reference['sound'] = Falseresult.setdefault('references', []).append(reference)else:raise ValueError('Media role must be first, last or reference')diff --git a/freevideo_engine/comfy_library.py b/freevideo_engine/comfy_library.pyindex da63ee3..805b5dc 100644--- a/freevideo_engine/comfy_library.py+++ b/freevideo_engine/comfy_library.py@@ -1123,8 +1123,9 @@ def register():for item in query.getall('ref', [])[:32]:kind, _, name = item.partition(':')parts = Path(name).parts- if kind in ('image', 'video', 'audio') and parts and not Path(name).is_absolute() and '..' not in parts:- refs.append(dict(kind=kind, path=name))+ silent = kind == 'video-silent'+ if (kind in ('image', 'video', 'audio') or silent) and parts and not Path(name).is_absolute() and '..' not in parts:+ refs.append(dict(kind='video', path=name, sound=False) if silent else dict(kind=kind, path=name))if refs:# The generation path's own classification decides the tables (audio track in a video).value.update(references=refs, media_base=folder_paths.get_input_directory())diff --git a/freevideo_engine/media_encoding.py b/freevideo_engine/media_encoding.pyindex 5014737..4544a68 100644--- a/freevideo_engine/media_encoding.py+++ b/freevideo_engine/media_encoding.py@@ -182,7 +182,9 @@ def prepare(media, canvas, directory):pixels.flush()ref.update(pixels=str(target), frames=count, normalized_fps=24)used = count / 24.- soundtrack, longer_audio, _ = _audio(path, directory / ('reference-%02d-audio.npy' % index), limit / 24.)+ # The clip's own sound is a reference too, unless the request turned it off.+ soundtrack, longer_audio, _ = (None, False, None) if row.get('sound') is False else \+ _audio(path, directory / ('reference-%02d-audio.npy' % index), limit / 24.)longer = longer or longer_audioif soundtrack:ref['audio'] = soundtrackdiff --git a/freevideo_engine/media_request.py b/freevideo_engine/media_request.pyindex 256e3ff..be8d0ec 100644--- a/freevideo_engine/media_request.py+++ b/freevideo_engine/media_request.py@@ -55,7 +55,7 @@ def read(path):raise ValueError('Invalid ' + field + ' entry')if field != 'references' and 'early_steps' in entry:raise ValueError('early_steps is only allowed on video references')- allowed = {'path', 'kind', 'early_steps'} if field == 'references' else {'path', 'strength', 'alpha'}+ allowed = {'path', 'kind', 'early_steps', 'sound'} if field == 'references' else {'path', 'strength', 'alpha'}if set(entry) - allowed:raise ValueError('Unknown ' + field + ' fields')row = file_info(entry.get('path'))@@ -66,6 +66,10 @@ def read(path):if 'early_steps' in entry:validate_early_steps(entry)row['early_steps'] = entry['early_steps']+ if 'sound' in entry:+ validate_sound(entry)+ if not entry['sound']:+ row['sound'] = Falseelse:if Path(row['path']).suffix.lower() != '.safetensors':raise ValueError('LoRA requires safetensors; pickle adapters are not loaded')@@ -103,6 +107,13 @@ def validate_early_steps(row):raise ValueError('Video reference early_steps must be an integer >= 0')+def validate_sound(row):+ if row.get('kind') != 'video':+ raise ValueError('sound is only allowed on video references')+ if type(row['sound']) is not bool:+ raise ValueError('Video reference sound must be true or false')++def reference_stages(media):"""Active references at each boundary; zero-step inputs never reach an encoder."""refs = media.get('references', [])diff --git a/freevideo_engine/sampling_assets.py b/freevideo_engine/sampling_assets.pyindex 1ef47a8..0f96f9a 100644--- a/freevideo_engine/sampling_assets.py+++ b/freevideo_engine/sampling_assets.py@@ -176,7 +176,8 @@ def engine_task(media, base=None):"""The task the engine selects after encoding these references.A reference video counts as audio when it has an audio stream, exactly as- the encoder decides; tables therefore match before the request starts.+ the encoder decides, unless the request turned that video's sound off;+ tables therefore match before the request starts."""from .media_request import task_fortask = task_for(media)@@ -186,7 +187,7 @@ def engine_task(media, base=None):for ref in media.get('references', []):visual |= ref['kind'] in ('image', 'video')audio |= ref['kind'] == 'audio'- if ref['kind'] == 'video' and not audio:+ if ref['kind'] == 'video' and not audio and ref.get('sound') is not False:path = Path(ref['path'])if base is not None and not path.is_absolute():path = Path(base) / pathdiff --git a/web/capability_view.js b/web/capability_view.jsindex 78139bb..d0c01f1 100644--- a/web/capability_view.js+++ b/web/capability_view.js@@ -54,7 +54,7 @@ export function capabilityContext(node, state) {const source = assets[item.assetIndex] || {}, row = {kind: item.kind};if (item.kind !== 'audio') { row.width = source.width; row.height = source.height; }if (item.kind !== 'image') row.seconds = source.seconds;- if (item.kind === 'video' && positive(source.audio_seconds)) row.audio_seconds = source.audio_seconds;+ if (item.kind === 'video' && item.sound !== false && positive(source.audio_seconds)) row.audio_seconds = source.audio_seconds;return row;});const audio = refs.some((r, i) => r.kind === 'audio' || positive(rows[i].audio_seconds));diff --git a/web/freevideo.js b/web/freevideo.jsindex 25ba0a3..d8ca046 100644--- a/web/freevideo.js+++ b/web/freevideo.js@@ -332,15 +332,23 @@ function mediaPanel(node, mount = null) {preview.controls = true; preview.preload = "metadata"; if (kind === "video") { preview.muted = true; preview.playsInline = true; }card.append(preview);}+ let showLength = () => {};+ if (kind === "video") {+ const sound = el("label", undefined, "fv-sound"); const box = el("input"); box.type = "checkbox"; box.checked = row.sound !== false;+ box.onchange = () => { if (box.checked) delete rows[index].sound; else rows[index].sound = false; showLength(); update(rows); };+ sound.append(box, el("span", text("Use the video's sound", "使用视频声音"))); card.append(sound);+ }if (kind !== "image") {// References are cut to the generated length (at most 15 s); say so before the run.+ // A video used without its sound has no audio to cut.const length = el("div", "", "fv-note"); length.hidden = true; card.append(length);- preview.onloadedmetadata = () => {- if (!(preview.duration > 15.05) || !Number.isFinite(preview.duration)) return;- length.textContent = text(`Audio length: ${preview.duration.toFixed(1)} s; uses up to the first 15 s within the video length.`,+ showLength = () => {+ const long = preview.duration > 15.05 && Number.isFinite(preview.duration);+ length.hidden = !long || row.sound === false || rows[index]?.sound === false;+ if (long) length.textContent = text(`Audio length: ${preview.duration.toFixed(1)} s; uses up to the first 15 s within the video length.`,`音频长 ${preview.duration.toFixed(1)} 秒,最多取前 15 秒且不超过视频时长。`);- length.hidden = false;};+ preview.onloadedmetadata = () => showLength();}const controls = el("div", undefined, "fv-row");const move = delta => { const target = index + delta; if (target < 0 || target >= rows.length) return; [rows[index], rows[target]] = [rows[target], rows[index]]; update(rows); };@@ -357,7 +365,7 @@ function mediaPanel(node, mount = null) {serialized.serializeValue = () => {if (node.isUploading) throw new Error(text("Wait for media uploads to finish before running", "请等待素材上传完成后再生成"));// The run takes only what it uses (and which character a picture belongs to); the editing data of a picture stays in the workflow.- try { return JSON.stringify(read().map(({file, role, enabled, cast}) => ({file, role, enabled, ...(typeof cast?.id === 'string' && cast.id ? {cast: {id: cast.id}} : {})}))); } catch { return serialized.value; }+ try { return JSON.stringify(read().map(({file, role, enabled, cast, sound}) => ({file, role, enabled, ...(sound === false && mediaKindOrNull(file) === 'video' ? {sound: false} : {}), ...(typeof cast?.id === 'string' && cast.id ? {cast: {id: cast.id}} : {})}))); } catch { return serialized.value; }};async function upload(files) {if (node.isUploading || !files.length) return;diff --git a/web/image_editor.css b/web/image_editor.cssindex 52e0ffc..a9369f1 100644--- a/web/image_editor.css+++ b/web/image_editor.css@@ -315,3 +315,4 @@ button.fv-ie-size:hover{background:var(--fv-hover);color:var(--fv-ink)}border-radius:var(--fv-r-sm);background:color-mix(in srgb,var(--fv-warning) 9%,transparent);color:var(--fv-ink);font-size:var(--fv-micro)}.fv-panel .fv-shape-note span{flex:1 1 180px}.fv-panel .fv-shape-note button{min-height:26px;padding:2px 10px}+.fv-panel .fv-sound{display:flex;align-items:center;gap:6px;margin:0 0 8px;font-size:var(--fv-micro);cursor:pointer}diff --git a/web/prompt_references.js b/web/prompt_references.jsindex dcc4f36..48cd4cd 100644--- a/web/prompt_references.js+++ b/web/prompt_references.js@@ -38,7 +38,8 @@ export function referenceItems(node) {const kind = referenceKind(row.file);if (!kind) throw new Error('invalid_media');const item = {key: `file:${media.id}:${row.file}:${occurrence}`, kind, file: row.file,- name: row.cast?.name || row.file.split('/').pop(), assetIndex: rows.indexOf(row)};+ name: row.cast?.name || row.file.split('/').pop(), assetIndex: rows.indexOf(row),+ ...(row.sound === false && kind === 'video' ? {sound: false} : {})};if (row.role === 'reference') refs.push(item);else if (kind === 'image' && ['first','last'].includes(row.role) && !anchors[row.role]) anchors[row.role] = item;else throw new Error('invalid_media');diff --git a/web/request_assets.js b/web/request_assets.jsindex 31eec2c..8aa02df 100644--- a/web/request_assets.js+++ b/web/request_assets.js@@ -27,7 +27,7 @@ export function enabledLoras(start, {upstream, widget, value}) {// Reference files as `kind:file`, so generation's own rule can tell whether a video has audio.// A reference that is not a file in the input folder makes the task unknowable here: send none.export function referenceFiles(refs) {- return refs.length && refs.every(r => typeof r.file === 'string' && r.kind) ? refs.map(r => `${r.kind}:${r.file}`) : [];+ return refs.length && refs.every(r => typeof r.file === 'string' && r.kind) ? refs.map(r => `${r.kind === 'video' && r.sound === false ? 'video-silent' : r.kind}:${r.file}`) : [];}// Keep the extension and the end of a long file name; shorten the middle.