Skip to content

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.

Take back adding a long video to the queue while one is generating

Bowen Xuec80c1ac3b5d0
diff --git a/web/studio.css b/web/studio.css
index 360665d..ecbafad 100644
--- a/web/studio.css
+++ b/web/studio.css
@@ -222,6 +222,3 @@
.fv-lora-problem{grid-column:var(--lora-lead,2)/span 3;grid-row:4;display:flex;flex-direction:column;align-items:flex-start;gap:6px;font-size:var(--fv-micro)}.fv-lora-problem p{margin:0;color:var(--fv-danger)}.fv-lora-problem.fv-lora-partial{color:var(--fv-muted)}.fv-lora-problem[hidden]{display:none}.fv-lora-why summary{cursor:pointer;color:var(--fv-muted)}.fv-lora-why pre{margin:6px 0 0;white-space:pre-wrap;word-break:break-all;color:var(--fv-muted);font:inherit;font-family:ui-monospace,monospace}.fv-lora-row[data-unusable=true] select{color:var(--fv-muted)}
.fv-lora-row[data-unusable=true]{cursor:default}.fv-lora-row[data-unusable=true] :is(input[type=number],input[type=checkbox]){opacity:.45}.fv-lora-row[data-unusable=true] select{opacity:1}.fv-lora-row[data-unusable=true] :is(.fv-lora-trigger,.fv-lora-range){display:none}
-/* The queued count follows the part number; when the line is too narrow it wraps out of sight. */
-.fv-studio .fv-chain-position:has(.fv-chain-queued){display:flex;flex-wrap:wrap;column-gap:0;line-height:1.4;max-height:1.4em;overflow:hidden}
-.fv-studio .fv-chain-position .fv-chain-queued{white-space:pre}
diff --git a/web/studio.js b/web/studio.js
index 552ec4c..f419e9d 100644
--- a/web/studio.js
+++ b/web/studio.js
@@ -1099,11 +1099,6 @@ export function openStudio(node, {extendFrom = null} = {}) {
stage.append(stageMedia); previewSpace.append(stage);
const progress = createGenerationProgress(t, undefined, {compact: true, api}); stage.append(progress.element);
const chainLine = el('div', '', 'fv-muted fv-chain-position'); chainLine.hidden = true; progress.element.prepend(chainLine);
- // The queued count sits after the part number; a line too narrow for both keeps the part number only.
- const setChainLine = text => {
- const main = el('span', text), more = chainController?.waiting;
- chainLine.replaceChildren(main, ...(more ? [el('span', t(` · ${more} more queued`, ` · 另有 ${more} 条排队`), 'fv-chain-queued')] : []));
- };
progress.updateReport({report_id: node.freevideoReportId});
cleanup.push(() => progress.dispose());
cleanup.push(createPreviewScene(stage, progress.element, stageMedia));
@@ -1307,13 +1302,13 @@ export function openStudio(node, {extendFrom = null} = {}) {
},
}));
const queueController = studioQueues.get(node);
- let chainWasActive = false, stopNote = '';
+ let chainWasActive = false;
chainController = createStudioChain({api, node, onProgress: (message, chain) => {
const position = chainPosition(chain, message);
const joining = readChainResult(chain).joining, waiting = chain.state === 'queued' && message.phase === 'prepare';
- setChainLine(joining ? t('Joining the parts.', '正在接合各段。')
+ chainLine.textContent = joining ? t('Joining the parts.', '正在接合各段。')
: waiting ? t(`Waiting in queue · Part ${position.index + 1} of ${position.count}`, `正在排队 · 第 ${position.index + 1} 段,共 ${position.count} 段`)
- : t(`Part ${position.index + 1} of ${position.count}`, `第 ${position.index + 1} 段,共 ${position.count} 段`));
+ : t(`Part ${position.index + 1} of ${position.count}`, `第 ${position.index + 1} 段,共 ${position.count} 段`);
progress.element.querySelector('.fv-generation-label').hidden = joining || waiting;
progress.updateReport(message); showProgress(message);
},
@@ -1329,14 +1324,12 @@ export function openStudio(node, {extendFrom = null} = {}) {
partList.update(chain, active);
busy = active || Boolean(queueState?.running || queueState?.pending.length); queued = chain?.state === 'queued';
chainLine.hidden = !active;
- setChainLine(outcome?.joining ? t('Joining the parts.', '正在接合各段。')
- : t(`Part ${position.index + 1} of ${position.count}`, `第 ${position.index + 1} 段,共 ${position.count} 段`));
+ chainLine.textContent = outcome?.joining ? t('Joining the parts.', '正在接合各段。')
+ : t(`Part ${position.index + 1} of ${position.count}`, `第 ${position.index + 1} 段,共 ${position.count} 段`);
if (active && node.properties.freevideo_chain?.width) previewSize(node.properties.freevideo_chain.width, node.properties.freevideo_chain.height);
if (!active) { cancelling = false; hideProgress(); }
if (!active) progress.element.querySelector('.fv-generation-label').hidden = false;
if (chain?.state === 'cancelled') status.textContent = t('Cancelled', '已取消');
- // After a stop with videos queued the next one starts at once; its line says so until something else is done.
- if (stopNote) { status.dataset.error = 'false'; status.textContent = stopNote; }
resumeChain.hidden = !['cancelled', 'failed', 'interrupted'].includes(chain?.state);
queueActions.hidden = !active && !busy && resumeChain.hidden;
updateRunButton();
@@ -1446,15 +1439,15 @@ export function openStudio(node, {extendFrom = null} = {}) {
runMode = multiple || extension.source ? 'single'
: ['single', 'batch', 'loop'].includes(node.properties?.freevideo_run_mode) ? node.properties.freevideo_run_mode : runMode;
const chain = chainController?.state, position = chainPosition(chain);
- const chainReason = !chainController?.active || chainController.canQueue ? '' : readChainResult(chain)?.joining
+ const chainReason = !chainController?.active ? '' : readChainResult(chain)?.joining
? t('Joining parts…', '正在拼接…')
: chain?.state === 'queued' ? t('Queued…', '排队中…')
: t(`Generating part ${position.index + 1}…`, `正在生成第 ${position.index + 1} 段…`);
- generate.disabled = submitting || (chainController?.active && !chainController.canQueue) || lengthControl.blocked || (runMode === 'loop' && queueState?.looping);
+ generate.disabled = submitting || chainController?.active || lengthControl.blocked || (runMode === 'loop' && queueState?.looping);
generate.textContent = submitting ? t('Adding…', '正在添加…')
: chainReason || (runMode === 'batch' ? t(`Add ${count.value || '…'} videos`, `添加 ${count.value || '…'} 个视频`)
: runMode === 'loop' ? (queueState?.looping ? t('Looping', '循环中') : t('Start loop', '开始循环'))
- : busy ? t('Add to queue', '加入队列')
+ : busy ? t('Add to queue', '添加到队列')
: previewFirst.checked && !previewFirst.disabled ? t('Generate preview', '生成预览') : t('Generate video', '生成视频'));
generate.title = (lengthControl.blocked ? lengthControl.message : submitting ? t('Adding…', '正在添加…') : '');
for (const b of modeButtons) b.setAttribute('aria-pressed', String(b.dataset.mode === runMode));
@@ -1550,12 +1543,7 @@ export function openStudio(node, {extendFrom = null} = {}) {
if (cancelling) return;
try {
cancelling = true; updateRunButton();
- if (chainController.active) {
- stopNote = chainController.waiting > 0 ? t('Stopped. The next queued video is starting.', '已停止,队列中的下一条开始生成。') : '';
- await chainController.cancel(); cancelling = false; updateRunButton();
- if (stopNote) { status.dataset.error = 'false'; status.textContent = stopNote; }
- return;
- }
+ if (chainController.active) { await chainController.cancel(); cancelling = false; updateRunButton(); return; }
await syncQueue();
const id = queueController.state().running?.id;
if (!id) { cancelling = false; updateRunButton(); return; }
@@ -1591,7 +1579,7 @@ export function openStudio(node, {extendFrom = null} = {}) {
let held = null, accepted = false;
const onAccepted = () => { accepted = true; };
try {
- stopNote = ''; lastQueueError = null; failure.clear(); node.freevideoFailure = ''; node.freevideoFailureReport = null;
+ lastQueueError = null; failure.clear(); node.freevideoFailure = ''; node.freevideoFailureReport = null;
capturing = true; updateRunButton(); status.dataset.error = 'false'; runOptions.open = false;
lengthControl.freeze();
if ((!extension.source || prompt.value.trim()) && await enhancer.beforeGenerate() === false) return;
@@ -1616,10 +1604,8 @@ export function openStudio(node, {extendFrom = null} = {}) {
capturing = false;
for (const section of controls.querySelectorAll('.fv-section')) section.inert = false;
if (lengthPlan?.count > 1) {
- const waitingBefore = chainController.waiting;
const chain = await chainController.start(snapshot, lengthOptions, {onAccepted});
if (disposed) return;
- if (chain && chainController.waiting > waitingBefore) { status.dataset.error = 'false'; status.textContent = t('Added to the queue. It starts when the current video finishes.', '已加入队列,当前视频完成后自动开始。'); return; }
if (!chain) { if (source) throw new Error(extendText(t, 'unavailable')); lengthControl.fallback(); if (!seconds.reportValidity()) return;
await queueController.start(snapshot, {count: batchCount, repeat: chosenMode === 'loop', seedIndex, onAccepted}); }
} else await queueController.start(snapshot, {count: batchCount, repeat: chosenMode === 'loop', seedIndex, onAccepted});
diff --git a/web/studio_chain.js b/web/studio_chain.js
index 88b74c3..87cbeaa 100644
--- a/web/studio_chain.js
+++ b/web/studio_chain.js
@@ -3,7 +3,6 @@ import {buildChainRequest} from './length_plan.js?v=20261011-length';
export const CHAIN_PROPERTY = 'freevideo_chain';
const activeStates = new Set(['queued', 'running', 'cancelling']);
-const MAX_WAITING = 5;
const finite = value => typeof value === 'number' && Number.isFinite(value) && value >= 0;
const post = body => ({method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(body)});
@@ -56,17 +55,14 @@ export function singleRunSnapshot(snapshot, node, plan) {
export function createStudioChain({api, node, onState = () => {}, onProgress = () => {}, onResult = () => {},
onError = () => {}, pollMs = 2000, now = () => Date.now()}) {
- let chain = null, poller = null, disposed = false, epoch = 0, submitting = false, promoting = false;
- // Chains the server took while another was running; the next one is shown when the running one stops.
- const waiting = [];
+ let chain = null, poller = null, disposed = false, epoch = 0, submitting = false;
let previous = {}, lastMessage = {}, delivered = null, errorShown = null, corrected = false, etaAt = 0, lastIndex = -1;
const timers = new Set();
const clock = {now, setTimeout(fn, ms) { const id = setTimeout(() => { timers.delete(id); fn(); }, ms); timers.add(id); return id; },
clearTimeout(id) { clearTimeout(id); timers.delete(id); }};
function clearPolls() { for (const id of timers) clearTimeout(id); timers.clear(); }
function refresh() { clearPolls(); return poller?.poll(); }
- const running = () => activeStates.has(chain?.state) || chain?.output_state === 'joining';
- const active = () => submitting || running();
+ const active = () => submitting || activeStates.has(chain?.state) || chain?.output_state === 'joining';
async function json(path, options, allowMissing = false) {
const response = await api.fetchApi(path, options);
if (response.status === 404 && allowMissing) return null;
@@ -106,7 +102,6 @@ export function createStudioChain({api, node, onState = () => {}, onProgress = (
chain = value; onState(chain);
const result = readChainResult(chain);
if (active()) progress({}, fresh);
- else if (waiting.length) void promote();
if (result.error && errorShown !== result.error) {
errorShown = result.error; onError(Object.assign(new Error(result.error), {joining: chain.output_state === 'failed', ...chainPosition(chain)}));
}
@@ -121,24 +116,6 @@ export function createStudioChain({api, node, onState = () => {}, onProgress = (
}
return active();
}
- async function promote() {
- if (promoting || disposed) return;
- promoting = true;
- let again = false;
- try {
- while (waiting.length && !disposed && !running()) {
- const next = waiting[0];
- let value;
- try { value = (await json(chainRoute(next.id), {cache: 'no-store'}, true))?.chain; }
- catch { again = true; break; }
- waiting.shift();
- if (!value?.id || value.state === 'cancelled') continue;
- adopt(value, next.metadata); break;
- }
- } finally { promoting = false; }
- if (again && !disposed) clock.setTimeout(() => void promote(), 3000);
- else if (!disposed && chain) onState(chain);
- }
function watch(fresh = false) {
poller?.dispose(); clearPolls();
const id = chain.id, version = epoch;
@@ -158,10 +135,9 @@ export function createStudioChain({api, node, onState = () => {}, onProgress = (
const known = node.properties?.[CHAIN_PROPERTY]?.id;
const reply = await json('/freevideo/chains', undefined, true);
if (disposed || version !== epoch || chain) return;
- const mine = row => String(row.node) === String(node.id) && activeStates.has(row.state) && row.client_id && row.client_id === api.clientId;
- const found = reply?.chains?.find(row => String(row.node) === String(node.id) && (known ? row.id === known : mine(row)));
+ const found = reply?.chains?.find(row => String(row.node) === String(node.id) && (known ? row.id === known
+ : activeStates.has(row.state) && row.client_id && row.client_id === api.clientId));
if (!found) return;
- for (const row of reply.chains) if (row.id !== found.id && mine(row)) waiting.push({id: row.id, metadata: null});
const value = (await json(chainRoute(found.id), undefined, true))?.chain;
if (disposed || version !== epoch || chain || !value) return;
adopt(value);
@@ -201,12 +177,10 @@ export function createStudioChain({api, node, onState = () => {}, onProgress = (
}
recover();
return {
- get active() { return active(); }, get state() { return chain; }, get waiting() { return waiting.length; },
- // A chain that is running does not stop the next one from being added behind it.
- get canQueue() { return !disposed && !submitting && running() && chain?.state !== 'cancelling' && waiting.length < MAX_WAITING; },
+ get active() { return active(); }, get state() { return chain; },
async start(snapshot, options, {onAccepted = null} = {}) {
- if (disposed || submitting || (running() && waiting.length >= MAX_WAITING)) throw new Error('chain_busy');
- submitting = true;
+ if (disposed || active()) throw new Error('chain_busy');
+ submitting = true; epoch++;
try {
const body = buildChainRequest(options, {node: node.id, prompt: snapshot.output,
extra_data: {extra_pnginfo: {workflow: snapshot.workflow || {}}}, ...(api.clientId ? {client_id: api.clientId} : {})});
@@ -215,10 +189,7 @@ export function createStudioChain({api, node, onState = () => {}, onProgress = (
if (!value.id) throw new Error('chain_missing');
onAccepted?.();
const inputs = snapshot.output[String(node.id)].inputs;
- const metadata = {width: inputs.width, height: inputs.height, seconds: options.seconds};
- submitting = false;
- if (running() && chain.id !== value.id) { waiting.push({id: value.id, metadata}); onState(chain); return value; }
- epoch++; adopt(value, metadata);
+ submitting = false; adopt(value, {width: inputs.width, height: inputs.height, seconds: options.seconds});
return value;
} finally { submitting = false; }
},