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.
First-frame reference: any unreadable first frame falls back; smaller reference picture
Bowen Xuefb7116db5e7d
diff --git a/freevideo_engine/continuation.py b/freevideo_engine/continuation.pyindex 594a6de..f4dc9b8 100644--- a/freevideo_engine/continuation.py+++ b/freevideo_engine/continuation.py@@ -22,6 +22,10 @@ FIRST_FRAME_NOTE = ('The reference image is the very first frame of this whole f'location, framing and colour tone as in that image throughout.')FIRST_FRAME_MAX_BYTES = 8 * 1024 * 1024FIRST_FRAME_MAX_SIDE = 4096+# The picture the model is given is half the side of the film's first frame, but not under this+# on its short side: on a real six-part chain it held framing and colour as well as the full+# picture for a third of the extra sampling time. Smaller pictures are not tested.+FIRST_FRAME_REFERENCE_SHORT = 384VERSION = 1MISSING = 'The previous video has no usable continuation data. Generate it again with this version of FreeVideo.'@@ -138,13 +142,38 @@ def unpack_first_frame(value):raise ValueError('Invalid first frame') from None+def first_frame_reference(raw):+ """(PNG bytes, width, height) of the reference picture made from a kept first frame."""+ import io+ from PIL import Image+ with Image.open(io.BytesIO(raw)) as image:+ width, height = image.size+ scale = max(.5, FIRST_FRAME_REFERENCE_SHORT / min(width, height))+ if scale >= 1:+ return raw, width, height+ small = image.convert('RGB').resize((round(width * scale), round(height * scale)), Image.LANCZOS)+ target = io.BytesIO()+ small.save(target, format='PNG')+ return target.getvalue(), small.width, small.height++def chain_first_frame(request, video_path=None):"""The first frame of the whole film `request` continues, as record metadata; None when nothing has it.A continued video's record carries it from its own source. The first part of a film neverstored one: its saved video starts with that frame. A continued part made before records- carried the frame has no way back to it.+ carried the frame has no way back to it. Anything that keeps it from being read is a ValueError,+ so every caller falls back the same way."""+ try:+ return _chain_first_frame(request, video_path)+ except (ValueError, MemoryError):+ raise+ except Exception:+ raise ValueError('Invalid first frame') from None+++def _chain_first_frame(request, video_path):metadata = _snapshot_value(request)['metadata']if metadata.get('first_frame') is not None:unpack_first_frame(metadata['first_frame'])diff --git a/freevideo_engine/generate.py b/freevideo_engine/generate.pyindex f1f0d06..6771089 100644--- a/freevideo_engine/generate.py+++ b/freevideo_engine/generate.py@@ -395,7 +395,7 @@ def _run(args):continuation = prepare_continuation(continue_from, canvas)continuation = dict(continuation, audio_context=audio_context(), source_video=str(continue_from))if first_frame is not None:- from .continuation import anchor_media, chain_first_frame, unpack_first_frame+ from .continuation import anchor_media, chain_first_frame, first_frame_reference, unpack_first_frametry:kept = chain_first_frame(continuation, continue_from)except ValueError:@@ -409,11 +409,12 @@ def _run(args):raise FileExistsError(args.out.resolve())args.out.resolve().parent.mkdir(parents=True, exist_ok=True)continue_anchor = args.out.resolve().with_suffix('.first-frame.png')- continue_anchor.write_bytes(unpack_first_frame(kept))+ picture, picture_width, picture_height = first_frame_reference(unpack_first_frame(kept))+ continue_anchor.write_bytes(picture)media = anchor_media(media, continue_anchor)validate_route(task=getattr(args, 'task', None) or 'ref2va', anchor=True, two_pass=two_pass,preview=preview, refine_from=getattr(args, 'refine_from', None), media=media)- first_frame.update(used=True, width=kept['width'], height=kept['height'])+ first_frame.update(used=True, width=picture_width, height=picture_height)if continue_anchor is not None:continuation['anchor'] = media['references'][0]active_loras = [row for row in media.get('loras', []) if row['strength'] != 0]