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.
Extend on a result or a saved video opens the editing view with a draft part ready
Bowen Xue9cdcf43649fb
diff --git a/web/autopilot.js b/web/autopilot.jsindex 4cfe7d0..c3829b4 100644--- a/web/autopilot.js+++ b/web/autopilot.js@@ -5,7 +5,7 @@ import { about, agentChat, jobName } from './autopilot_chat.js';import { openEditorView } from './editor_loader.js';import { closeDialog } from './motion.js';import { openSetup } from './setup.js';-import { extendVideo, openStudio, showNodes } from './studio.js';+import { openExtendEditor, openStudio, showNodes } from './studio.js';import { viewChanged, viewSwitch } from './view_navigation.js';import { wordmark } from './wordmark.js';@@ -45,9 +45,9 @@ export function openAutopilotView(node, {studio = null} = {}) {// Leaving for another view waits until this page has closed, so the view underneath is never covered twice.const closed = () => dialog.open ? new Promise(done => { dialog.addEventListener('close', done, {once: true}); closeDialog(dialog); }) : null;const chat = agentChat(t, api, {shown: inSight,- // A finished video opens as its work in Creations. Continuing it there belongs to the studio, so this page gives way first.+ // Creations continues the work on the editor timeline; this page gives way first.open: async job => (await import('./library.js')).openLibrary(t, {selectedWork: job.work, back: t('Back to chat', '返回对话'),- extend: async record => { await closed(); return extendVideo(record, node); }}),+ extend: async (record, options) => { await closed(); return openExtendEditor(record, node, {studio, ...options}); }}),edit: job => leave(() => openEditorView(node, {studio: studio?.open ? studio : undefined, work: {id: job.work, video: `FreeVideo/${job.work}/video.mp4`, geometry: {width: job.width, height: job.height, seconds: job.seconds}}})),changed: view => { last = view; show(); }});// With no agent the card stands alone in the middle. Once one has connected the conversation stays, also afterdiff --git a/web/editor.js b/web/editor.jsindex 2014834..a119d60 100644--- a/web/editor.js+++ b/web/editor.js@@ -141,7 +141,7 @@ export function openEditor({api, app, from = null, panel = {}, components: giventracksHost.inert = genHost.inert = true; title.disabled = true;// CSS delays the pending indication; fast opens stay at full opacity.tracksHost.classList.add('fv-ed-pending'); genHost.classList.add('fv-ed-pending');- let discardOnSwitch = false, initialSelection = null, offerInitial = null;+ let discardOnSwitch = false, initialSelection = null, offerInitial = null, extendEntry = null;let viewKey = null, viewReady = false;let library = null, closing = false, closePromise = null, exportSnapshot = null, lastSeed = null, projectEpoch = 0;let disposed = false, suppressSave = false, savedContent = '', initializing = true, tracks = null, genbar = null, adjustPanel = null, exportStatus = null, pointerEditing = false, deferredStamp = null;@@ -199,7 +199,7 @@ export function openEditor({api, app, from = null, panel = {}, components: givenconst store = createEditorStore(api, {t, notify, standIn: given?.generationStandIn, onGenerationReady: ready => {if (disposed) return;generationAsked = true; genHost.hidden = !ready; element.dataset.generationReady = String(ready);- settleGenbar(); if (ready) offerInitial?.();+ settleGenbar(); if (ready) { offerInitial?.(); extendEntry?.(); }tracks?.refresh?.(); genbar?.update(mostRecentJob ? barJob(jobStatuses.get(mostRecentJob)) : null);updateTransport(); adjustPanel?.update();}});@@ -332,7 +332,7 @@ export function openEditor({api, app, from = null, panel = {}, components: givenviewKey = record.id || key || 'draft:' + (globalThis.crypto?.randomUUID?.() || `${Date.now()}-${Math.random()}`);let remembered = editorViews.get(viewKey);if (!remembered) try { remembered = JSON.parse(localStorage.getItem(viewPrefix + viewKey)); } catch {}- initialSelection = offerInitial = null;+ initialSelection = offerInitial = extendEntry = null;projectEpoch++;player.pause(); for (const stop of jobWatchers.values()) stop(); jobWatchers.clear(); jobStatuses.clear(); progress.clear(); runProgress.clear(); progressConnection?.reset();mostRecentJob = null; genbar?.update(null); queue.reset(record); stopExport?.(); stopExport = null; exportStatus = exportSnapshot = null; exportButton.textContent = t('Export', '导出');@@ -610,10 +610,10 @@ export function openEditor({api, app, from = null, panel = {}, components: given// A sound-only export is not a work: it opens as a file the browser plays and can save.if (value.only === 'sound') { if (value.url) window.open(mediaURL(api, value.url), '_blank', 'noopener'); return; }const module = await import('./library.js');- module.openLibrary(t, {selectedWork: value.work, extend: async record => {+ module.openLibrary(t, {selectedWork: value.work, extend: async (record, options) => {if (await handle.close() === false) throw new Error(saveWarning.textContent);await onView('studio');- return (await import('./studio.js')).extendVideo(record);+ return (await import('./studio.js')).openExtendEditor(record, undefined, options);}});}function updateExport(value) {@@ -914,6 +914,29 @@ export function openEditor({api, app, from = null, panel = {}, components: given}for (const [id, value] of progress) tracks.setProgress(id, value);tracks.setScrollLeft(editorViews.get(viewKey)?.scrollLeft);+ if (from?.work && from.extend) {+ const id = from.work.id || from.work.video?.replace(/^FreeVideo\//, '').replace(/\/video\.mp4$/, '');+ const epoch = projectEpoch;+ // Selects the work and, when nothing follows it yet, adds one minimum draft. Runs once; when the+ // generation probe failed this time it runs after a later probe succeeds.+ const enter = (select = true) => {+ if (closing || disposed || epoch !== projectEpoch) return true;+ const clip = state.record.tracks[0].clips.findLast(clip => clip.source?.kind === 'work' && clip.source.id === id);+ if (!clip) return true;+ // Coming back to a work that already has parts after it selects the waiting draft instead of adding another.+ const edge = clip.start + clip.frames;+ const after = state.record.tracks[0].clips.filter(other => other.id !== clip.id && other.start >= edge);+ const waiting = after.find(other => other.pending === 'draft');+ if (select) state.select({kind: 'clip', ids: model.pair(state.record, (waiting || clip).id).map(member => member.id)});+ if (after.length || !clip.extend || !clip.source || store.sources.get(sourceKey(clip.source))?.missing) return true;+ if (!store.generationAvailable) return false;+ const spare = Math.min(...model.pair(state.record, clip.id).map(member => member.length - member.in - member.frames));+ tracks.extendClip(clip.id, spare + model.RULES.minSeconds * model.FPS, {silent: true});+ return true;+ };+ await store.generationReady();+ if (!enter() && !closing && !disposed) extendEntry = () => { if (enter(false) || closing || disposed) extendEntry = null; };+ }})().catch(error).finally(() => {// Every exit (including close and partial failure) settles readiness.// After a completed start the saved baseline is already set; edits made since must stay unsaved.diff --git a/web/editor_entry.js b/web/editor_entry.jsindex 8208177..9d2926e 100644--- a/web/editor_entry.js+++ b/web/editor_entry.js@@ -15,7 +15,7 @@ function editorPanel(node) {return {node: String(node.id), prompt: value.output, extra_data: {extra_pnginfo: {workflow: value.workflow || {}}}};}};}-export function openEditorView(node, {studio, work = null} = {}) {+export function openEditorView(node, {studio, work = null, extend = false} = {}) {studio?.querySelectorAll('video,audio').forEach(media => media.pause());const panel = editorPanel(node);const progressElement = studio?.querySelector('.fv-generation-progress');@@ -27,7 +27,7 @@ export function openEditorView(node, {studio, work = null} = {}) {return number ? {percent: Number(number[1])} : {percent: 0};};}- const handle = openEditor({api, app, panel, from: work ? {work} : null, onView(view) {+ const handle = openEditor({api, app, panel, from: work ? {work, ...(extend ? {extend: true} : {})} : null, onView(view) {if (view === 'nodes') showNodes(node, studio);else if (view === 'autopilot') openAutopilot(node, {studio});else if (studio?.open) viewChanged('studio', node);diff --git a/web/editor_loader.js b/web/editor_loader.jsindex 8221aea..3b2bc61 100644--- a/web/editor_loader.js+++ b/web/editor_loader.js@@ -5,8 +5,10 @@ import {app} from '../../scripts/app.js';export async function openEditorView(node, options) {try {const entry = await import('./editor_entry.js');+ if (options?.isCurrent?.() === false) return null;return entry.openEditorView(node, options);} catch (error) {+ if (options?.isCurrent?.() === false) return null;console.warn('FreeVideo edit view:', error);const language = new URLSearchParams(location.search).get('freevideo_lang');const cn = language === 'zh' || (language !== 'en' && String(navigator.language || '').toLowerCase().startsWith('zh'));diff --git a/web/editor_tracks.js b/web/editor_tracks.jsindex efde6c3..c0a821c 100644--- a/web/editor_tracks.js+++ b/web/editor_tracks.js@@ -212,6 +212,19 @@ export function createTracks(host, {state, sources = {}, t = en => en, actions =actions.editError?.(error); return false;}}+ function extendClip(id, frames, {silent = false} = {}) {+ if (disposed || actions.generationAvailable?.() === false) return false;+ let next;+ try { next = model.extendClip(state.record, id, frames, actions.generationLimits?.() || {}); }+ catch (error) {+ if (!(error instanceof model.EditError)) throw error;+ if (!silent) actions.editError?.(error);+ return false;+ }+ const ids = next.tracks[0].clips.filter(clip => clip.pending === 'draft' && !model.find(state.record, clip.id))+ .flatMap(clip => model.pair(next, clip.id).map(member => member.id));+ return attempt(t('Extend', '拉长'), () => next, ids.length ? {selectionAfter: {kind: 'clip', ids}} : undefined);+ }function position(node, start, frames) {node.style.left = `${pixels(start)}px`; node.style.width = `${Math.max(2, pixels(frames))}px`;}@@ -840,18 +853,8 @@ export function createTracks(host, {state, sources = {}, t = en => en, actions =else if (finished.type === 'plannedBoundary') attempt(t('Resize parts', '调整段长'), record => model.resizePlannedBoundary(record, finished.id, finished.neighbor.clip.id, result.frame, actions.generationLimits?.()));else if (result.kind === 'planned') attempt(t('Resize', '改长短'), record => model.resizePlanned(record, finished.id, finished.edge, result.frame, actions.generationLimits?.()));else if (result.kind === 'extend') {- if (actions.generationAvailable?.() === false) return;const frames = result.frame - finished.clip.start - finished.clip.frames + result.frames;- let next = null;- try { next = model.extendClip(state.record, finished.id, frames, actions.generationLimits?.() || {}); }- catch (error) { if (!(error instanceof model.EditError)) throw error; actions.editError?.(error); }- if (next) {- // The new parts stay selected through undo and redo, so Generate stays usable.- const clip = model.find(next, finished.id), start = clip.start + clip.frames;- const ids = next.tracks[0].clips.filter(c => c.pending === 'draft' && c.start >= start && c.start < start + result.frames)- .flatMap(c => model.pair(next, c.id).map(member => member.id));- attempt(t('Extend', '拉长'), () => next, ids.length ? {selectionAfter: {kind: 'clip', ids}} : undefined);- }+ extendClip(finished.id, frames);} else attempt(t('Trim', '裁短'), record => model.trim(record, finished.id, finished.edge, result.frame));renderSelection();} finally { actions.gestureEnd?.(); }@@ -1097,7 +1100,7 @@ export function createTracks(host, {state, sources = {}, t = en => en, actions =showInsertion(null); insertion.classList.remove('fv-ed-blocked-insertion');}, 700);}- return {element, keyboard, menu, dismissPopup, flashBlocked, seekPlayhead,+ return {element, keyboard, menu, dismissPopup, flashBlocked, seekPlayhead, extendClip,setSnapping(enabled) {if (typeof enabled !== 'boolean') return {ok: false, reason: 'snapping'};setTransportSnapping(state, enabled); cachedPoints = allPoints(gesture?.ids || []);diff --git a/web/library.js b/web/library.jsindex adf7d66..b79f229 100644--- a/web/library.js+++ b/web/library.js@@ -2,6 +2,7 @@ import { api } from '../../scripts/api.js';import { closeDialog } from './motion.js';import { resultActions, previewBadge } from './result_actions.js';import { extendSourceExists } from './studio_extend.js';+import { topDialog } from './dialog_keys.js';const style = document.createElement('link');style.rel = 'stylesheet'; style.href = new URL('./library.css', import.meta.url).href; document.head.append(style);@@ -152,9 +153,11 @@ export function openLibrary(t, {upscale = null, selectedWork = null, extend = nudate.textContent = timestamp(row); geometry.textContent = dimensions(row);links.replaceChildren(resultActions(row, t, {extend: async saved => {+ const isCurrent = () => !disposed && dialog.open && dialog.dataset.closing !== 'true' && topDialog() === dialog && selected === saved.video;+ if (!isCurrent()) return;player?.pause();- const run = extend || (async record => (await import('./studio.js')).extendVideo(record));- try { const studio = await run(saved); dialog.close(); studio?.querySelector('.fv-prompt-editor textarea')?.focus({preventScroll: true}); }+ const run = extend || (async (record, options) => (await import('./studio.js')).openExtendEditor(record, undefined, options));+ try { const editor = await run(saved, {isCurrent}); if (editor && !disposed) { dialog.close(); editor.element?.focus({preventScroll: true}); } }catch (error) { notice.textContent = error.message; }},secondPass: row.preview && upscale ? () => secondPass(row) : null,diff --git a/web/result_actions.js b/web/result_actions.jsindex 12433ab..2bbe5f2 100644--- a/web/result_actions.js+++ b/web/result_actions.js@@ -1,7 +1,7 @@import { api } from '../../scripts/api.js';import { outputDownloadURL } from './output_download.js';import { shareButton } from './share.js';-import { EXTEND_ENTRY_OPEN, canExtend, extendText, extendSourceExists } from './studio_extend.js';+import { canExtend, extendText, extendSourceExists } from './studio_extend.js';const css = document.createElement('link');css.rel = 'stylesheet'; css.href = new URL('./result_actions.css', import.meta.url).href; document.head.append(css);@@ -115,7 +115,7 @@ export function resultActions(record, t, {diagnostic = null, secondPass = null,download.href = outputDownloadURL(api, record.video); download.download = '';bar.append(download);}- if (EXTEND_ENTRY_OPEN && extend && canExtend(record)) {+ if (extend && canExtend(record)) {const button = action('button', extendText(t, 'action'), 'extend', 'fv-action-secondary fv-action-extend');button.hidden = true;extendSourceExists(api, record).then(exists => { button.hidden = !exists; });diff --git a/web/studio.js b/web/studio.jsindex b779a97..eced36b 100644--- a/web/studio.js+++ b/web/studio.js@@ -1,4 +1,5 @@import { createErrorPanel, errorText, createErrorReport } from './error_panel.js';+import {topDialog} from './dialog_keys.js';import { app } from '../../scripts/app.js';import { api } from '../../scripts/api.js';import { openSetup } from './setup.js';@@ -190,6 +191,14 @@ export async function extendVideo(record, node = current?.node || app.graph?._noreturn openStudio(node, {extendFrom: await readExtendRecord(api, record)});}+export async function openExtendEditor(record, node = current?.node || app.graph?._nodes?.find(row => row.type === 'FreeVideoGenerate'),+ {studio = current?.node === node ? current?.dialog : undefined, isCurrent} = {}) {+ if (!node || isCurrent?.() === false) return null;+ const handle = await openEditorView(node, {studio, work: record, extend: true, isCurrent});+ await handle?.ready;+ return handle;+}+export function openStudio(node, {extendFrom = null} = {}) {if (current?.node === node && current.dialog.open) {if (extendFrom) current.enterExtend(extendFrom); else current.dialog.focus();@@ -541,7 +550,8 @@ export function openStudio(node, {extendFrom = null} = {}) {const previewCaption = el('span'), previewTools = el('div', null, 'fv-preview-tools');previewTools.append(previewCaption);previewTools.append(button(t('Creations', '作品'), () => {- stage.querySelector('video')?.pause(); openLibrary(t, {upscale: value => node.freevideoUpscaleResult(value), extend: saved => extendVideo(saved, node)});+ stage.querySelector('video')?.pause(); openLibrary(t, {upscale: value => node.freevideoUpscaleResult(value),+ extend: (saved, options) => openExtendEditor(saved, node, {studio: dialog, ...options})});})); previewHead.append(previewTools); output.append(previewHead);const previewSpace = el('div', null, 'fv-preview-space'); output.append(previewSpace);const stage = el('div', null, 'fv-stage');@@ -698,7 +708,8 @@ export function openStudio(node, {extendFrom = null} = {}) {const reported = progress.hasReport();const tipShowing = !!links.querySelector('.fv-report-tip:not(.fv-report-tip-leaving)');links.replaceChildren(resultActions(r, t, {diagnostic: reported ? downloadReport : null,- extend: async saved => { try { await extendVideo(saved, node); } catch (error) { resultActionFailed(error); } },+ extend: saved => openExtendEditor(saved, node, {studio: dialog,+ isCurrent: () => dialog.open && dialog.dataset.closing !== 'true' && topDialog() === dialog && result === r}),secondPass: r.preview ? secondPass(r) : null}));if (runButtonReady) updateExtendButton();// After a video finished just now, point at the report menu until thediff --git a/web/studio_extend.js b/web/studio_extend.jsindex c1e555d..840a5e4 100644--- a/web/studio_extend.js+++ b/web/studio_extend.js@@ -8,8 +8,8 @@ export const EXTEND_TEXT = Object.freeze({});export const extendText = (t, key) => t(...EXTEND_TEXT[key]);-// The saved video of a continuation holds only what it adds, so the result card and the library keep this entry-// closed until the joined whole video is made; the editor's own extension is unaffected.+// Only the legacy in-studio continuation entry waits for a joined whole video.+// Result cards and Creations continue on the editor timeline independently.export const EXTEND_ENTRY_OPEN = false;export function canExtend(record) {return Boolean(record?.video && /\.mp4$/i.test(record.video) && !record.preview