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.

Library: say how many creation records could not be read

Bowen Xue7efc9e059286
diff --git a/freevideo_engine/comfy_library.py b/freevideo_engine/comfy_library.py
index 805b5dc..3f2ece8 100644
--- a/freevideo_engine/comfy_library.py
+++ b/freevideo_engine/comfy_library.py
@@ -31,6 +31,10 @@ def _video(root, identity):
return path
+class _Unfinished(ValueError):
+ """A run whose summary says it did not finish: not a damaged record."""
+
+
def _report(path):
# Read only the small request summary, never tensors, prompts or media.
with path.with_suffix('.request.json').open('rb') as stream:
@@ -38,8 +42,10 @@ def _report(path):
if len(data) > 4 * 1024 * 1024:
raise ValueError('Request summary is too large')
report = json.loads(data)
- if not isinstance(report, dict) or report.get('success') is not True:
- raise ValueError('Video is not complete')
+ if not isinstance(report, dict):
+ raise ValueError('Request summary is not an object')
+ if report.get('success') is not True:
+ raise _Unfinished('Video is not complete')
return report
@@ -82,12 +88,20 @@ def list_videos(output_directory, *, before=None, limit=24):
candidates.append((key, path, info))
except (OSError, ValueError):
continue
- rows = []
+ rows, unreadable = [], []
for key, path, info in sorted(candidates, key=lambda item: item[0], reverse=True):
+ relative = Path('FreeVideo') / key[1] / 'video.mp4'
+ if relative.as_posix() in hidden:
+ continue
try:
- report = _report(path)
- relative = Path('FreeVideo') / key[1] / 'video.mp4'
- if relative.as_posix() in hidden:
+ try:
+ report = _report(path)
+ except (FileNotFoundError, _Unfinished):
+ # A generation still writing its video has no summary yet; a failed run is not listed.
+ continue
+ except (OSError, ValueError):
+ # Summaries are replaced atomically, so one that cannot be read is damaged.
+ unreadable.append(key)
continue
summary = output_summary(report, relative)
# Geometry may gain input metadata in future reports. Keep this API
@@ -123,7 +137,9 @@ def list_videos(output_directory, *, before=None, limit=24):
next_cursor = rows[-1]['cursor'] if more else None
for row in rows:
row.pop('cursor')
- return dict(items=rows, next=next_cursor)
+ # Each page counts the damaged summaries in its own range, so the pages add up.
+ last = (int(next_cursor.split(':', 1)[0]), next_cursor.split(':', 1)[1]) if next_cursor else None
+ return dict(items=rows, next=next_cursor, unreadable=sum(last is None or key > last for key in unreadable))
def thumbnail(output_directory, identity):
diff --git a/web/library.css b/web/library.css
index c347424..8523b7f 100644
--- a/web/library.css
+++ b/web/library.css
@@ -71,5 +71,6 @@
.fv-library .fv-library-undo:not([hidden])~.fv-library-selection:not([hidden]){margin-top:0}
.fv-library .fv-library-undo button{min-height:28px;padding:2px 10px;font-size:13px;color:var(--fv-accent)}
.fv-library .fv-library-skipped{flex-basis:100%;font-size:12px;color:var(--fv-muted)}
+.fv-library .fv-library-unreadable{margin:8px;text-align:center}.fv-library .fv-library-unreadable:empty{display:none}
@media(max-width:680px){.fv-library-tools{gap:0}.fv-library .fv-library-header{grid-template-columns:auto minmax(0,1fr) auto}.fv-library-header h2{text-align:center}.fv-library-header button{white-space:nowrap}.fv-studio.fv-library .fv-library-header button{padding-left:6px;padding-right:6px}}
.fv-library-message .fv-issue-button{margin:4px 0 4px 8px;vertical-align:middle}
diff --git a/web/library.js b/web/library.js
index bf1a63d..159d37d 100644
--- a/web/library.js
+++ b/web/library.js
@@ -193,6 +193,8 @@ export function openLibrary(t, {upscale = null, selectedWork = null, extend = nu
const grid = el('div', null, 'fv-library-grid');
const message = el('p', '', 'fv-library-message'); message.setAttribute('role', 'status');
const more = button(t('Show more', '加载更多'), () => load(true), 'fv-quiet'); more.hidden = true;
+ // Creations whose saved record could not be read stay on disk; say how many the loaded pages skipped.
+ const unreadable = el('p', '', 'fv-library-skipped fv-library-unreadable'); let unread = 0;
// Selecting several creations: a strip above the cards, the delete bar below them.
const picking = el('div', null, 'fv-library-picking'); picking.hidden = true;
const pickAll = button(t('Select all', '全选'), () => selectAll(), 'fv-quiet');
@@ -207,7 +209,7 @@ export function openLibrary(t, {upscale = null, selectedWork = null, extend = nu
bar.append(barLabel, barText, barActions);
// The undo note and the delete bar share one sticky dock so they stack instead of covering each other.
const dock = el('div', null, 'fv-library-dock'); dock.append(undoBar, bar);
- collection.append(picking, grid, message, more, dock);
+ collection.append(picking, grid, message, more, unreadable, dock);
workflowBackfill(collection, t);
const detail = el('section', null, 'fv-library-detail');
const all = button(t('All creations', '全部作品'), () => {
@@ -661,7 +663,9 @@ export function openLibrary(t, {upscale = null, selectedWork = null, extend = nu
message.textContent = rows.size ? '' : t('Loading your creations…', '正在读取作品…');
try {
const data = await libraryPage(t, {before: appendPage ? next : null, signal: abort.signal}); if (disposed) return;
- if (!appendPage) { thumbnails.disconnect(); grid.replaceChildren(); cards.clear(); rows.clear(); }
+ if (!appendPage) { thumbnails.disconnect(); grid.replaceChildren(); cards.clear(); rows.clear(); unread = 0; }
+ unread += Number.isSafeInteger(data.unreadable) && data.unreadable > 0 ? data.unreadable : 0;
+ unreadable.textContent = unread ? t(`${unread} ${unread === 1 ? 'creation' : 'creations'} could not be read`, `另有 ${unread}\u00a0个作品无法读取`) : '';
for (const row of data.items || []) append(row);
for (const row of arrivals) append(row, true);
next = data.next; more.hidden = !next;