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.
Character dialog: an unreadable picture is named on its own tile, with the signed wording
Bowen Xue72c0d7704e5d
diff --git a/freevideo_engine/agent/cast.py b/freevideo_engine/agent/cast.pyindex 5f61162..8352d5c 100644--- a/freevideo_engine/agent/cast.py+++ b/freevideo_engine/agent/cast.py@@ -79,13 +79,13 @@ def turn_label(progress):class CastError(JobError):"""A card error; conflicts carry the current card so the caller can retry from it."""- def __init__(self, code, message, next_action, *, card=None, job=None):+ def __init__(self, code, message, next_action, *, card=None, job=None, details=None):super().__init__(code, message)self.status = errors.ERRORS[code][0]- self.next_action, self.card, self.job = next_action, card, job+ self.next_action, self.card, self.job, self.details = next_action, card, job, details or []def view(self):- value = errors.build(self.code, validation=True, details=[], message=self.message,+ value = errors.build(self.code, validation=True, details=deepcopy(self.details), message=self.message,next_action=self.next_action)if self.code in errors.IMAGE_REASONS:value.update(errors.image_failure(self.code))@@ -276,6 +276,15 @@ class Cast:return iso(self.jobs.clock())# Media --------------------------------------------------------------------------------------------+ def _picture_at(self, identity, item, by, index):+ """`_picture` for the request's images[index]; a refused picture names its place, so the dialog marks it."""+ try:+ return self._picture(identity, item, by)+ except CastError as error:+ if error.code == 'invalid_media' and not error.details:+ error.details = [dict(field='/images/%d/media' % index)]+ raise+def _picture(self, identity, item, by):"""Resolve one picture to an input file in this card's folder (frames, imports, edits)."""from ..comfy_assets import media_kind@@ -290,6 +299,15 @@ class Cast:if kind != 'image':raise CastError('invalid_media', 'A card picture must be an image.','Upload an image, or name a video frame with from_job or library and frame.')+ # The extension alone lets a renamed or cut-off file in; decode it once so a broken picture is refused here,+ # not when a video first uses the card.+ try:+ from PIL import Image+ with Image.open(self.jobs.port.input_path(relative)) as image:+ image.load()+ except Exception: # noqa: BLE001 - any decoder failure means the picture cannot be used+ raise CastError('invalid_media', 'A card picture must be a readable image.',+ 'Upload another image.') from Noneentry = dict(media=dict(file=relative), by=by)if isinstance(source, dict) and source.get('from_job'):entry['from_job'] = source['from_job']@@ -354,8 +372,8 @@ class Cast:return replayidentity = 'c' + uuid.uuid4().hex[:12]images = []- for row in value.get('images', []):- entry = self._picture(identity, row['media'], by)+ for index, row in enumerate(value.get('images', [])):+ entry = self._picture_at(identity, row['media'], by, index)images.append(dict(entry, label=row.get('label', 'other')))voice = self._voice(identity, value['voice']) if value.get('voice') else Nonewith self.changed:@@ -429,8 +447,8 @@ class Cast:resolved = {}for key, rows in changes.items():if key == 'images':- resolved['images'] = [entry if entry is not None else dict(self._picture(identity, row['media'], by),- label=row.get('label', 'other')) for row, entry in rows]+ resolved['images'] = [entry if entry is not None else dict(self._picture_at(identity, row['media'], by, index),+ label=row.get('label', 'other')) for index, (row, entry) in enumerate(rows)]elif key == 'voice':resolved['voice'] = None if rows is None else self._voice(identity, rows)else:diff --git a/web/cast_library.css b/web/cast_library.cssindex 425b191..51a833d 100644--- a/web/cast_library.css+++ b/web/cast_library.css@@ -35,6 +35,9 @@.fv-cast-dialog .fv-cast-delete{margin-right:auto;color:var(--fv-danger)}.fv-cast-dialog .fv-cast-save{border-color:var(--fv-accent);background:var(--fv-accent);color:var(--fv-bg);font-weight:var(--fv-semibold,600)}.fv-cast-dialog .fv-cast-save:hover:not([aria-disabled=true]){background:var(--fv-accent-hover)}+.fv-cast-dialog .fv-cast-bad .fv-cast-choose{border:1px solid var(--fv-danger)}+.fv-cast-slot-error{position:absolute;left:1px;right:1px;bottom:1px;padding:4px 3px;border-radius:0 0 var(--fv-r-sm,8px) var(--fv-r-sm,8px);background:var(--fv-bg);color:var(--fv-danger);font-size:12px;line-height:1.4;word-break:keep-all;overflow:hidden;pointer-events:none}+.fv-cast-slot-line{display:block}.fv-cast-message{margin-top:12px;color:var(--fv-danger);white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.fv-cast-message.fv-cast-notice{color:var(--fv-muted)}.fv-cast-dialog .fv-cast-delete.fv-cast-confirm{border-color:#c9414f;background:#c9414f;color:#fff}diff --git a/web/cast_library.js b/web/cast_library.jsindex bff17f7..ead6cb3 100644--- a/web/cast_library.js+++ b/web/cast_library.js@@ -41,9 +41,14 @@ export function createCastLibrary({api, text, viewURL, uploadOne, onChange = ()async function value(response) {const data = await response.json().catch(() => null);if (!response.ok) {- const error = new Error(data?.error?.message || (typeof data?.error === 'string' && data.error)+ // The dialog only sends pictures, so unreadable media here is always one of them.+ const unreadable = data?.error?.code === 'invalid_media' && text('Could not read this picture. Please choose another one.', '无法读取这张图片,请换一张。');+ const error = new Error(unreadable || data?.error?.message || (typeof data?.error === 'string' && data.error)|| data?.message || response.statusText || text('Did not finish. Try again.', '没有完成,请重试。'));- error.status = response.status; throw error;+ error.status = response.status;+ // Which picture it was, as /images/<n>/media of the request.+ if (unreadable) error.field = data.error.details?.find(detail => typeof detail?.field === 'string')?.field;+ throw error;}return data;}@@ -142,6 +147,21 @@ export function createCastLibrary({api, text, viewURL, uploadOne, onChange = ()slotUI[index].choose.disabled = busy; slotUI[index].remove.disabled = busy;}}+ // A refused picture is named on its own tile; choosing another picture there, or saving again, clears it.+ // A tile too narrow for the words keeps only its red border, and the words go on the line under the pictures.+ let markedBelow = -1;+ function mark(index, content = '') {+ const {slot, problem} = slotUI[index];+ // Clear the line only while it still holds this tile's words, not a later message.+ if (markedBelow === index) { markedBelow = -1; if (status.textContent === problem.textContent) message(''); }+ // One line per clause, so "这张图片" is never split across lines.+ problem.replaceChildren(...content.replace(/([,。]|\. )/g, '$1\n').split('\n').filter(Boolean).map(part => el('span', 'fv-cast-slot-line', part)));+ problem.hidden = !content; slot.classList.toggle('fv-cast-bad', !!content);+ const width = slot.clientWidth;+ if (content && width > 0 && (width < 100 || problem.scrollWidth > problem.clientWidth || problem.offsetHeight > slot.clientHeight / 2)) {+ problem.hidden = true; markedBelow = index; message(content);+ }+ }function select(tab) {active = tab;uploadPane.hidden = tab !== 'upload'; aiPane.hidden = tab !== 'ai';@@ -174,7 +194,7 @@ export function createCastLibrary({api, text, viewURL, uploadOne, onChange = ()choose.append(el('span', 'fv-cast-slot-plus', '+'));if (!index) choose.append(el('span', '', text('Front image', '正面图片')));}- remove.hidden = true; if (image?.complete) remove.hidden = false; sync();+ remove.hidden = true; if (image?.complete) remove.hidden = false; mark(index); sync();}function chooseFiles(index, files) {if (loading || saving || closed) return;@@ -195,7 +215,9 @@ export function createCastLibrary({api, text, viewURL, uploadOne, onChange = ()input.onchange = () => { chooseFiles(index, input.files); input.value = ''; };slot.ondragover = event => { event.preventDefault(); event.stopPropagation(); };slot.ondrop = event => { event.preventDefault(); event.stopPropagation(); chooseFiles(index, event.dataTransfer.files); };- slot.append(choose, remove, input); slotUI.push({choose, remove});+ const problem = el('div', 'fv-cast-slot-error'); problem.setAttribute('role', 'alert'); problem.hidden = true;+ // The remove button comes after the text so it stays above it on a narrow tile.+ slot.append(choose, problem, remove, input); slotUI.push({slot, choose, remove, problem});(index ? views : uploadPane).append(slot); paint(index);}uploadPane.append(views);@@ -230,9 +252,10 @@ export function createCastLibrary({api, text, viewURL, uploadOne, onChange = ()async function saveCard() {if (closed || save.disabled) return;if (missing) { message(missing, true); return; }- saving = true; resetDelete(); message(''); sync();+ saving = true; resetDelete(); message(''); slotUI.forEach((_, index) => mark(index)); sync();+ let pictures = [];try {- const pictures = active === 'upload' ? slots.filter(Boolean) : generator.getPictures().map((picture, index) => ({+ pictures = active === 'upload' ? slots.filter(Boolean) : generator.getPictures().map((picture, index) => ({...(typeof picture.file === 'string' ? {media: picture.file} : {file: picture.file}),label: picture.label || (index ? 'other' : 'front'),}));@@ -251,7 +274,11 @@ export function createCastLibrary({api, text, viewURL, uploadOne, onChange = ()await value(await (id ? agentSend(api, 'PATCH', path(id), {revision, ...body}): agentPost(api, '/freevideo/agent/cast', {kind: 'character', ...body})));close(); await saved();- } catch (error) { await failure(error); }+ } catch (error) {+ const at = /^\/images\/(\d+)\/media$/.exec(error.field || '');+ const index = at && active === 'upload' ? slots.indexOf(pictures[Number(at[1])]) : -1;+ if (index >= 0 && !closed) mark(index, error.message); else await failure(error);+ }finally { saving = false; if (!closed) sync(); }}async function deleteCard() {