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.
Editing view: a range stops at five parts, and a video refused for having too many shows the...
Bowen Xue3f7b1ababaf7
diff --git a/web/editor.js b/web/editor.jsindex 77e4723..6359778 100644--- a/web/editor.js+++ b/web/editor.js@@ -185,6 +185,11 @@ export function openEditor({api, app, from = null, panel = {}, components: givenconst code = value?.code || value?.message;if (['audio_prepare', 'speed_pending', 'speed_locked', 'speed'].includes(code)) return {ok: false, reason: code};if (code === 'unsupported') { genbar?.update(null); return; }+ if (code === 'chain_too_long') {+ const [en, zh] = (value.said || []).map(text => typeof text === 'string' && text ? text.slice(0, 200) : null);+ notify(t(en || 'This video can have up to 5 parts. Make it shorter.', zh || '这条视频最多 5 段,请缩短一些。'));+ return {ok: false, reason: code};+ }if (['busy', 'locked', 'text', 'audio_full', 'overlap', 'range'].includes(code)) {if (['locked', 'audio_full', 'overlap', 'range'].includes(code)) tracks?.flashBlocked?.(value.displayFrame);return {ok: false, reason: code};diff --git a/web/editor_model.js b/web/editor_model.jsindex f398589..8133a1c 100644--- a/web/editor_model.js+++ b/web/editor_model.js@@ -8,7 +8,7 @@ export const VERSION = 1;export const FPS = 24;export const RULES = Object.freeze({maxSeconds: 15, singleSeconds: 30, minSeconds: 2, tailSeconds: 5,step: 17, first: 5, overlap: 22,- maxTracks: 3, maxClips: 500, maxText: 8000});+ maxTracks: 3, maxClips: 500, maxText: 8000, maxParts: 5});// Slice and bound user text by Unicode code points, never UTF-16 halves.export const truncateText = (text, limit) => Array.from(text).slice(0, limit).join('');export const copyName = (name, suffix) => truncateText(name, RULES.maxText - Array.from(suffix).length) + suffix;@@ -596,6 +596,12 @@ function remember(clip, source = null) {}// The lengths one range is generated in, as planRange lays them out on empty tracks.export const partLengths = (frames, {maxSeconds = RULES.maxSeconds, maxFollowSeconds = maxSeconds} = {}) => segmentLengths(frames, maxSeconds, maxFollowSeconds);+// One video is generated in at most RULES.maxParts parts: the longest range that still fits.+export function maxRangeFrames(record, {start, maxSeconds = RULES.maxSeconds, maxFollowSeconds = maxSeconds}) {+ const before = trackBy(record, 'v1').clips.find(clip => end(clip) === start && clip.source && clip.extend && clip.in + clip.frames === clip.length);+ const follow = Math.floor(Math.min(RULES.maxSeconds, maxFollowSeconds)) * FPS;+ return (before ? follow : Math.floor(Math.min(RULES.maxSeconds, maxSeconds)) * FPS) + (RULES.maxParts - 1) * follow;+}// Manual boundaries use device limits, not the automatic fifteen-second preference.export function rangeParts(record, {start, frames, parts, maxSeconds = RULES.maxSeconds, maxFollowSeconds = maxSeconds}) {const before = trackBy(record, 'v1').clips.find(clip => end(clip) === start && clip.source && clip.extend && clip.in + clip.frames === clip.length);diff --git a/web/editor_store.js b/web/editor_store.jsindex 01cdb74..f41fde4 100644--- a/web/editor_store.js+++ b/web/editor_store.js@@ -458,6 +458,11 @@ export function createEditorStore(api, {t = en => en, notify = () => {}, onGenernotice('generate', 'Restart FreeVideo to generate.', '请重新启动 FreeVideo 后再生成。');return null;}+ if (response.status === 400) {+ // The server's own sentence for a video with too many parts is shown as it is.+ const body = await response.json().catch(() => null);+ if (body?.code === 'chain_too_long') throw Object.assign(new Error(body.code), {code: body.code, said: [body.error, body.error_zh]});+ }if (!response.ok) throw errorFor(response);return (await response.json())?.chain || null;},diff --git a/web/editor_tracks.js b/web/editor_tracks.jsindex c6d1f46..90ecf41 100644--- a/web/editor_tracks.js+++ b/web/editor_tracks.js@@ -238,6 +238,16 @@ export function createTracks(host, {state, sources = {}, t = en => en, actions =const end = Math.max(...items.map(item => item.clip.start + item.clip.frames));return {start, frames: end - start, tracks: [...new Set(items.map(item => item.track))]};}+ // A range cannot be drawn longer than one video may be; `fromEnd` keeps its end where it is.+ function capRange(selection, fromEnd = false) {+ const limits = actions.generationLimits?.();+ let most = model.maxRangeFrames(state.record, {...limits, start: selection.start});+ if (selection.frames <= most) return selection;+ if (!fromEnd) return {...selection, frames: most};+ const stop = selection.start + selection.frames;+ most = model.maxRangeFrames(state.record, {...limits, start: stop - most});+ return {...selection, start: stop - most, frames: most};+ }function rangeParts(selection, record = state.record) {return model.rangeParts(record, {...selection, ...actions.generationLimits?.()});}@@ -685,14 +695,14 @@ export function createTracks(host, {state, sources = {}, t = en => en, actions =const end = original.start + original.frames, at = Math.round(aligned.frame / model.FPS) * model.FPS;const start = gesture.edge === 'start' ? Math.min(end - 2 * model.FPS, at) : original.start;const stop = gesture.edge === 'end' ? Math.max(start + 2 * model.FPS, at) : end;- gesture.selection = {kind: 'range', start, frames: stop - start, tracks: original.tracks};+ gesture.selection = capRange({kind: 'range', start, frames: stop - start, tracks: original.tracks}, gesture.edge === 'start');}previewSelection = gesture.selection; showGuide(aligned.guide); renderSelection();hint(gesture.selection, event, false, gesture.type === 'rangeMove');if (gesture.type === 'rangeMove' && gesture.rangeBlocked) tooltip.hidden = true;} else if (gesture.type === 'range') {const aligned = snap(frame, points, state.zoom);- gesture.selection = rangeParameters(gesture.anchor, aligned.frame);+ gesture.selection = capRange(rangeParameters(gesture.anchor, aligned.frame), aligned.frame < gesture.anchor);previewSelection = gesture.selection; showGuide(aligned.guide);renderSelection(); hint(gesture.selection, event);} else if (gesture.type === 'move') {@@ -728,6 +738,7 @@ export function createTracks(host, {state, sources = {}, t = en => en, actions =if (error) tooltip.hidden = true;} else if (gesture.type === 'edge') {let result = edgeParameters(gesture.clip, gesture.edge, frame, points, state.zoom, {canExtend: actions.generationAvailable?.() !== false});+ if (result.kind === 'extend') result.frames = capRange({start: result.frame, frames: result.frames}).frames;if (result.kind === 'planned') {let preview;try { preview = model.resizePlanned(state.record, gesture.id, gesture.edge, result.frame, actions.generationLimits?.()); }