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.
Editor: addSubtitles writes subtitle lines in one undoable edit
Bowen Xue1d0e64a22efc
diff --git a/web/editor.js b/web/editor.jsindex 4972a2e..4bf7cfc 100644--- a/web/editor.js+++ b/web/editor.js@@ -103,6 +103,16 @@ export function openEditor({api, app, from = null, panel = {}, components: givenheaderActions.append(exportBox, button(t('Settings', '设置'), openSetup, 'fv-quiet'));top.append(brand, navigation, headerActions);const menu = el('div', 'fv-ed-name-menu'); menu.hidden = true; menu.setAttribute('role', 'menu');+ // Up and Down move through the name box and the items; Home and End go to either end.+ menu.onkeydown = event => {+ if (event.defaultPrevented || event.isComposing || !['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key)+ || (['Home', 'End'].includes(event.key) && event.target.matches('input'))) return;+ const items = [...menu.querySelectorAll('input, [role=menuitem], [role=menuitemradio]')].filter(node => !node.disabled && !node.closest('[hidden]'));+ if (!items.length) return;+ event.preventDefault(); event.stopPropagation();+ const at = items.indexOf(document.activeElement), step = event.key === 'ArrowDown' ? 1 : -1;+ items[event.key === 'Home' ? 0 : event.key === 'End' ? items.length - 1 : at < 0 ? 0 : (at + step + items.length) % items.length].focus();+ };const saveWarning = el('span', 'fv-ed-save-warning'); saveWarning.hidden = true; saveWarning.setAttribute('role', 'status'); exportBox.prepend(saveWarning);const notice = el('div', 'fv-ed-notice'); notice.hidden = true; notice.setAttribute('role', 'status');transport.append(drawer);diff --git a/web/editor_text_model.js b/web/editor_text_model.jsindex ccd5b01..5862653 100644--- a/web/editor_text_model.js+++ b/web/editor_text_model.js@@ -118,3 +118,24 @@ export function importSRT(record, text) {row.clips = entries.map(entry => ({id: `c${++next.serial}`, start: entry.at, frames: entry.frames, text: entry.text}));return model.parse(next);}+// Writes subtitle lines in one edit that one undo reverses (auto subtitles, an agent).+// cues: [{start, frames, text}] in timeline frames; a bilingual line is one cue of two+// lines (text with one "\n"). replace: true swaps out the whole subtitle track; otherwise+// the lines join it and any overlap with a line already there refuses the whole call.+// Every line takes the track's one style (changeSubtitleStyle); a line placed on its own is a text part.+export function addSubtitles(record, cues, {replace = false} = {}) {+ check(Array.isArray(cues) && cues.length >= 1 && cues.length <= 500 && typeof replace === 'boolean', 'subtitles');+ const lines = cues.map(cue => {+ check(object(cue) && Object.keys(cue).every(k => ['start', 'frames', 'text'].includes(k)), 'subtitles');+ check(whole(cue.start) && whole(cue.frames, 1) && whole(cue.start + cue.frames), 'range');+ check(typeof cue.text === 'string' && cue.text.trim() !== '' && cue.text.split('\n').length <= 2);+ return {start: cue.start, frames: cue.frames, text: cue.text};+ }).sort((a, b) => a.start - b.start);+ const next = model.serialize(record);+ let row = next.tracks.find(t => t.kind === 'subtitle'); check(!row?.locked, 'locked');+ if (!row) { row = {id: 's1', kind: 'subtitle', clips: []}; next.tracks.push(row); }+ const kept = replace ? [] : row.clips, all = [...kept, ...lines.map(line => ({id: `c${++next.serial}`, ...line}))].sort((a, b) => a.start - b.start);+ for (let i = 1; i < all.length; i++) check(all[i].start >= all[i - 1].start + all[i - 1].frames, 'overlap');+ row.clips = all;+ return model.parse(next);+}