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: set the length of new parts in seconds from the generation bar
Bowen Xuedeb16d58fb54
diff --git a/web/editor.css b/web/editor.cssindex a6ea01d..3a00990 100644--- a/web/editor.css+++ b/web/editor.css@@ -109,6 +109,15 @@.fv-ed-first-frame input:checked{background:var(--fv-accent,#6db8fa)}.fv-ed-first-frame input:checked::before{transform:translateX(10px)}.fv-ed-first-frame:has(input:disabled){opacity:.4}+/* Duration of the parts not generated yet, typed in whole seconds; the seconds field of Studio, narrower. */+.fv-ed-duration{position:relative;flex:none;font-size:13px;white-space:nowrap}+.fv-ed-duration[hidden]{display:none}+.fv-ed-duration label{display:flex;align-items:center;gap:6px}+.fv-studio .fv-ed-duration input[type=number]{width:56px;height:36px;min-height:36px;padding:0 6px;text-align:center;font-variant-numeric:tabular-nums}+.fv-ed-duration:has(input:disabled){opacity:.4}+.fv-ed-duration-hint{bottom:calc(100% + 6px);left:0}+.fv-ed-duration-hint[hidden]{display:none}+.fv-ed-genbar-break{display:none}.fv-ed-description:disabled{opacity:.4}.fv-ed-genbar{position:relative}.fv-ed-genbar:has(.fv-empty-prompt){flex-wrap:wrap}@@ -215,6 +224,7 @@.fv-ed-ref-chips{max-width:calc(100vw - 96px)}.fv-ed-gen-hint{flex:1 0 auto;white-space:nowrap}.fv-ed-gen-note{order:-1;flex:1 1 100%;white-space:normal}+ .fv-studio .fv-ed-duration input[type=number]{font-size:16px}.fv-editor .fv-ed-genbar>button{margin-left:auto;max-width:100%;height:36px;min-height:36px;font-size:12px}.fv-editor .fv-ed-genbar>button:not([hidden]) ~ button:not([hidden]){margin-left:0}.fv-ed-genbar .fv-empty-prompt{flex:0 0 100%;justify-content:flex-end;margin:0}@@ -243,6 +253,7 @@.fv-studio.fv-editor:has(.fv-ed-gen-failure:not([hidden])){grid-template-rows:auto minmax(0,1fr) 40px var(--fv-ed-generation-row,max-content) auto minmax(160px,236px)}.fv-studio.fv-editor .fv-header:has(.fv-view-switch){grid-template-columns:minmax(0,1fr) auto}/* One row: undo, split, delete and zoom; editor_toolbar_more.js moves the rest behind ⋯. */+ .fv-ed-duration-word{display:none}.fv-ed-toolbar{gap:4px;padding:0 12px;overflow:visible}.fv-ed-toolbar .fv-ed-tool-group+.fv-ed-tool-group:before{display:none}.fv-ed-toolbar>.fv-ed-zoom{flex:1 1 auto;min-width:0;margin-left:4px}@@ -264,6 +275,13 @@.fv-editor .fv-ed-library{grid-area:auto;top:116px;bottom:0;z-index:8}.fv-editor:has(.fv-ed-library[data-open=true]) .fv-ed-drawer-toggle{position:fixed;top:128px;right:20px;z-index:9}}+/* "Generate · about 4 minutes" in English does not fit beside the seconds field below 550 px: it keeps a line of its own,+ and the line above it stays whether the field shows or not, so choosing a clip or a draft does not move the timeline. */+@media(max-width:549px){+ .fv-ed-genbar:lang(en)[data-mode=selected]:not(:has(>.fv-ed-gen-failure:not([hidden]))){row-gap:0;padding-top:2px;align-content:space-between;min-height:calc(146px + var(--fv-ed-description-growth,0px))}+ .fv-ed-genbar:lang(en)[data-mode=selected]:not(:has(>.fv-ed-gen-failure:not([hidden])))>*{margin-top:8px}+ .fv-ed-genbar:lang(en)[data-mode=selected]:not(:has(>.fv-ed-gen-failure:not([hidden])))>.fv-ed-genbar-break{display:block;flex:0 0 100%;height:0;margin:0}+}/* Narrow window: the picture sits right under the header, the row takes the project's own shape (a16:9 project is about 200 px tall at 400 px wide), and whatever height is left goes to the timeline. */@media(max-width:680px){diff --git a/web/editor_duration.js b/web/editor_duration.jsnew file mode 100644index 0000000..93e49c4--- /dev/null+++ b/web/editor_duration.js@@ -0,0 +1,147 @@+// "Duration [n] s" in the generation bar: the length of the parts not generated yet, or of a range drawn on v1.+// A typed length is applied as dragging the right edge would apply it: whole seconds, the same part rules, one step to undo.+import * as model from './editor_model.js';+const {FPS, RULES} = model;+const el = (tag, cls, text) => { const e = document.createElement(tag); if (cls) e.className = cls; if (text != null) e.textContent = text; return e; };+const end = clip => clip.start + clip.frames;+const draft = clip => clip.pending != null && !clip.source;+const running = clip => ['queued', 'running'].includes(clip.pending);+const limitsOf = actions => actions.generationLimits?.() || {};++// What the field stands for: one run of parts not generated yet on v1, or a range on v1; null hides the field.+export function durationTarget(record, selection) {+ if (!selection) return null;+ if (selection.kind === 'range') return selection.tracks.includes('v1') ? {kind: 'range', frames: selection.frames, busy: false} : null;+ if (selection.kind !== 'clip') return null;+ const video = record.tracks.find(track => track.id === 'v1');+ const clips = (video?.clips || []).filter(clip => selection.ids.includes(clip.id)).sort((a, b) => a.start - b.start);+ if (!clips.length || !clips.every(draft) || !selection.ids.every(id => clips.some(clip => clip.id === id || clip.link === id))) return null;+ if (!clips.every((clip, i) => !i || end(clips[i - 1]) === clip.start && model.continuesBefore(record, clip.id))) return null;+ return {kind: 'parts', clips, frames: clips.reduce((sum, clip) => sum + clip.frames, 0), busy: clips.some(running)};+}++// The length a typed number becomes, why it was changed (`hint`), and the edit or selection that applies it.+export function durationPlan(record, selection, seconds, limits = {}) {+ const target = durationTarget(record, selection);+ if (!target || target.busy || typeof seconds !== 'number' || !Number.isFinite(seconds)) return null;+ const requested = Math.round(seconds), current = Math.round(target.frames / FPS);+ const clamp = (least, most) => {+ const value = Math.max(least, Math.min(most, requested));+ return {value, hint: requested < least ? {least} : requested > most ? {most} : null};+ };+ if (target.kind === 'range') {+ // A range drawn on its own starts a new video: at least the general minimum, at most the parts one video may have.+ const {value, hint} = clamp(RULES.minSeconds, Math.floor(model.maxRangeFrames(record, {...limits, continues: false}) / FPS));+ const {parts, ...rest} = selection;+ return {value, hint, current, selection: value === current ? null : {...rest, frames: value * FPS}};+ }+ const [first, ...later] = target.clips, laterIds = later.map(clip => clip.id);+ const base = laterIds.length ? model.dropPlanned(record, laterIds) : record;+ const oldIds = new Set(base.tracks[0].clips.map(clip => clip.id));+ const runOf = r => r.tracks[0].clips.filter(clip => clip.id === first.id || !oldIds.has(clip.id));+ // Ask the very same model operation as a right-edge drag, then report the length it actually accepted.+ const stop = Math.max(0, Math.min(1e7, first.start + requested * FPS));+ const refused = problem => Object.assign(new model.EditError(problem.code), problem);+ const planned = model.planPlannedEnd(base, first.id, stop, limits), resized = planned.record;+ // A failed resize returns its input. For several selected parts that input has already lost the later parts:+ // never submit it, even when Enter was pressed on the original value.+ if (resized === base) return {value: current, hint: null, current, change: null, error: refused(planned.problem)};+ const laidOut = r => {+ const base = laterIds.length ? model.dropPlanned(r, laterIds) : r;+ const next = model.planPlannedEnd(base, first.id, stop, limits);+ if (next.record === base) throw refused(next.problem);+ return next.record;+ };+ const value = runOf(resized).reduce((sum, clip) => sum + clip.frames, 0) / FPS;+ const hint = requested < planned.least ? {least: planned.least} : requested > planned.most ? {most: planned.most} : null;+ if (value === current) return {value, hint, current, change: null};+ // Each part laid out again keeps the description of the part that stood in its place; parts added at the end take the last one's.+ const change = r => keepWords(r, r === record ? resized : laidOut(r), target.clips.map(clip => clip.id), runOf);+ const result = change(record);+ const ids = runOf(result).flatMap(clip => model.pair(result, clip.id).map(member => member.id));+ return {value, hint, current, change, selectionAfter: {kind: 'clip', ids}};+}++// What a part says: its description, who wrote it and its note, on each of its tracks.+const WORDS = ['text', 'text_by', 'note'];+function keepWords(before, after, oldIds, runOf) {+ const trackId = (record, id) => record.tracks.find(track => track.clips.some(clip => clip.id === id)).id;+ const wordsOf = id => new Map(model.pair(before, id).map(clip => [trackId(before, clip.id), clip]));+ const olds = oldIds.map(wordsOf), run = runOf(after);+ const differs = run.some((clip, i) => model.pair(after, clip.id).some(member => {+ const old = olds[Math.min(i, olds.length - 1)].get(trackId(after, member.id));+ return old && WORDS.some(field => old[field] !== member[field]);+ }));+ if (!differs) return after;+ const next = model.serialize(after), clips = next.tracks.flatMap(track => track.clips.map(clip => [clip, track.id]));+ run.forEach((clip, i) => {+ const old = olds[Math.min(i, olds.length - 1)];+ for (const member of model.pair(after, clip.id)) {+ const [target, track] = clips.find(([item]) => item.id === member.id), from = old.get(track);+ if (!from) continue;+ for (const field of WORDS) { if (from[field] === undefined) delete target[field]; else target[field] = from[field]; }+ }+ });+ return model.parse(next);+}++// actions.generationLimits(): what this machine generates in one part; actions.editError(error): an edit that could not be made.+export function createDurationField({state, t, actions}) {+ const element = el('div', 'fv-ed-duration'), label = el('label');+ const input = el('input'); input.type = 'number'; input.step = '1'; input.min = '1'; input.inputMode = 'numeric';+ input.setAttribute('aria-label', t('Duration in seconds', '时长(秒)'));+ label.append(el('span', 'fv-ed-duration-word', t('Duration', '时长')), input, el('span', 'fv-ed-duration-unit', t('s', '秒')));+ // Styled as the timeline's drag label, with its sentences, above the field.+ const hint = el('div', 'fv-ed-duration-hint'); hint.hidden = true; hint.setAttribute('role', 'status');+ element.append(label, hint); element.hidden = true;+ // `typing`: a number typed and not applied yet, which a redraw of the bar keeps.+ let hintTimer = null, disposed = false, typing = false;+ const shown = () => { const target = durationTarget(state.record, state.selection); return target ? String(Math.round(target.frames / FPS)) : ''; };+ function say(text) {+ clearTimeout(hintTimer); hint.textContent = text; hint.hidden = false;+ hintTimer = setTimeout(() => { hint.hidden = true; }, 2000);+ }+ function commit() {+ if (disposed || element.hidden) return;+ typing = false;+ if (input.disabled) { input.value = shown(); return; }+ const typed = String(input.value ?? '').trim(), seconds = Number(typed);+ try {+ const plan = typed && Number.isFinite(seconds) ? durationPlan(state.record, state.selection, seconds, limitsOf(actions)) : null;+ if (!plan) { input.value = shown(); return; }+ clearTimeout(hintTimer); hint.hidden = true;+ if (plan.error) throw plan.error;+ if (plan.hint?.least != null) say(t(`At least ${plan.hint.least} s`, `至少 ${plan.hint.least} 秒`));+ else if (plan.hint?.most != null) say(t(`Max ${plan.hint.most} s`, `最长 ${plan.hint.most} 秒`));+ if (plan.change) state.apply(t('Extend', '拉长'), plan.change, {selectionAfter: plan.selectionAfter});+ else if (plan.selection) state.select(plan.selection, {history: true});+ } catch (error) {+ clearTimeout(hintTimer); hint.hidden = true;+ actions.editError?.(error);+ }+ input.value = shown();+ }+ // Typing alone leaves the timeline as it is: a "1" on the way to "14" is not applied.+ input.onkeydown = event => {+ if (event.key === 'Enter' && !event.isComposing && event.keyCode !== 229) { event.preventDefault(); commit(); return; }+ if (event.key !== 'ArrowUp' && event.key !== 'ArrowDown') return;+ event.preventDefault();+ const typed = Number(String(input.value ?? '').trim() || shown());+ input.value = String((Number.isFinite(typed) ? Math.round(typed) : Number(shown())) + (event.key === 'ArrowUp' ? 1 : -1));+ commit();+ };+ input.oninput = () => { typing = true; };+ input.onblur = () => commit();+ // The browser's own step buttons.+ input.onchange = () => commit();+ // While these parts are made the field stays in place, greyed like the description.+ function update(busy = false) {+ const target = durationTarget(state.record, state.selection);+ element.hidden = !target;+ if (!target) { clearTimeout(hintTimer); hint.hidden = true; return; }+ input.disabled = busy || target.busy;+ if (input.disabled) typing = false;+ if (!typing) input.value = String(Math.round(target.frames / FPS));+ }+ return {element, input, update, commit, dispose() { disposed = true; clearTimeout(hintTimer); }};+}diff --git a/web/editor_genbar.js b/web/editor_genbar.jsindex 02a35e4..7a77500 100644--- a/web/editor_genbar.js+++ b/web/editor_genbar.js@@ -1,5 +1,6 @@// The editor owns its generation controls; progress can use the optional component.import {createFirstFrameSwitch} from './editor_first_frame.js';+import {createDurationField} from './editor_duration.js';import {createEditorReferences} from './editor_references.js';import {createExpandButton} from './editor_expand.js';import {createRequestAssets} from './request_assets.js';@@ -96,6 +97,12 @@ export function createEditorGenbar(host, {state, t, actions, text = ''}) {musicAssets.textContent = musicBytes > 0 ? t(`Downloads before generating: music model ${size(musicBytes)}`, `生成前会先下载:配乐模型 ${size(musicBytes)}`) : '';musicAssets.hidden = !(musicBytes > 0) || host.dataset.mode !== 'selected' || !music.target();}+ // How long the parts not generated yet are, between the description and the first-frame switch.+ const duration = createDurationField({state, t, actions});+ description.after(duration.element);+ // Where a narrow English bar starts Generate on a line of its own (editor.css); hidden elsewhere.+ const lineBreak = el('span', 'fv-ed-genbar-break'); lineBreak.setAttribute('aria-hidden', 'true');+ generate.before(lineBreak); host.lang = t('en', 'zh-CN');const failure = el('div', 'fv-ed-gen-failure fv-result-links'), failureBar = el('div', 'fv-ed-failure-actions fv-actions');const failureReason = el('span', 'fv-ed-failure-reason'); failureReason.setAttribute('role', 'status');const report = el('button', 'fv-ed-failure-report fv-action fv-action-secondary', t('Download diagnostic report', '下载诊断报告')); report.type = 'button';@@ -202,6 +209,7 @@ export function createEditorGenbar(host, {state, t, actions, text = ''}) {hint.replaceChildren(...shown.map(([cls, text]) => el('span', cls, text)));hint.title = shown.map(([, text]) => text).join('');}+ duration.update(busy);firstFrame.update(busy);if (presets) {presets.hidden = !musical || !selected && !busy;@@ -326,7 +334,7 @@ export function createEditorGenbar(host, {state, t, actions, text = ''}) {if (!value && note.contains(retryService)) { retryService.remove(); note.hidden = true; }showService();}, getText() { expand.commit(); return input.value; }, update(value) { status = value; render(); }, preview(selection) { previewSelection = selection; render(); }, setText(value) { input.value = value || ''; state.setRangeText(input.value); if (bound && input.value !== bound.text) { dirty = true; written = input.value; } render(); },- dispose() { disposed = true; ++serial; clearTimeout(noteTimer); clearTimeout(refNoticeTimer); unsubscribe(); resize?.disconnect(); expand.dispose(); references?.dispose(); assets?.dispose(); Object.values(pickers).forEach(picker => picker.dispose()); }};+ dispose() { disposed = true; ++serial; clearTimeout(noteTimer); clearTimeout(refNoticeTimer); duration.dispose(); unsubscribe(); resize?.disconnect(); expand.dispose(); references?.dispose(); assets?.dispose(); Object.values(pickers).forEach(picker => picker.dispose()); }};}// A missing optional module leaves the editor's existing progress in place.diff --git a/web/editor_model.js b/web/editor_model.jsindex 3f0c377..d34926f 100644--- a/web/editor_model.js+++ b/web/editor_model.js@@ -744,7 +744,7 @@ export function continuesBefore(record, id) {export const partLengths = (frames, {maxSeconds = RULES.maxSeconds, maxFollowSeconds = maxSeconds, continues = false, tail = true} = {}) => segmentLengths(frames, maxSeconds, maxFollowSeconds, continues, tail);// One video is generated in at most partsLimit parts: the longest range that still fits. A device whose continuing// parts are all short has the short-part limit.-export function maxRangeFrames(record, {continues = false, maxSeconds = RULES.maxSeconds, maxFollowSeconds = maxSeconds, firstFrame = false}) {+export function maxRangeFrames(record, {continues = false, maxSeconds = RULES.maxSeconds, maxFollowSeconds = maxSeconds, firstFrame = record.settings?.first_frame_reference === true}) {const before = continues;const follow = Math.floor(Math.min(RULES.maxSeconds, maxFollowSeconds)) * FPS;const parts = partsLimit(follow < RULES.fullSeconds * FPS, firstFrame);@@ -805,11 +805,84 @@ export function resizePlannedBoundary(record, leftId, rightId, frame, limits = {return finish(next);}export function resizePlanned(record, id, edge, frame, limits = {}) {- check(['start', 'end'].includes(edge) && whole(frame), 'range');+ if (edge !== 'end') return layoutPlanned(record, id, edge, frame, limits);+ return planPlannedEnd(record, id, frame, limits).record;+}+// Immutable records let repeated pointer previews and release share their last complete layout.+const plannedEndCache = new WeakMap();+export function planPlannedEnd(record, id, frame, limits = {}) {+ check(whole(frame), 'range');+ const geometry = plannedGeometry(record, id, limits), {primary: first, video} = geometry;+ const most = maxRangeFrames(record, {...limits, continues: continuesBefore(record, id)});+ const capped = Math.min(frame, first.start + most), position = Math.round(capped / FPS) * FPS;+ const key = JSON.stringify(Object.keys(limits).sort().map(key => [key, limits[key]]));+ const cached = plannedEndCache.get(record);+ if (cached?.id === id && cached.position === position && cached.key === key) return cached.result;+ const clips = trackBy(record, 'v1').clips, draft = clip => clip?.pending && !clip.source;+ const earlier = [];+ for (let before = video && partBefore(record, video); draft(before); before = partBefore(record, before)) earlier.unshift(before);+ const before = partBefore(record, earlier[0] || video);+ const lineage = before ? madeLineage(record, before) : {parts: 0, short: false};+ const firstFrame = limits.firstFrame ?? record.settings?.first_frame_reference === true;+ const candidates = new Map();+ const candidate = frame => {+ const {start, stop} = fitPlanned(geometry, 'end', frame);+ if (candidates.has(stop)) return candidates.get(stop);+ // Only numbers and the existing draft lineage participate in the search. No project copy, parse,+ // finish or split occurs until a length has been chosen. Use the same generation grid as partsProblem.+ const head = {id: (video || first).id, start, frames: stop - start, part: first.part || Symbol(),+ follows: video?.follows, source: null, job: null};+ const context = {tracks: [{id: 'v1', clips: [...(before ? [before] : []), ...earlier, head]}]};+ const lengths = rangeParts(context, {start, frames: stop - start, ...limits, tail: geometry.tail});+ lengths[lengths.length - 1] = stop - start - lengths.slice(0, -1).reduce((sum, count) => sum + count, 0);+ const run = [...earlier]; let at = start;+ for (const [index, frames] of lengths.entries()) {+ const clip = {...head, id: index ? Symbol() : head.id, start: at, frames};+ if (index) clip.follows = run.at(-1).id;+ run.push(clip); at += frames;+ }+ // Resizing may detach a following draft, or reach it. Splitting transfers its follows link to the last part.+ if (video) for (let next = clips.find(clip => clip.start === at && clip.id !== video.id); draft(next);) {+ if (at === stop && next.follows === video.id) next = {...next, follows: run.at(-1).id};+ if (!continuing(next, run.at(-1))) break;+ run.push(next); at = end(next);+ next = clips.find(clip => clip.start === at);+ }+ let problem = null;+ try { if (video) problem = plannedPartsProblem(generationPlan(context, run), () => lineage, firstFrame); }+ catch (error) {+ if (!(error instanceof EditError) || error.code !== 'range') throw error;+ // A frame-split tail may not fit the generation grid. Skip this candidate, including in hint bounds.+ problem = {code: error.code};+ }+ const result = {frame, seconds: (stop - start) / FPS, problem,+ allowed: !['range', 'chain_too_long', 'chain_short_parts'].includes(problem?.code)};+ candidates.set(stop, result); return result;+ };+ const initial = candidate(capped), wanted = initial.seconds;+ const least = continuesBefore(record, id)+ ? continuedSeconds(0, limits.maxFollowSeconds ?? limits.maxSeconds) : RULES.minSeconds;+ let chosen = initial.allowed ? initial : null;+ for (let seconds = wanted - 1; !chosen && seconds >= least; seconds--) {+ const next = candidate(first.start + seconds * FPS); if (next.allowed) chosen = next;+ }+ for (let seconds = wanted + 1; !chosen && seconds <= most / FPS; seconds++) {+ const next = candidate(first.start + seconds * FPS); if (next.allowed) chosen = next;+ }+ // Bounds describe the entire feasible set, including any holes, rather than just the chosen adjustment.+ for (let seconds = least; seconds <= most / FPS; seconds++) candidate(first.start + seconds * FPS);+ const feasible = [...candidates.values()].filter(value => value.allowed).map(value => value.seconds);+ const result = {record: chosen ? layoutPlanned(record, id, 'end', chosen.frame, limits) : record,+ least: feasible.length ? Math.min(...feasible) : null, most: feasible.length ? Math.max(...feasible) : null,+ problem: chosen ? null : initial.problem};+ plannedEndCache.set(record, {id, position, key, result});+ return result;+}+function plannedGeometry(record, id, limits) {const members = pair(record, id); check(members.length, 'missing'); busy(members);check(members.every(clip => clip.pending && !clip.source), 'unsupported');const primary = members[0];- const video = trackOf(record, id).id === 'v1' ? primary : find(record, primary.link);+ const video = members.find(clip => trackOf(record, clip.id).id === 'v1');const maxFollowSeconds = limits.maxFollowSeconds ?? limits.maxSeconds ?? RULES.maxSeconds;// A planned part that continues another is at least followSeconds long, unless no part continues it.const follows = !!video && !!partBefore(record, video), tail = !video || !trackBy(record, 'v1').clips.some(clip => continuing(clip, video));@@ -817,6 +890,9 @@ export function resizePlanned(record, id, edge, frame, limits = {}) {const neighbors = members.flatMap(clip => trackOf(record, clip.id).clips.filter(other => other.id !== clip.id));const low = Math.max(0, ...neighbors.filter(clip => end(clip) <= primary.start).map(end));const high = Math.min(1e7, ...neighbors.filter(clip => clip.start >= end(primary)).map(clip => clip.start));+ return {members, primary, video, minimum, low, high, maxFollowSeconds, follows, tail};+}+function fitPlanned({primary, minimum, low, high, maxFollowSeconds, follows, tail}, edge, frame) {const position = Math.round(frame / FPS) * FPS;let start = edge === 'start' ? Math.max(low, Math.min(end(primary) - minimum, position)) : primary.start;let stop = edge === 'end' ? Math.min(high, Math.max(start + minimum, position)) : end(primary);@@ -828,6 +904,12 @@ export function resizePlanned(record, id, edge, frame, limits = {}) {else if (edge === 'start' && stop - fitted >= low) start = stop - fitted;}}+ return {start, stop};+}+function layoutPlanned(record, id, edge, frame, limits = {}) {+ check(['start', 'end'].includes(edge) && whole(frame), 'range');+ const geometry = plannedGeometry(record, id, limits), {members, primary, tail} = geometry;+ const {start, stop} = fitPlanned(geometry, edge, frame);let next = copy(record); detachAttempt(next, members.map(clip => clip.id));const part = primary.part || freshId(next);for (const clip of pair(next, id)) { clip.start = start; clip.frames = clip.length = stop - start; clip.part = part; clearPlan(clip); }@@ -1091,14 +1173,19 @@ function madeLineage(record, clip) {// them. Returns {code, parts, limit} for the first problem, or null.export function partsProblem(record, ids, {firstFrame = record.settings?.first_frame_reference === true, sourceLineage = {}} = {}) {const rows = generationPlan(record, generationClips(record, ids));+ return plannedPartsProblem(rows, clip => {+ // A video chosen from the library counts the parts it was made in, when they are known.+ const inherited = clip.source ? sourceLineage[`${clip.source.kind}:${clip.source.id}`] : null;+ const known = inherited && inherited.known !== false && Number.isInteger(inherited.parts) && inherited.parts > 0;+ return known ? {parts: inherited.parts, short: inherited.short === true} : madeLineage(record, clip);+ }, firstFrame);+}+function plannedPartsProblem(rows, previousLineage, firstFrame) {const followed = new Set(rows.map(row => row.before?.id));if (rows.some(row => row.before && row.request_frames < (followed.has(row.clip.id) ? MIN_PART_FRAMES : MIN_TAIL_FRAMES))) return {code: 'chain_part_too_short', parts: null, limit: RULES.followSeconds};const lineage = new Map();for (const row of rows) {- const inherited = row.before?.source ? sourceLineage[`${row.before.source.kind}:${row.before.source.id}`] : null;- const known = inherited && inherited.known !== false && Number.isInteger(inherited.parts) && inherited.parts > 0;- const previous = !row.before ? {parts: 0, short: false} : lineage.get(row.before.id)- ?? (known ? {parts: inherited.parts, short: inherited.short === true} : madeLineage(record, row.before));+ const previous = !row.before ? {parts: 0, short: false} : lineage.get(row.before.id) ?? previousLineage(row.before);lineage.set(row.clip.id, {parts: previous.parts + 1, short: previous.short || !!row.before && row.request_frames < FULL_PART_FRAMES});}const values = [...lineage.values()], parts = Math.max(...values.map(value => value.parts));diff --git a/web/editor_tracks.css b/web/editor_tracks.cssindex 3fbcf24..dd581c8 100644--- a/web/editor_tracks.css+++ b/web/editor_tracks.css@@ -75,7 +75,7 @@.fv-ed-track-zoom button:hover{background:var(--fv-card);color:var(--fv-ink)}.fv-ed-zoom-slider{width:64px;height:24px;margin:0;accent-color:var(--fv-accent);cursor:pointer}.fv-ed-track-zoom .fv-ed-fit{padding:0 7px;white-space:nowrap;font-size:12px;margin-left:4px}-.fv-ed-drag-label{position:absolute;z-index:9;padding:4px 7px;background:var(--fv-card);color:var(--fv-ink);border:1px solid var(--fv-border);border-radius:6px;font-size:12px;white-space:pre;line-height:1.5;pointer-events:none}+.fv-ed-drag-label,.fv-ed-duration-hint{position:absolute;z-index:9;padding:4px 7px;background:var(--fv-card);color:var(--fv-ink);border:1px solid var(--fv-border);border-radius:6px;font-size:12px;white-space:pre;line-height:1.5;pointer-events:none}.fv-ed-clip-popover{position:absolute;z-index:10;width:280px;max-width:calc(100% - 16px);padding:10px;border:1px solid var(--fv-border);border-radius:8px;background:var(--fv-card)}.fv-ed-clip-popover p{margin:0 0 8px;font-size:13px;overflow-wrap:anywhere}.fv-ed-clip-popover button{min-height:32px;padding:4px 10px;border:1px solid var(--fv-border);border-radius:8px;background:var(--fv-raised);cursor:pointer}