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.

Say what a queued video waits for and when it starts

Bowen Xuecf126aa14b3b
diff --git a/freevideo_engine/chain_runner.py b/freevideo_engine/chain_runner.py
index bf37a1f..4d400c0 100644
--- a/freevideo_engine/chain_runner.py
+++ b/freevideo_engine/chain_runner.py
@@ -195,8 +195,26 @@ class ChainRunner:
value['mine'] = record['client_id'] == client_id
if record['state'] in store.ACTIVE and block is not None:
value['current'] = block['id']
+ waiting = self._waiting(record)
+ if waiting is not None:
+ value['waiting'] = waiting
return value
+ def _waiting(self, record):
+ """What a chain that has not started waits for: how many chains are ahead and, for a single
+ one, the time it has left (None while that is unknown)."""
+ if record['state'] != 'queued' or record['id'] == self.active or record['id'] not in self.queue:
+ return None
+ ahead = [] if self.active is None else [self.active]
+ for identity in self.queue[:self.queue.index(record['id'])]:
+ row = self.records.get(identity)
+ if row is not None and row['state'] == 'queued' and identity not in ahead:
+ ahead.append(identity)
+ if not ahead:
+ return None
+ remaining = _number(self.progress_values.get(ahead[0], {}).get('remaining_seconds')) if len(ahead) == 1 and ahead[0] == self.active else None
+ return {'ahead': len(ahead), 'remaining_seconds': None if remaining is None or remaining < 0 else remaining}
+
def _depths(self, record, seen=()):
"""Parts each block of `record` continues through, itself included (a block with no source is the
first part). A source that is an existing video counts the parts that video was made of, as far
diff --git a/web/chain_support.js b/web/chain_support.js
index 8101415..ee82d2c 100644
--- a/web/chain_support.js
+++ b/web/chain_support.js
@@ -4,6 +4,17 @@ import { effortFor, effortsFrom } from './sampling_effort.js';
const clockDefault = {now: () => Date.now(), setTimeout: (fn, ms) => setTimeout(fn, ms), clearTimeout: id => clearTimeout(id)};
export const chainRoute = (id, action) => '/freevideo/chain' + (id ? '/' + encodeURIComponent(id) : '') + (action ? '/' + action : '');
+// The line for a chain that waits behind others: its own time when one video is ahead and its time left is known.
+export function waitingText(waiting, t) {
+ const ahead = waiting?.ahead, left = waiting?.remaining_seconds;
+ if (!Number.isInteger(ahead) || ahead < 1) return t('Queued', '排队中');
+ if (ahead > 1) return t(`Queued · ${ahead} ahead`, `排队中 · 前面还有 ${ahead} 个`);
+ if (!Number.isFinite(left) || left < 0) return t('Queued · waiting for the previous one', '排队中 · 等前一个完成');
+ const time = left < 60 ? t(`about ${Math.max(1, Math.ceil(left))} s`, `约 ${Math.max(1, Math.ceil(left))} 秒`)
+ : t(`about ${Math.ceil(left / 60)} min`, `约 ${Math.ceil(left / 60)} 分钟`);
+ return t(`Queued · starts in ${time}`, `排队中 · ${time}后开始`);
+}
+
// No overlapping polls and no delivery after disposal, including a slow response.
export function createPoller(read, deliver, {clock = clockDefault, interval = 2000, onError = () => {}} = {}) {
let active = true, timer = null, running = null;
diff --git a/web/editor_genbar.js b/web/editor_genbar.js
index 59cf5e7..19d515d 100644
--- a/web/editor_genbar.js
+++ b/web/editor_genbar.js
@@ -4,6 +4,7 @@ import {createEditorReferences} from './editor_references.js';
import {createExpandButton} from './editor_expand.js';
import {createRequestAssets} from './request_assets.js';
import {issueButton} from './issue_button.js';
+import {waitingText} from './chain_support.js';
const el = (tag, cls, text) => { const e = document.createElement(tag); if (cls) e.className = cls; if (text != null) e.textContent = text; return e; };
export const timeEstimate = (seconds, t) => seconds == null ? '' : seconds < 60
? t(`about ${Math.max(1, Math.ceil(seconds))} s`, `约 ${Math.max(1, Math.ceil(seconds))} 秒`)
@@ -137,7 +138,7 @@ export function createEditorGenbar(host, {state, t, actions, text = ''}) {
cancel.hidden = !busy || opening || cancelling || !held && finalization?.cancelable === false; resume.hidden = !stopped;
const waiting = status?.state === 'queued' && !(status.blocks || []).some(block => ['queued', 'running'].includes(block.state) && block.prompt_id);
if (opening) hint.textContent = t('Starting…', '正在开始…');
- else if (held || waiting) hint.textContent = t('Queued', '排队中');
+ else if (held || waiting) hint.textContent = waiting && !held ? waitingText(status.waiting, t) : t('Queued', '排队中');
else if (cancelling) hint.textContent = t('Stopping…', '正在停止…');
else if (running) {
const blocks = status?.blocks || [], done = blocks.filter(block => block.state === 'done').length;
diff --git a/web/studio.css b/web/studio.css
index 2308945..22482d4 100644
--- a/web/studio.css
+++ b/web/studio.css
@@ -97,6 +97,7 @@
.fv-studio .fv-stage[data-short=true] .fv-generation-heading{flex-direction:row;gap:16px}
.fv-studio .fv-stage[data-short=true] .fv-generation-count{font-size:20px}
.fv-studio .fv-stage[data-short=true] .fv-generation-times{display:none}
+.fv-studio .fv-stage .fv-generation-progress.fv-generation-waiting .fv-generation-count,.fv-studio .fv-stage .fv-generation-progress.fv-generation-waiting .fv-generation-times{display:none}
.fv-studio .fv-stage-media video{animation:fv-preview-appear .55s ease}
@keyframes fv-preview-appear{from{opacity:0}to{opacity:1}}
/* One metrics card; the 1 px gaps draw the dividers in any column count. */
diff --git a/web/studio.js b/web/studio.js
index 950b870..841e9e6 100644
--- a/web/studio.js
+++ b/web/studio.js
@@ -44,6 +44,7 @@ import { SHOWCASE_SCENE } from './entry_showcase.js';
import { createStudioLength, savedSeconds } from './studio_length.js?v=20261011-length';
import { firstFrameRow } from './first_frame_row.js';
import { createStudioChain, chainPosition, chainParts, chainSplit, composePartText, readChainResult, sumPartEstimates, singleRunSnapshot } from './studio_chain.js?v=20261019-words';
+import { waitingText } from './chain_support.js';
import { createExtendState, extendText, extendSourceExists, readExtendRecord, extendSnapshot, mountExtendThumbnail, videoUnavailableText } from './studio_extend.js';
const languageOverride = typeof location !== 'undefined'
@@ -1388,9 +1389,10 @@ export function openStudio(node, {extendFrom = null} = {}) {
const position = chainPosition(chain, message);
const joining = readChainResult(chain).joining, waiting = chain.state === 'queued' && message.phase === 'prepare';
setChainLine(joining ? t('Joining the parts.', '正在接合各段。')
- : waiting ? t(`Waiting in queue · Part ${position.index + 1} of ${position.count}`, `正在排队 · 第 ${position.index + 1} 段,共 ${position.count} 段`)
+ : waiting ? (chain.waiting ? waitingText(chain.waiting, t) : 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} 段`));
progress.element.querySelector('.fv-generation-label').hidden = joining || waiting;
+ progress.element.classList.toggle('fv-generation-waiting', waiting);
progress.updateReport(message); showProgress(message);
},
onState: chain => {
@@ -1409,7 +1411,7 @@ export function openStudio(node, {extendFrom = null} = {}) {
: 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 (!active) { progress.element.querySelector('.fv-generation-label').hidden = false; progress.element.classList.remove('fv-generation-waiting'); }
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; }
@@ -1552,7 +1554,7 @@ export function openStudio(node, {extendFrom = null} = {}) {
const chainWait = Boolean(chainController?.active && (!chainController.canQueue || !multiple));
const chainReason = !chainWait ? '' : readChainResult(chain)?.joining
? t('Joining parts…', '正在拼接…')
- : chain?.state === 'queued' ? t('Queued…', '排队中…')
+ : chain?.state === 'queued' ? (chain.waiting ? waitingText(chain.waiting, t) : t('Queued…', '排队中…'))
: t(`Generating part ${position.index + 1}…`, `正在生成第 ${position.index + 1} 段…`);
generate.disabled = submitting || chainWait || lengthControl.blocked || (runMode === 'loop' && queueState?.looping);
generate.textContent = submitting ? t('Adding…', '正在添加…')