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.
Chain repairs only the seams it was told to, never lets one repair stand in for another, and...
Bowen Xue3125a5dfbe17
diff --git a/freevideo_engine/chain_join.py b/freevideo_engine/chain_join.pyindex 4f41a00..1116a6c 100644--- a/freevideo_engine/chain_join.py+++ b/freevideo_engine/chain_join.py@@ -174,6 +174,10 @@ def _join_files(sources, target, cancelled, frames, exact=True, leads=None, expeif leads is not None and audio_lead_in is not None:stored = audio_lead_indef audio_lead_in(video, previous=None):+ if expected is not None:+ # The caller named the seams that must be repaired and keeps their sound itself;+ # a shared record for any other pair of videos must not stand in for them.+ return leads(video, previous)return leads(video, previous) or stored(video, previous=previous)sources, target = [Path(source) for source in sources], Path(target)if len(sources) < 2:diff --git a/freevideo_engine/chain_leads.py b/freevideo_engine/chain_leads.pyindex 66b1229..bfa0f90 100644--- a/freevideo_engine/chain_leads.py+++ b/freevideo_engine/chain_leads.py@@ -44,13 +44,14 @@ def load(directory, chain, index, previous, output=None):import numpy as npfrom .continuation import LEAD_IN_SAMPLES, LEAD_IN_FADE, LEAD_IN_RATEtry:- with np.load(_path(directory, chain, index), allow_pickle=False) as data:+ with open(_path(directory, chain, index), 'rb') as stream, np.load(stream, allow_pickle=False) as data:samples, kept = data['samples'], str(data['previous'])own = str(data['output']) if 'output' in data.files else ''if kept and kept != previous or own and output is not None and own != output or samples.dtype != np.float32 or samples.shape != (LEAD_IN_SAMPLES + LEAD_IN_FADE, 2):return Nonereturn dict(samples=samples, before=LEAD_IN_SAMPLES, fade=LEAD_IN_FADE, sample_rate=LEAD_IN_RATE)- except (OSError, ValueError, KeyError, TypeError, EOFError):+ except Exception:+ # Damaged storage (a bad checksum or archive directory included) is the same as no copy.return None@@ -62,12 +63,14 @@ def has(directory, chain, index):def prune(directory, chains):- """Drop the kept leads of chains the store no longer lists; a listed chain keeps all of them,- because a longer chain is joined again from its first block."""+ """Drop the kept leads of chains whose record is gone; a chain that still has its record file keeps+ all of them, because a longer chain is joined again from its first block. `chains` is what the+ caller loaded; a record beyond its limit or one it could not read is still on disk."""chains = set(chains)try:for path in Path(directory).glob('c-*' + SUFFIX):- if path.name.split('.', 1)[0] not in chains:+ chain = path.name.split('.', 1)[0]+ if chain not in chains and not (Path(directory) / (chain + '.json')).exists():path.unlink(missing_ok=True)except OSError:logging.warning('[FreeVideo] Chain seam sound could not be removed')diff --git a/freevideo_engine/chain_runner.py b/freevideo_engine/chain_runner.pyindex 797efd8..2111040 100644--- a/freevideo_engine/chain_runner.py+++ b/freevideo_engine/chain_runner.py@@ -297,19 +297,23 @@ class ChainRunner:return isinstance(row['after'], str) and bool(row['continuation'])def _seams_kept(self, snapshot):- """(expected, kept) seam sounds of the leading blocks, keeping late any a record still has."""+ """(indexes of the seams that must be repaired, how many of them have their sound), keeping+ late any a shared record still has. A seam is the pair of neighbours in the joined video, so a+ block that continues from a block other than its neighbour cannot be repaired and counts as lost."""identity, blocks = snapshot['id'], store.leading_blocks(snapshot)- expected = kept = 0- for row in blocks[1:] if getattr(self.host, 'repairs_seams', True) else ():+ wanted, kept = set(), 0+ for position, row in enumerate(blocks[1:] if getattr(self.host, 'repairs_seams', True) else (), 1):if not self._continues(row):continue- expected += 1- after = self._sources(snapshot, row)['after']- if chain_leads.load(self.store_dir, identity, row['index'], after['output'], row['output']) is not None:+ wanted.add(row['index'])+ neighbour = blocks[position - 1]+ if row['after'] != neighbour['id']:+ continue+ if chain_leads.load(self.store_dir, identity, row['index'], neighbour['output'], row['output']) is not None:kept += 1- elif self._keep_lead(identity, row['index'], row['output'], after['output'], True):+ elif self._keep_lead(identity, row['index'], row['output'], neighbour['output'], True):kept += 1- return expected, kept+ return wanted, keptdef _finish_blocks(self, record, final_state='done'):if not record['join']:@@ -501,16 +505,23 @@ class ChainRunner:return self.closed.is_set() or (final_state != 'cancelled'and self.records[identity]['state'] == 'cancelling')index_by_output = {row['output']: row['index'] for row in snapshot['blocks'] if row['output']}+ wanted = set()def lead_reader(following, previous):+ # Only a seam that must be repaired gets a sound; another seam is never counted for it.index = index_by_output.get(following)- return chain_leads.load(self.store_dir, identity, index, previous, following) if index is not None else None- promised, kept = self._seams_kept(snapshot)- snapshot = dict(snapshot, lead_reader=lead_reader, expected_seams=promised)+ if index is None or index not in wanted:+ return None+ return chain_leads.load(self.store_dir, identity, index, previous, following)texts = [row['inputs']['text'] for row in snapshot['blocks']]texts += [row['inputs'].get('text') for row in snapshot['snapshot']['prompt'].values()if isinstance(row, dict) and isinstance(row.get('inputs'), dict)]failure = None+ promised = kept = 0try:+ found, kept = self._seams_kept(snapshot)+ wanted.update(found)+ promised = len(wanted)+ snapshot = dict(snapshot, lead_reader=lead_reader, expected_seams=promised)if kept < promised:# A sound seam that cannot be repaired is never published as a finished video.raise ValueError('%d of %d seam sounds were not kept' % (promised - kept, promised))