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.

Editor: flag an unreadable reference picture right away

Bowen Xue244531fba1c6
diff --git a/web/editor.css b/web/editor.css
index 7d2cfb2..f796eee 100644
--- a/web/editor.css
+++ b/web/editor.css
@@ -98,6 +98,8 @@
.fv-ed-genbar{position:relative}
.fv-ed-refs{display:flex;align-items:center;gap:6px;flex:none}
.fv-ed-refs[hidden],.fv-ed-ref-menu[hidden]{display:none}
+.fv-ed-ref-notice{position:absolute;bottom:calc(100% + 8px);max-width:min(560px,calc(100% - 24px));border:1px solid var(--fv-border);background:var(--fv-card);padding:10px 14px;border-radius:8px;z-index:9;color:var(--fv-ink);pointer-events:none}
+.fv-ed-ref-notice[hidden]{display:none}
.fv-ed-ref-chips{display:flex;align-items:center;gap:6px;max-width:min(240px,32vw);overflow-x:auto;scrollbar-width:thin;scrollbar-color:var(--fv-border) transparent;padding:1px}
.fv-ed-ref-chips:empty{display:none}
/* A strip that scrolls fades at the hidden end(s); one that fits is untouched. */
diff --git a/web/editor.js b/web/editor.js
index 71b5278..44230bf 100644
--- a/web/editor.js
+++ b/web/editor.js
@@ -272,11 +272,11 @@ export function openEditor({api, app, from = null, panel = {}, components: given
}
const content = record => JSON.stringify({...record, id: null, revision: 0});
function notify(text) { if (disposed) return; if (!text) { clearTimeout(noticeTimer); notice.hidden = true; return; } notice.textContent = text; notice.hidden = false; clearTimeout(noticeTimer); noticeTimer = setTimeout(() => { notice.hidden = true; }, 9000); }
- // `step` names what was being done, so a failure there says which step went wrong.
- function error(value, step = null) {
+ // `step` names what was being done, so a failure there says which step went wrong; `out` is where the line is said (the bar's own line for a reference picture).
+ function error(value, step = null, out = notify) {
const code = value?.reason || value?.code || value?.message;
if (['missing_glyphs', 'MissingGlyphs', 'source_missing'].includes(code)) {
- notify(code === 'source_missing' ? t('A source file is missing. Import it again from the library.', '有素材的原文件找不到了,请在素材库重新导入。')
+ out(code === 'source_missing' ? t('A source file is missing. Import it again from the library.', '有素材的原文件找不到了,请在素材库重新导入。')
: t('The chosen font is missing some characters. Choose another font.', '所选字体缺少部分字符,请换一种字体。'));
return {ok: false, reason: code};
}
@@ -286,7 +286,7 @@ export function openEditor({api, app, from = null, panel = {}, components: given
const [en, zh] = (value.said || []).map(text => typeof text === 'string' && text ? text.slice(0, 200) : null);
const text = code === 'chain_too_long' ? t(en || 'This video can have up to 5 parts. Make it shorter.', zh || '这条视频最多 5 段,请缩短一些。')
: t(en || 'Each continued part must be at least 10 seconds. Make it longer.', zh || '接着生成的每一段至少 10 秒,请加长一些。');
- notify(text); return {ok: false, reason: code, say: text};
+ out(text); return {ok: false, reason: code, say: text};
}
if (['busy', 'locked', 'text', 'audio_full', 'overlap', 'range', 'no_audio'].includes(code)) {
if (['locked', 'audio_full', 'overlap', 'range'].includes(code)) tracks?.flashBlocked?.(value.displayFrame);
@@ -294,11 +294,11 @@ export function openEditor({api, app, from = null, panel = {}, components: given
text: t('Write a description first.', '先写一句描述。'), overlap: t('That spot is taken. Use an empty spot.', '这里已经有片段了,请放到空白处。'),
audio_full: t('Both audio tracks are full here. Move an audio clip first.', '这里两条声音轨都满了,请先挪开一段声音。'),
no_audio: t('This clip has no sound. Please choose one with sound.', '这个素材没有声音,请选一段有声音的。')}[code];
- if (said) notify(said);
+ if (said) out(said);
return {ok: false, reason: code};
}
const text = step === 'generate' ? editorErrorText(value, t) : step === 'export' ? exportErrorText(value, t) : t('Could not complete. Try again.', '没有完成,请重试');
- notify(text); return {ok: false, reason: code, say: text};
+ out(text); return {ok: false, reason: code, say: text};
}
const store = createEditorStore(api, {t, notify, standIn: given?.generationStandIn, onGenerationReady: ready => {
if (disposed) return;
diff --git a/web/editor_genbar.js b/web/editor_genbar.js
index 2642e18..0ee2904 100644
--- a/web/editor_genbar.js
+++ b/web/editor_genbar.js
@@ -59,8 +59,18 @@ export function createEditorGenbar(host, {state, t, actions, text = ''}) {
failureBar.append(failureReason, report); failure.append(failureBar); failure.hidden = true; host.append(failure);
let failureId = null, downloading = false;
// Reference pictures for a part that starts fresh: thumbnails and a small "+" before the description.
- const references = actions.references ? createEditorReferences({t, source: actions.references.source, size: actions.references.size, error: actions.error, notify: actions.references.notify}) : null;
- if (references) description.before(references.element);
+ // What goes wrong with a reference picture is said above the "+", where the eyes are, not in the page-wide line.
+ const refNotice = el('div', 'fv-ed-ref-notice'); refNotice.hidden = true; refNotice.setAttribute('role', 'status');
+ let refNoticeTimer = null;
+ const sayAtRefs = text => {
+ clearTimeout(refNoticeTimer);
+ if (!text || disposed) { refNotice.hidden = true; return; }
+ refNotice.textContent = text; refNotice.hidden = false;
+ refNotice.style.left = Math.max(0, (references?.element.getBoundingClientRect().left || 0) - host.getBoundingClientRect().left) + 'px';
+ refNoticeTimer = setTimeout(() => { refNotice.hidden = true; }, 9000);
+ };
+ const references = actions.references ? createEditorReferences({t, source: actions.references.source, size: actions.references.size, error: value => actions.error(value, null, sayAtRefs), notify: sayAtRefs}) : null;
+ if (references) { description.before(references.element); host.append(refNotice); }
let status = null, serial = 0, disposed = false, pressing = new Set(), previewSelection = null, estimateCache = null, noteTimer = null, queuedAt = null;
// Which parts are generating, or how the job ended: a "Queued" line goes once this moves on.
const progressKey = () => ['done', 'failed', 'cancelled', 'interrupted'].includes(status?.state) ? status.state
@@ -223,7 +233,7 @@ export function createEditorGenbar(host, {state, t, actions, text = ''}) {
});
render();
return {element: host, say, downloadFailure, 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); render(); },
- dispose() { disposed = true; ++serial; clearTimeout(noteTimer); unsubscribe(); resize?.disconnect(); expand.dispose(); references?.dispose(); assets?.dispose(); }};
+ dispose() { disposed = true; ++serial; clearTimeout(noteTimer); clearTimeout(refNoticeTimer); unsubscribe(); resize?.disconnect(); expand.dispose(); references?.dispose(); assets?.dispose(); }};
}
// A missing optional module leaves the editor's existing progress in place.
diff --git a/web/editor_references.js b/web/editor_references.js
index 9dbb790..df8044f 100644
--- a/web/editor_references.js
+++ b/web/editor_references.js
@@ -69,15 +69,27 @@ export function createEditorReferences({t, source, size = () => null, error = ()
return holder;
};
const write = rows => { try { source.write(rows); } catch (value) { error(value); } };
+ // A picture the page cannot draw would only fail minutes later, in the engine; tiff is not drawn by every browser, so it goes on unchecked.
+ const readable = async file => {
+ if (!/\.(png|jpe?g|webp|bmp)$/i.test(file.name || '')) return true;
+ if (typeof Image !== 'function') return true;
+ const url = URL.createObjectURL(file), image = new Image();
+ try { image.src = url; await image.decode(); return image.naturalWidth > 0 && image.naturalHeight > 0; }
+ catch { return false; }
+ finally { URL.revokeObjectURL(url); }
+ };
async function addFiles(files) {
if (working) return;
working = true; update();
+ let skipped = false;
try {
for (const file of files) {
if (full()) break;
+ if (!await readable(file)) { skipped = true; continue; }
const result = await source.upload(file);
write([...source.rows(), {file: result.file, role: 'reference', enabled: true}]);
}
+ if (skipped && !disposed) notify(t('Could not read this picture. Please choose another one.', '无法读取这张图片,请换一张。'));
} catch (value) { error(value); }
finally { working = false; picker.value = ''; update(); }
}