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.
Fold videos made by one task under the newest in Recent videos and Creations
Bowen Xue770a5c8d0744
diff --git a/freevideo_engine/comfy_library.py b/freevideo_engine/comfy_library.pyindex a518882..c3eef4f 100644--- a/freevideo_engine/comfy_library.py+++ b/freevideo_engine/comfy_library.py@@ -1,5 +1,6 @@"""Browse completed FreeVideo outputs across ComfyUI/browser restarts."""import asyncio+import hashlibfrom contextlib import nullcontextimport ioimport json@@ -66,6 +67,77 @@ def _agent(folder):return {key: str(value[key])[:120] for key in ('job', 'label', 'project', 'client') if value.get(key)}+def _identity_of(root, value):+ """The library identity of a video path named by a run, or None for a file elsewhere."""+ try:+ relative = Path(value).resolve().relative_to(Path(root).resolve() / 'FreeVideo')+ except (OSError, ValueError, TypeError):+ return None+ identity = '/'.join(relative.parts[:2])+ return identity if len(relative.parts) == 3 and relative.name == 'video.mp4' and _ID.fullmatch(identity) else None+++def _source_identity(root, folder, report):+ """The saved video this run started from: the preview it upscales, or the footage it continues."""+ source = (report.get('upscaled_preview') or {}).get('output') if isinstance(report.get('upscaled_preview'), dict) else None+ if not source:+ try:+ with (folder / 'comfy-request.json').open('rb') as stream:+ data = stream.read(1024 * 1024 + 1)+ command = json.loads(data).get('command') if len(data) <= 1024 * 1024 else None+ if isinstance(command, list) and '--continue-from' in command:+ source = command[command.index('--continue-from') + 1]+ except (OSError, ValueError, AttributeError, IndexError):+ pass+ return _identity_of(root, source) if isinstance(source, str) else None+++def _prompt_digest(folder):+ try:+ with os.fdopen(os.open(folder / 'prompt.txt', os.O_RDONLY | getattr(os, 'O_NOFOLLOW', 0)+ | getattr(os, 'O_BINARY', 0)), 'rb') as stream:+ data = stream.read(_PROMPT_BYTES + 1)+ text = data.decode('utf-8').strip() if len(data) <= _PROMPT_BYTES else ''+ except (OSError, ValueError):+ return None+ return hashlib.sha256(text.encode('utf-8')).hexdigest() if text else None+++def _tasks(root, rows, folders, reports):+ """Name each row's task: the earliest video connected to it by a preview and its upscale, a continuation,+ one agent job, or the same prompt text on the same day. A video with no such link is its own task."""+ parent = {row['id']: row['id'] for row in rows}+ def find(item):+ while parent[item] != item:+ parent[item] = parent[parent[item]]+ item = parent[item]+ return item+ seen = {}+ for row in rows:+ identity = row['id']+ tokens = ['id:' + identity]+ source = _source_identity(root, folders[identity], reports[identity])+ if source:+ tokens.append('id:' + source)+ if row.get('agent', {}).get('job'):+ tokens.append('job:' + row['agent']['job'])+ digest = _prompt_digest(folders[identity])+ if digest:+ tokens.append('prompt:%s:%s' % (identity.split('/', 1)[0], digest))+ for token in tokens:+ if token in seen:+ parent[find(identity)] = find(seen[token])+ else:+ seen[token] = identity+ groups = {}+ for row in rows:+ groups.setdefault(find(row['id']), []).append(row)+ for members in groups.values():+ earliest = min(members, key=lambda row: (row['created_at'], row['id']))['id']+ for row in members:+ row['task'] = earliest++def _favorite(path):"""A missing or damaged optional sidecar does not hide a saved video."""saved = path.with_suffix('.favorite.json')@@ -133,7 +205,7 @@ def list_videos(output_directory, *, before=None, limit=24, favorite=None):candidates.append((key, path, info))except (OSError, ValueError):continue- rows, unreadable = [], []+ rows, unreadable, folders, reports = [], [], {}, {}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:@@ -171,6 +243,7 @@ def list_videos(output_directory, *, before=None, limit=24, favorite=None):agent = Noneif agent:summary['agent'] = agent+ folders[key[1]], reports[key[1]] = path.parent, reportrows.append(dict(summary, id=key[1], bytes=info.st_size, favorite=is_favorite,created_at=datetime.fromtimestamp(info.st_mtime, timezone.utc).isoformat(),cursor=str(key[0]) + ':' + key[1]))@@ -182,6 +255,7 @@ def list_videos(output_directory, *, before=None, limit=24, favorite=None):breakmore = len(rows) > limitrows = rows[:limit]+ _tasks(root, rows, folders, reports)next_cursor = rows[-1]['cursor'] if more else Nonefor row in rows:row.pop('cursor')diff --git a/web/health.js b/web/health.jsindex a758638..e2bbb30 100644--- a/web/health.js+++ b/web/health.js@@ -16,7 +16,7 @@ const launchVisit = query.get('freevideo') === 'launch';export const MODULES = ['audio_original.js', 'chat_data.js', 'phone_model.js', 'phone.js', 'lan_access.js', 'qrcodegen.js', 'agent_activity.js', 'agent_confirm_settings.js', 'agent_connect.js', 'agent_session.js', 'autopilot.js', 'autopilot_chat.js', 'chat_attachments.js', 'autopilot_conversations.js', 'browser_extension.js', 'caret_rect.js', 'chain_support.js', 'chain_rules.js', 'timed_prompt.js', 'capability_view.js', 'cast_generate.js', 'cast_mention.js', 'cast_overlay.js', 'cast_source.js', 'compatibility.js', 'entry_showcase.js', 'error_panel.js', 'first_run_guide.js', 'fonts.js', 'freevideo.js', 'generation_progress.js','editor.js', 'editor_actions.js', 'editor_lifecycle.js', 'editor_adjust.js', 'editor_adjust_picture.js', 'editor_picture_fields.js', 'editor_picture_session.js', 'editor_preview_picture.js', 'editor_entry.js', 'editor_expand.js', 'editor_export_dialog.js', 'editor_first_frame.js', 'editor_media_references.js', 'editor_references.js', 'editor_genbar.js', 'editor_duration.js', 'editor_geometry.js', 'editor_library.js', 'editor_menu.js', 'editor_stems.js', 'editor_model.js', 'editor_frame.js', 'editor_player.js', 'editor_room.js', 'editor_select.js', 'editor_state.js', 'editor_store.js', 'editor_tracks.js', 'editor_generation.js', 'editor_transport.js', 'editor_transport_model.js', 'editor_audio.js', 'editor_audio_model.js', 'editor_audio_notes.js', 'editor_audio_replace.js', 'editor_audio_rules.js', 'editor_music.js', 'editor_music_model.js', 'editor_speed.js', 'editor_speed_model.js', 'editor_failure.js', 'editor_header_fit.js','editor_loader.js', 'editor_text_coverage.js', 'editor_text.js', 'editor_toolbar_more.js', 'editor_text_model.js', 'editor_text_layout.js', 'editor_notes.js', 'editor_icons.js', 'dialog_keys.js', 'done_notify.js', 'failure_issue.js', 'feedback.js', 'frame_sizes.js', 'health.js', 'image_commands.js', 'image_editor.js', 'image_editor_engine.js', 'image_generation.js', 'image_lora.js', 'launch_visit.js', 'launcher.js', 'length_plan.js', 'lora_triggers.js', 'lora_check.js', 'library.js', 'motion.js', 'native_errors.js', 'translate_guard.js', 'output_download.js', 'port_notice.js', 'preview_scene.js',- 'progress_connection.js', 'prompt_draft.js', 'prompt_enhance.js', 'prompt_references.js', 'prompt_sections.js', 'prompt_terms.js', 'request_assets.js', 'repair_hint.js', 'report_issue.js', 'issue_button.js', 'studio_recent.js',+ 'progress_connection.js', 'prompt_draft.js', 'prompt_enhance.js', 'prompt_references.js', 'prompt_sections.js', 'prompt_terms.js', 'request_assets.js', 'repair_hint.js', 'report_issue.js', 'issue_button.js', 'studio_recent.js', 'task_groups.js','result_actions.js', 'result_reuse.js', 'sampling_effort.js', 'pass_mode.js','setup.js', 'share.js', 'share_layout.js', 'studio.js', 'studio_chain.js', 'studio_extend.js', 'studio_length.js', 'first_frame_row.js', 'replace_person.js', 'replace_state.js', 'optional_inputs.js', 'other_usage.js', 'studio_queue.js', 'studio_size.js','toolbar_position.js', 'updates.js', 'view_navigation.js', 'wordmark.js', 'workspace_restore.js', 'cast_library.js', 'media_upload.js', 'whitebox_encode.js', 'whitebox_mp4.js', 'whitebox_recording.js', 'whitebox_render.js', 'whitebox_scenes.js', 'whitebox_worker.js','empty_prompt_notice.js', 'feature_tour.js', 'feature_tour_content.js', 'howto.js', 'swap_lora.js', 'tour_try.js', 'tutorial_book.js', 'tutorial_book_content.js'];diff --git a/web/library.css b/web/library.cssindex 05cc030..fba625b 100644--- a/web/library.css+++ b/web/library.css@@ -90,3 +90,10 @@.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}+/* Videos of one task fold under the newest: its picture shows one more edge behind it. Opened, the cover and each video of the task sit on their own raised ground, with a gap between them. */+.fv-library-card[hidden]{display:none}+.fv-library-card.fv-task-head:not(.fv-task-open) .fv-library-picture{box-shadow:4px -4px 0 0 var(--fv-sheen)}+.fv-library .fv-library-card.fv-task-open,.fv-library .fv-library-card.fv-task-member{background:var(--fv-raised);border-radius:var(--fv-r-md)}+.fv-library .fv-library-card.fv-task-member{animation:fv-task-reveal .2s ease}+@keyframes fv-task-reveal{from{opacity:0;transform:translateY(-4px)}}+@media(prefers-reduced-motion:reduce){.fv-library .fv-library-card.fv-task-member{animation:none}}diff --git a/web/library.js b/web/library.jsindex eab223f..162a41a 100644--- a/web/library.js+++ b/web/library.js@@ -5,6 +5,7 @@ import { videoUnavailableText } from './studio_extend.js';import { topDialog } from './dialog_keys.js';import { isNetworkTypeError, connectionLostText } from './browser_extension.js';import { issueButton } from './issue_button.js';+import { applyTasks, toggledTask } from './task_groups.js';const style = document.createElement('link');style.rel = 'stylesheet'; style.href = new URL('./library.css', import.meta.url).href; document.head.append(style);@@ -321,6 +322,7 @@ export function openLibrary(t, {upscale = null, selectedWork = null, extend = nuremove: () => remove(row)}));notice.textContent = '';for (const [file, card] of cards) card.setAttribute('aria-pressed', String(selecting ? picked.has(file) : file === selected));+ fold();}// These are the saved generation's measurements, including when the// same MP4 has since been reused. Never substitute the active request.@@ -414,7 +416,7 @@ export function openLibrary(t, {upscale = null, selectedWork = null, extend = nu// Other views of the library (the studio's Recent videos) drop it too.window.dispatchEvent(new CustomEvent('freevideo-library-deleted', {detail: {video: row.video}}));if (disposed) return;- rows.delete(row.video); cards.get(row.video)?.remove(); cards.delete(row.video);+ rows.delete(row.video); cards.get(row.video)?.remove(); cards.delete(row.video); fold();if (selected === row.video) {selected = null; frame.replaceChildren(); links.replaceChildren(); date.textContent = geometry.textContent = '';stats.hidden = true; stats.replaceChildren(); budget.textContent = '';@@ -427,6 +429,13 @@ export function openLibrary(t, {upscale = null, selectedWork = null, extend = nu// --- Selecting several creations ---const gb = bytes => `${(bytes / 2 ** 30).toFixed(bytes < 2 ** 30 ? 2 : 1)} GB`;const ordered = () => [...grid.querySelectorAll('.fv-library-card')];+ // The videos of one task fold under the newest; one task is unfolded at a time, and picking shows every card.+ let unfolded = null;+ function fold() {+ const order = ordered().map(card => card.dataset.video);+ if (!order.some(video => rows.get(video)?.task === unfolded)) unfolded = null;+ applyTasks({cards, rows, order, open: unfolded, selecting, selected, t, label: video => cardLabel(rows.get(video))});+ }const dayOf = video => (rows.get(video)?.id || '').slice(0, 10);const lastDay = () => dayOf(ordered().at(-1)?.dataset.video);const dayName = day => {@@ -499,6 +508,7 @@ export function openLibrary(t, {upscale = null, selectedWork = null, extend = nucard.classList.toggle('fv-picked', selecting && picked.has(video));card.setAttribute('aria-pressed', String(selecting ? picked.has(video) : video === selected));}+ fold();pickAll.disabled = deleting; pickNone.disabled = deleting || !picked.size;for (const heading of grid.querySelectorAll('.fv-library-day')) {const videos = ordered().map(card => card.dataset.video).filter(video => dayOf(video) === heading.dataset.day);@@ -623,7 +633,7 @@ export function openLibrary(t, {upscale = null, selectedWork = null, extend = nuremoved.add(video);window.dispatchEvent(new CustomEvent('freevideo-library-deleted', {detail: {video}}));if (disposed) continue;- rows.delete(video); cards.get(video)?.remove(); cards.delete(video);+ rows.delete(video); cards.get(video)?.remove(); cards.delete(video); fold();}};let undoFor = 10;@@ -715,7 +725,12 @@ export function openLibrary(t, {upscale = null, selectedWork = null, extend = nuif (!row?.video || (favoritesOnly && !row.favorite)) return;rows.set(row.video, row);if (cards.has(row.video)) { syncFavorite(row); return; }- const card = button('', event => selecting ? pick(row.video, event.shiftKey) : select(rows.get(row.video)), 'fv-library-card');+ const card = button('', event => {+ if (selecting) { pick(row.video, event.shiftKey); return; }+ // A cover with others under it also opens them in place.+ unfolded = toggledTask(rows, ordered().map(item => item.dataset.video), row.video, unfolded);+ select(rows.get(row.video)); fold();+ }, 'fv-library-card');card.dataset.video = row.video;card.setAttribute('aria-label', cardLabel(row));card.setAttribute('aria-pressed', String(selecting ? picked.has(row.video) : row.video === selected));@@ -737,7 +752,7 @@ export function openLibrary(t, {upscale = null, selectedWork = null, extend = nu}card.append(picture, el('span', row.agent?.label || timestamp(row)), el('small', row.agent?.label ? timestamp(row) : dimensions(row)));cards.set(row.video, card); first ? grid.prepend(card) : grid.append(card); thumbnails.observe(image);- if (selecting) regroup();+ if (selecting) regroup(); else if (first) fold();}async function load(appendPage) {if (disposed || (loading && appendPage)) return false;@@ -761,7 +776,7 @@ export function openLibrary(t, {upscale = null, selectedWork = null, extend = nuif (!narrow.matches && rows.size) select(rows.values().next().value, false);else dialog.dataset.detail = 'false';} else select(rows.get(selected), false);- ok = true; regroup();+ ok = true; regroup(); fold();if (selectedWork) { const row = [...rows.values()].find(row => row.id === selectedWork || row.video === selectedWork); if (row) { select(row); selectedWork = null; } else if (next) queueMicrotask(() => load(true)); }} catch (error) {if (!disposed && round === loadRound && error.name !== 'AbortError') {@@ -799,7 +814,7 @@ export function openLibrary(t, {upscale = null, selectedWork = null, extend = nuconst deletedElsewhere = event => {const video = event.detail?.video;if (!video || !rows.has(video)) return;- rows.delete(video); cards.get(video)?.remove(); cards.delete(video);+ rows.delete(video); cards.get(video)?.remove(); cards.delete(video); fold();if (selected === video) { selected = null; frame.replaceChildren(); links.replaceChildren(); date.textContent = geometry.textContent = ''; stats.hidden = true; stats.replaceChildren(); budget.textContent = ''; dialog.dataset.detail = 'false'; }picked.delete(video);};diff --git a/web/studio.css b/web/studio.cssindex 648fd68..fecdec1 100644--- a/web/studio.css+++ b/web/studio.css@@ -290,3 +290,9 @@.fv-studio .fv-swap-meter[data-indeterminate=true]>i{width:32%;animation:fv-swap-sweep 1.4s ease-in-out infinite}@keyframes fv-swap-sweep{from{transform:translateX(-100%)}to{transform:translateX(320%)}}@media (max-width:480px){.fv-studio .fv-swap-slots{grid-template-columns:1fr}.fv-studio .fv-swap-source{order:1}.fv-studio .fv-swap-sound{order:2}.fv-studio .fv-swap-person{order:3}}+/* Recent videos: the same folding as Creations; the videos under an opened cover are indented. */+.fv-studio .fv-recent-card[hidden]{display:none}+.fv-recent-card.fv-task-head:not(.fv-task-open) .fv-library-picture{box-shadow:4px -4px 0 0 var(--fv-sheen)}+.fv-studio .fv-recent-card.fv-task-member{margin-left:12px;animation:fv-task-reveal .2s ease}+@keyframes fv-task-reveal{from{opacity:0;transform:translateY(-4px)}}+@media(prefers-reduced-motion:reduce){.fv-studio .fv-recent-card.fv-task-member{animation:none}}diff --git a/web/studio_recent.js b/web/studio_recent.jsindex f1ded0f..429619e 100644--- a/web/studio_recent.js+++ b/web/studio_recent.js@@ -1,5 +1,6 @@import { libraryPage, videoTimestamp, videoDimensions, videoThumbnailURL } from './library.js';import { icon } from './result_actions.js';+import { applyTasks, toggledTask } from './task_groups.js';const KEY = 'fv-studio-recent-rail';const el = (tag, text, cls) => {@@ -23,7 +24,8 @@ export function createRecentVideos(t, {body, onSelect}) {// as a panel over the preview; it starts closed each time, so a saved column never covers the picture.const wide = window.matchMedia('(min-width:1680px)');let expanded = true, open = false, selected = null, disposed = false, request = null, resizeTimer = null;- const cards = new Map();+ const cards = new Map(), byVideo = new Map();+ let order = [], unfolded = null;try { expanded = localStorage.getItem(KEY) !== 'false'; } catch {}function visibility() {const shown = wide.matches ? expanded : open;@@ -85,9 +87,14 @@ export function createRecentVideos(t, {body, onSelect}) {target.src = target.dataset.src; thumbnails.unobserve(target);}}, {root: list, rootMargin: '80px'});+ const cardLabel = video => `${videoTimestamp(byVideo.get(video), t)} · ${videoDimensions(byVideo.get(video))}`;+ function fold() {+ applyTasks({cards, rows: byVideo, order, open: unfolded, selected, t, label: cardLabel});+ }function setSelected(video) {selected = video;for (const [file, card] of cards) card.setAttribute('aria-pressed', String(file === selected));+ fold();}async function refresh() {if (disposed) return [];@@ -96,22 +103,30 @@ export function createRecentVideos(t, {body, onSelect}) {try {const data = await libraryPage(t, {limit: 24, signal: controller.signal});if (disposed || controller.signal.aborted) return [];- thumbnails.disconnect(); cards.clear(); list.replaceChildren();+ thumbnails.disconnect(); cards.clear(); byVideo.clear(); list.replaceChildren();// The library API returns newest first, with the same preview metadata.const rows = (data.items || []).filter(row => row?.video).slice(0, 24);for (const row of rows) {const card = el('button', null, 'fv-recent-card'); card.type = 'button';const date = videoTimestamp(row, t), dimensions = videoDimensions(row);card.setAttribute('aria-label', `${date} · ${dimensions}`);- card.onclick = () => { onSelect(row); hidePanel({restoreFocus: true}); };+ card.onclick = () => {+ // A cover with others under it opens them in place and keeps the panel; any other card is the choice.+ const next = toggledTask(byVideo, order, row.video, unfolded);+ onSelect(row);+ if (next !== unfolded || card.classList.contains('fv-task-head')) { unfolded = next; fold(); return; }+ hidePanel({restoreFocus: true});+ };const picture = el('div', null, 'fv-library-picture');const image = el('img'); image.alt = ''; image.decoding = 'async';image.dataset.src = videoThumbnailURL(row);image.onerror = () => { image.hidden = true; };picture.append(image);card.append(picture, el('span', date), el('small', dimensions));- cards.set(row.video, card); list.append(card); thumbnails.observe(image);+ cards.set(row.video, card); byVideo.set(row.video, row); list.append(card); thumbnails.observe(image);}+ order = rows.map(row => row.video);+ if (!order.some(video => byVideo.get(video).task === unfolded)) unfolded = null;message.textContent = t('Videos you generate appear here.', '生成的视频会显示在这里。');message.hidden = rows.length > 0; list.append(message);setSelected(selected);diff --git a/web/task_groups.js b/web/task_groups.jsnew file mode 100644index 0000000..c8e7ead--- /dev/null+++ b/web/task_groups.js@@ -0,0 +1,45 @@+// Videos made by one task (a preview and its upscale, a continuation, one agent job, the same prompt on one day)+// share the `task` the library API gives them. A list shows the newest as the cover; the others fold under it+// until the cover is pressed again. Both lists (Recent videos and Creations) fold with this one rule.++// Marks the cards of `order` (video ids, newest first) for their tasks. `open` is the task now unfolded;+// while picking several creations every card shows.+export function applyTasks({cards, rows, order, open = null, selecting = false, selected = null, t, label}) {+ const groups = new Map();+ for (const video of order) {+ const task = rows.get(video)?.task;+ if (task) groups.set(task, [...(groups.get(task) || []), video]);+ }+ const heads = new Map();+ for (const [task, videos] of groups) if (videos.length > 1) heads.set(videos[0], {task, videos});+ for (const video of order) {+ const card = cards.get(video);+ if (!card) continue;+ const task = rows.get(video)?.task, group = task && groups.get(task);+ const folded = group && group.length > 1;+ const shown = folded && (selecting || open === task);+ const head = heads.get(video);+ card.classList.toggle('fv-task-head', !!head);+ card.classList.toggle('fv-task-open', !!head && shown);+ card.classList.toggle('fv-task-member', !!folded && !head);+ card.hidden = !!folded && !head && !shown;+ if (head && !selecting) {+ card.setAttribute('aria-expanded', String(shown));+ card.setAttribute('aria-label', t(`${group.length} results`, `${group.length} 个结果`));+ // A folded cover stands for every video under it.+ if (!shown) card.setAttribute('aria-pressed', String(group.includes(selected)));+ } else {+ card.removeAttribute('aria-expanded');+ card.setAttribute('aria-label', label(video));+ }+ }+ return heads;+}++// The task to unfold when `video` is pressed: only a cover with others under it unfolds, and pressing it again folds it.+export function toggledTask(rows, order, video, open) {+ const task = rows.get(video)?.task;+ if (!task || order.find(item => rows.get(item)?.task === task) !== video) return open;+ if (order.filter(item => rows.get(item)?.task === task).length < 2) return open;+ return open === task ? null : task;+}