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.

Long-video part list shows and edits only each part's own events, and one save at a time

Bowen Xue752c009cb23d
diff --git a/freevideo_engine/chain_store.py b/freevideo_engine/chain_store.py
index de2c093..5722e14 100644
--- a/freevideo_engine/chain_store.py
+++ b/freevideo_engine/chain_store.py
@@ -206,9 +206,14 @@ def summary(record):
def detail(record):
- return dict(summary(record), blocks=deepcopy(record['blocks']), plan=deepcopy(record['plan']),
- generation_size={key: record['snapshot']['prompt'][record['node']]['inputs'].get(key)
- for key in ('width', 'height')})
+ value = dict(summary(record), blocks=deepcopy(record['blocks']), plan=deepcopy(record['plan']),
+ generation_size={key: record['snapshot']['prompt'][record['node']]['inputs'].get(key)
+ for key in ('width', 'height')})
+ if (record.get('split') or {}).get('state') == 'done':
+ # Split parts repeat words put there by code; the page lists and edits only each part's own.
+ from .prompt_vlm.rules import own_words
+ value['part_words'] = own_words([str(row['inputs'].get('text', '')) for row in record['blocks']])
+ return value
def save(directory, record):
diff --git a/freevideo_engine/prompt_vlm/rules.py b/freevideo_engine/prompt_vlm/rules.py
index e0efbf3..f0dfb48 100644
--- a/freevideo_engine/prompt_vlm/rules.py
+++ b/freevideo_engine/prompt_vlm/rules.py
@@ -616,6 +616,51 @@ def validate_split(text, value, *, strict=False):
return parts
+SOUND_SECTIONS = re.compile(r'\n\n(?:overall_soundscape|non_diegetic_music):')
+SENTENCE_END = '.。!!??'
+
+
+def own_words(texts):
+ """Where each split part's own events stand in its text: [start, end] in UTF-16 units, or None.
+
+ The continuation sentence, the shared description, subject definitions, LoRA trigger words and sound
+ sections are put there by code and are the same in every part; the page shows and edits only the rest.
+ The shared description is what the parts start with in common, up to a sentence end before a space.
+ """
+ starts, ends = [], []
+ for text in texts:
+ found = SOUND_SECTIONS.search(text)
+ ends.append(found.start() if found else len(text))
+ at = text.find(CONTINUE + ' ')
+ starts.append(at + len(CONTINUE) + 1 if at >= 0 else None)
+ # The opening part has no continuation sentence; what stands before it elsewhere comes first there too.
+ lead = next((texts[i][:at - len(CONTINUE) - 1] for i, at in enumerate(starts) if at is not None), None)
+ if lead is not None and starts and starts[0] is None and texts[0].startswith(lead):
+ starts[0] = len(lead)
+ known = [texts[i][at:ends[i]] for i, at in enumerate(starts) if at is not None and at <= ends[i]]
+ if len(known) < 2:
+ return [None] * len(texts)
+ common = known[0]
+ for words in known[1:]:
+ common = common[:next((i for i, (a, b) in enumerate(zip(common, words)) if a != b), min(len(common), len(words)))]
+ shared = next((k for k in range(len(common), 19, -1) if common[k - 1] in SENTENCE_END
+ and all(len(words) == k or words[k] == ' ' for words in known)), None)
+ if shared is None:
+ return [None] * len(texts)
+ def units(text, index):
+ return len(text[:index].encode('utf-16-le')) // 2
+ spans = []
+ for text, at, end in zip(texts, starts, ends):
+ if at is None or at > end or not text[at:end].startswith(common[:shared]):
+ spans.append(None)
+ continue
+ begin = at + shared + 1
+ # A part with nothing of its own shows the shared description it repeats.
+ spans.append([units(text, at), units(text, end)] if begin >= end
+ else [units(text, begin), units(text, end)])
+ return spans
+
+
def validate_parts(parts, value):
"""Worker output shape for a split job: one non-empty text per part."""
if (not isinstance(parts, list) or len(parts) != len(value['seconds'])
diff --git a/web/studio.js b/web/studio.js
index a03a98e..996f0dc 100644
--- a/web/studio.js
+++ b/web/studio.js
@@ -42,7 +42,7 @@ import { createFirstRunGuide } from './first_run_guide.js';
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, readChainResult, sumPartEstimates, singleRunSnapshot } from './studio_chain.js?v=20261018-redo';
+import { createStudioChain, chainPosition, chainParts, chainSplit, composePartText, readChainResult, sumPartEstimates, singleRunSnapshot } from './studio_chain.js?v=20261019-words';
import { createExtendState, extendText, extendSourceExists, readExtendRecord, extendSnapshot, mountExtendThumbnail, videoUnavailableText } from './studio_extend.js';
const languageOverride = typeof location !== 'undefined'
@@ -90,7 +90,8 @@ function createChainPartList(t, save, {onShow = () => {}, onHide = () => {}, red
const {part} = row, writing = editing === row;
row.element.dataset.state = part.editable ? 'pending' : part.state;
row.text.textContent = part.text;
- row.text.disabled = !part.editable;
+ // A part waits for its save to come back before it can be edited again, so two saves never cross.
+ row.text.disabled = !part.editable || row.saving != null;
if (!writing && row.editor) removeEditor(row);
// A note about a lost edit stays on its line until that part is done.
if (row.tag.dataset.kind === 'error' && part.state === 'done') row.tag.dataset.kind = '';
@@ -136,7 +137,7 @@ function createChainPartList(t, save, {onShow = () => {}, onHide = () => {}, red
try {
await save(row.part.id, value);
row.saving = null;
- if (rows.get(row.part.id) === row) flash(row, t('Saved', '已保存'), 'saved');
+ if (rows.get(row.part.id) === row) { draw(row); flash(row, t('Saved', '已保存'), 'saved'); }
} catch (error) {
row.saving = null;
if (rows.get(row.part.id) !== row) return;
@@ -146,7 +147,7 @@ function createChainPartList(t, save, {onShow = () => {}, onHide = () => {}, red
}
}
function open(row) {
- if (!row.part.editable || editing === row) return;
+ if (!row.part.editable || row.saving != null || editing === row) return;
if (editing) finish(editing, true);
editing = row; clearTimeout(timers.get(row.part.id)); timers.delete(row.part.id); tag(row, '');
const editor = row.editor = el('textarea', null, 'fv-chain-part-editor');
@@ -1123,7 +1124,7 @@ export function openStudio(node, {extendFrom = null} = {}) {
})); previewHead.append(previewTools); output.append(previewHead);
const previewSpace = el('div', null, 'fv-preview-space'); output.append(previewSpace);
// The preview keeps the size it has once the list is in; an opened part grows the column, which scrolls.
- const partList = createChainPartList(t, (block, text) => chainController.setText(block, text), {
+ const partList = createChainPartList(t, (block, text) => chainController.setText(block, composePartText(chainController.state, block, text)), {
onShow: () => { previewSpace.style.flex = `0 0 ${previewSpace.getBoundingClientRect().height}px`; },
onHide: () => { previewSpace.style.flex = ''; },
redo: block => { failure.clear(); return chainController.redo(block); },
diff --git a/web/studio_chain.js b/web/studio_chain.js
index 8f8288e..c6440c0 100644
--- a/web/studio_chain.js
+++ b/web/studio_chain.js
@@ -36,6 +36,17 @@ export function chainSplit(chain) {
const split = chain?.split;
return {writing: ['pending', 'running'].includes(split?.state), reason: split?.state === 'failed' ? split.reason || 'failed' : null};
}
+// A split part lists only its own events: the continuation sentence and the shared description the server
+// repeats in every part stay as they are around an edit (part_words: [start, end] of the part's own words).
+function ownWords(chain, index, text) {
+ const span = chain?.part_words?.[index];
+ return Array.isArray(span) && span.length === 2 && span.every(Number.isInteger)
+ && 0 <= span[0] && span[0] < span[1] && span[1] <= text.length ? span : null;
+}
+function ownText(chain, index, text) {
+ const span = ownWords(chain, index, text);
+ return span ? text.slice(...span) : text;
+}
// Once the video has ended, each part offers one way on: a stopped video continues from its first unfinished part,
// and a finished part, with every part before it done, can be made again as a new video.
const STOPPED = new Set(['failed', 'cancelled', 'interrupted']);
@@ -47,7 +58,7 @@ export function chainParts(chain) {
const joined = readChainResult(chain)?.joined, kept = Number.isInteger(chain?.output_blocks) ? chain.output_blocks : blocks.length;
let start = 0;
const starts = blocks.map(block => { const at = start; start = Number.isInteger(block.new_frames) && start != null ? start + block.new_frames : null; return at; });
- return blocks.map((block, index) => ({id: block.id, index, text: block.inputs?.text ?? '',
+ return blocks.map((block, index) => ({id: block.id, index, text: ownText(chain, index, block.inputs?.text ?? ''),
editable: !writing && block.state === 'pending' && block.prompt_id == null,
// The seconds this part adds to the video; a continuing part repeats the end of the one before it.
seconds: Math.max(1, Math.round((block.new_frames ?? block.inputs?.frames ?? 0) / FPS)),
@@ -56,6 +67,11 @@ export function chainParts(chain) {
action: !idle ? null : index === unfinished ? (STOPPED.has(chain.state) ? 'resume' : null)
: unfinished < 0 || index < unfinished ? 'redo' : null}));
}
+export function composePartText(chain, block, words) {
+ const index = (chain?.blocks || []).findIndex(row => row.id === block);
+ const text = chain?.blocks?.[index]?.inputs?.text ?? '', span = index < 0 ? null : ownWords(chain, index, text);
+ return span ? text.slice(0, span[0]) + words + text.slice(span[1]) : words;
+}
export function sumPartEstimates(plan, estimate) {
if (!plan || plan.count < 2 || typeof estimate !== 'function') return null;