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.
Keep an unreadable launcher settings file aside; startup survives unreadable sessions and films
Bowen Xue76f1858de6ca
diff --git a/freevideo_engine/agent/productions.py b/freevideo_engine/agent/productions.pyindex 2e4f63e..6ee2c11 100644--- a/freevideo_engine/agent/productions.py+++ b/freevideo_engine/agent/productions.py@@ -177,7 +177,12 @@ class Productions:jobs.parent_allowed = self.allowsdef load(self):- for path in sorted(self.directory.glob('*.json')):+ try:+ paths = sorted(self.directory.glob('*.json'))+ except OSError:+ logging.getLogger(__name__).warning('Could not list saved films; starting without them')+ return+ for path in paths:try:record = json.loads(path.read_text(encoding='utf-8'))state = record['state']@@ -209,8 +214,13 @@ class Productions:record['stalled']['code'])self.records[state['id']] = recordexcept (ValueError, KeyError, TypeError, AttributeError, IndexError, RecursionError, OSError):- path.replace(path.with_name(path.name + '.bad-' + uuid.uuid4().hex))- logging.getLogger(__name__).warning('Isolated an invalid production receipt; other films remain available')+ try:+ path.replace(path.with_name(path.name + '.bad-' + uuid.uuid4().hex))+ except OSError:+ # A receipt that cannot be moved aside is left in place; the agent still starts.+ logging.getLogger(__name__).warning('Skipped an invalid production receipt that could not be renamed')+ else:+ logging.getLogger(__name__).warning('Isolated an invalid production receipt; other films remain available')def _stalled(self, error):code = error.code if isinstance(getattr(error, 'code', None), str) and error.code in errors.ERRORS else 'internal_error'diff --git a/freevideo_engine/agent/sessions.py b/freevideo_engine/agent/sessions.pyindex ab5f9c8..064402b 100644--- a/freevideo_engine/agent/sessions.py+++ b/freevideo_engine/agent/sessions.py@@ -5,6 +5,7 @@ import asynciofrom copy import deepcopyfrom datetime import datetime, timezoneimport json+import loggingimport osfrom pathlib import Pathimport secrets@@ -87,40 +88,56 @@ class Sessions:return self._meta[sid]def _load(self):- for path in sorted(self.root.glob('s*.jsonl')):+ try:+ paths = sorted(self.root.glob('s*.jsonl'))+ except OSError:+ logging.getLogger(__name__).warning('Could not list saved sessions; starting without them')+ return+ for path in paths:sid = path.stemif schema.issues(schema.SESSION, sid) or path.is_symlink():continue- with path.open('rb') as stream:- first = stream.readline()+ try:+ self._load_file(path, sid)+ except OSError:+ # One unreadable file must not stop the agent from starting.+ for table in (self._meta, self._ids, self._clients, self._acted, self._said, self._initial_seq, self._user_seq):+ table.pop(sid, None)+ self._chosen.discard(sid)+ self._partial.discard(sid)+ logging.getLogger(__name__).warning('Skipped an unreadable session file')++ def _load_file(self, path, sid):+ with path.open('rb') as stream:+ first = stream.readline()+ try:+ meta = json.loads(first)+ if not first.endswith(b'\n') or meta.get('session') != sid:+ return+ _check(schema.session_metadata(), meta)+ except (ValueError, UnicodeDecodeError, SessionError, AttributeError):+ return+ self._meta[sid] = dict(id=sid, title=meta['title'], created_at=meta['created_at'],+ updated_at=meta['created_at'], client=meta['client'], last_seq=0, stopped=False)+ self._ids[sid] = {}+ self._clients[sid] = {meta['client']} if meta['client'] else set()+ self._acted[sid] = (meta['created_at'], 1)+ if meta.get('by') == 'user':+ self._chosen.add(sid)+ for row in stream:+ if not row.endswith(b'\n'):+ self._partial.add(sid)+ breaktry:- meta = json.loads(first)- if not first.endswith(b'\n') or meta.get('session') != sid:+ event = json.loads(row)+ _check(schema.session_event(stored=True), event)+ if event['seq'] != self._meta[sid]['last_seq'] + 1:continue- _check(schema.session_metadata(), meta)- except (ValueError, UnicodeDecodeError, SessionError, AttributeError):+ except (ValueError, UnicodeDecodeError, SessionError):+ # Also skips an interrupted tail separated by a later append.continue- self._meta[sid] = dict(id=sid, title=meta['title'], created_at=meta['created_at'],- updated_at=meta['created_at'], client=meta['client'], last_seq=0, stopped=False)- self._ids[sid] = {}- self._clients[sid] = {meta['client']} if meta['client'] else set()- self._acted[sid] = (meta['created_at'], 1)- if meta.get('by') == 'user':- self._chosen.add(sid)- for row in stream:- if not row.endswith(b'\n'):- self._partial.add(sid)- break- try:- event = json.loads(row)- _check(schema.session_event(stored=True), event)- if event['seq'] != self._meta[sid]['last_seq'] + 1:- continue- except (ValueError, UnicodeDecodeError, SessionError):- # Also skips an interrupted tail separated by a later append.- continue- self._fold(sid, event)- self._initial_seq[sid] = self._meta[sid]['last_seq']+ self._fold(sid, event)+ self._initial_seq[sid] = self._meta[sid]['last_seq']def _fold(self, sid, event):meta = self._meta[sid]diff --git a/freevideo_engine/launcher_settings.py b/freevideo_engine/launcher_settings.pyindex 12314a7..c502e7d 100644--- a/freevideo_engine/launcher_settings.py+++ b/freevideo_engine/launcher_settings.py@@ -3,6 +3,7 @@ from contextlib import ExitStack, contextmanagerimport jsonimport osfrom pathlib import Path+import shutilimport sysimport time@@ -91,6 +92,34 @@ def read(path):return {}+KEPT_COPIES = 3+++def keep_unreadable(path):+ """Copy a settings file that exists but cannot be parsed aside before a save replaces it."""+ try:+ text = io_path(path).read_text(encoding='utf-8')+ if not text.strip() or isinstance(json.loads(text), dict):+ return None+ except FileNotFoundError:+ return None+ except (OSError, ValueError):+ pass+ kept = Path(str(path) + '.bad-' + time.strftime('%Y%m%d-%H%M%S'))+ try:+ shutil.copyfile(io_path(path), io_path(kept))+ except OSError:+ return None+ # A save that keeps failing leaves the file unreadable, so every retry copies it again.+ older = sorted(kept.parent.glob(Path(path).name + '.bad-*'))[:-KEPT_COPIES]+ for stale in older:+ try:+ io_path(stale).unlink()+ except OSError:+ pass+ return kept++def write(path, values, language, selection=None):payload = dict(values, language=language, installation=selection)save(path, sanitize(payload))@@ -174,6 +203,8 @@ class Store:previous = read(path)if previous:save(path.with_suffix('.previous.json'), previous)+ else:+ keep_unreadable(path)save(path, payload)written.append(path)except OSError as error: