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.
Agent: reference pictures give way to first_frame_reference as the engine does
Bowen Xueeb932534a7d1
diff --git a/freevideo_engine/agent/drama.py b/freevideo_engine/agent/drama.pyindex 8d1e115..0ec7e13 100644--- a/freevideo_engine/agent/drama.py+++ b/freevideo_engine/agent/drama.py@@ -150,16 +150,16 @@ def check(play):validate(specs._int, shot[field], path + '/' + field, low, high)if 'seconds' in shot:validate(specs._number, shot['seconds'], path + '/seconds', 1.625, 60.)- modes = int(shot.get('first') is not None) + int(bool(shot.get('continue'))) + int('references' in shot)- if modes > 1:- problem(path, 'first, continue and references are mutually exclusive')+ # A continuing shot starts from the previous one and may add reference pictures, never a first frame.+ if shot.get('first') is not None and (shot.get('continue') or shot.get('references')):+ problem(path, 'first is exclusive with continue and references')# Continuing a shot, or one longer than one 15 s block, needs two-pass text generation.seconds = shot.get('seconds', play.get('seconds'))long = isinstance(seconds, (int, float)) and not isinstance(seconds, bool) and seconds > 15if ((shot.get('continue') or long) and play.get('quality') in specs.QUALITYand not specs.QUALITY[play['quality']][0] and all(p['path'] != '/quality' for p in problems)):problem('/quality', '"light" (two-pass) when a shot continues another or is longer than 15 s')- if long and (shot.get('first') is not None or 'references' in shot):+ if long and (shot.get('first') is not None or shot.get('references') and not shot.get('continue')):problem(path + '/seconds', 'at most 15 with a first frame or references')elif long and not shot.get('continue') and _carded(play, shot):# Cast cards travel as references, which one generation of at most 15 s carries.@@ -171,9 +171,13 @@ def check(play):refs = shot['references']if not isinstance(refs, list) or len(refs) > 32:problem(path + '/references', 'must be a list of at most 32 items')+ elif shot.get('continue') and len(refs) > specs.CONTINUED_PICTURES:+ problem(path + '/references', 'at most %d pictures when the shot continues' % specs.CONTINUED_PICTURES)if isinstance(refs, list):for j, ref in enumerate(refs):- validate(specs.media_item, ref, path + '/references/%d' % j)+ validate(specs.media_item, ref, path + '/references/%d' % j, image=bool(shot.get('continue')))+ if shot.get('continue') and not specs.still_picture(ref):+ problem(path + '/references/%d' % j, 'must be a picture when the shot continues')if 'cast' in shot:if not isinstance(shot['cast'], list):problem(path + '/cast', 'must be a list of character names')@@ -291,21 +295,20 @@ def cast_references(play, shot, cards, *, continues=False):cards maps a card ID to the current card, or None once it is gone. The samefunction serves plan previews and the moment a take is submitted.- cast_reference: None (no character in the shot has a card), 'inherited'- (continues the previous shot), 'own' (the shot names its own first frame or- references), 'missing' (a card was deleted), 'partial' (not everyone fit)- or 'cards'. 'omitted' lists people left out entirely; 'voice_omitted' lists- people whose pictures are carried but whose voice did not fit."""+ cast_reference: None (no character in the shot has a card), 'own' (the shot+ names its own first frame or references), 'missing' (a card was deleted),+ 'partial' (not everyone fit) or 'cards'. 'omitted' lists people left out+ entirely; 'voice_omitted' lists people whose pictures are carried but whose+ voice did not fit. A shot that continues the previous one carries one picture+ per person (the sheet, else the front view) for at most CONTINUED_PICTURES+ people, and no voice clip: its voices carry on from the previous shot."""characters = play.get('characters', {})keys = [k for k in cast(play, shot) if isinstance(characters[k].get('card'), str)]result = dict(cast_reference=None, people=[], omitted=[], voice_omitted=[], missing=[], references=[],prefix=None, subjects=[], cards={})if not keys:return result- if continues:- result['cast_reference'] = 'inherited'- return result- if shot.get('first') is not None or 'references' in shot:+ if shot.get('first') is not None or shot.get('references'):result['cast_reference'] = 'own'return resultspoken = {}@@ -320,6 +323,12 @@ def cast_references(play, shot, cards, *, continues=False):result['missing'].append(key)continueimages = _pictures(card)+ if continues:+ if images and len(chosen) < specs.CONTINUED_PICTURES:+ chosen.append((key, card, images[:1], False))+ else:+ result['omitted'].append(key)+ continuevoice = card.get('voice') is not None and voices < MAX_VOICESif pictures + len(images) + voices + voice > MAX_REFERENCES:result['omitted'].append(key)diff --git a/freevideo_engine/agent/guide.py b/freevideo_engine/agent/guide.pyindex e94e477..d981749 100644--- a/freevideo_engine/agent/guide.py+++ b/freevideo_engine/agent/guide.py@@ -75,7 +75,8 @@ GUIDE = {'Under 30 s defaults to one generation when the device supports this size and quality; unknown limits use 15 s. ''Otherwise it uses as few parts as possible, each at least 10 s; how many depends on how long this computer can generate in one run, and the parts continue and join automatically. ''Multiple blocks or continue_from need two-pass text generation: quality "light" '- 'or sampling.two_pass=true, no preview and no media. '+ 'or sampling.two_pass=true and no preview. Their only media is media.references with at most 3 pictures, '+ 'which every continuing part also sees (keeps the same people); first_frame_reference then gives way to them. ''Multi-block output is cut to the planned duration. POST /plan shows the chain plan. ''For a video in several parts, part_prompts gives each part its own description in order (as many as ''chain_plan.blocks from POST /plan), so each part continues the story instead of replaying it; '@@ -533,7 +534,8 @@ GUIDE['cast'] = ['Changes need the revision you read (body revision or If-Match); stale_revision returns the current card in ''error.card. Fields the user changed return changed_by_user: keep the user\'s version.','Film with a card by setting characters.<key>.card. Cards are read when each take is submitted. Shots that '- 'continue the previous one carry no references (cast_reference inherited); POST /drama/plan shows each shot\'s cast. '+ 'continue the previous one carry one card picture per person (the sheet, else the front) for at most 3 people, '+ 'and keep the voices of the previous shot; POST /drama/plan shows each shot\'s cast. ''A shot with a carded character is at most 15 s; continue it in the next shot to go longer.','POST /cast/{id}/generate makes reference pictures from the description as a normal job (face=true adds a close-up). ''It defaults to the installed image model, otherwise video frames (labels guessed, label_guess). 'diff --git a/freevideo_engine/agent/jobs.py b/freevideo_engine/agent/jobs.pyindex c02cf7a..1545127 100644--- a/freevideo_engine/agent/jobs.py+++ b/freevideo_engine/agent/jobs.py@@ -136,9 +136,14 @@ def continuation_problems(spec, prefix='', *, editor=None):problems.append(dict(problem, got=got, message=problem['message'].replace('received None', 'received ' + got)))if spec['preview']:problems.append(schema.diagnostic(prefix + '/preview', 'false' + why, True))- if spec['media']:- problems.append(schema.diagnostic(prefix + '/media', 'none' + why + ' (continue_from carries the previous video)',+ others = [key for key, value in spec['media'].items() if key != 'references' and value]+ pictures = spec['media'].get('references') or []+ if others:+ problems.append(schema.diagnostic(prefix + '/media', 'only references' + why + ' (continue_from carries the previous video)',None))+ elif len(pictures) > specs.CONTINUED_PICTURES or not all(specs.still_picture(item) for item in pictures):+ problems.append(schema.diagnostic(prefix + '/media/references', 'at most %d pictures%s' % (specs.CONTINUED_PICTURES, why),+ len(pictures)))return problemsdiff --git a/freevideo_engine/agent/production.py b/freevideo_engine/agent/production.pyindex 07a5c72..4c0a515 100644--- a/freevideo_engine/agent/production.py+++ b/freevideo_engine/agent/production.py@@ -266,11 +266,10 @@ def _schedule(state, shot, count, by, note=None, *, automatic=False):job.pop('media', None)if job['project'] is None:job.pop('project')- if not shot['continues']:- if source.get('first') is not None:- job['media'] = {'first': deepcopy(source['first'])}- elif 'references' in source:- job['media'] = {'references': deepcopy(source['references'])}+ if source.get('first') is not None and not shot['continues']:+ job['media'] = {'first': deepcopy(source['first'])}+ elif source.get('references'):+ job['media'] = {'references': deepcopy(source['references'])}jobs.append(dict(take=None, job=None, generation=None, seed=None, state='queued', automatic=automatic,stale=False, continues_take=None, note=note, by=by, library_id=None, seconds=None,cancel_requested=False, error=None, spec=job))diff --git a/freevideo_engine/agent/schema.py b/freevideo_engine/agent/schema.pyindex 6e6b423..79f7376 100644--- a/freevideo_engine/agent/schema.py+++ b/freevideo_engine/agent/schema.py@@ -57,7 +57,7 @@ SLUG = string(64, pattern=r'^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$')REF = string(128, pattern=r'^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$',description='Idempotency key; reuse only with the same request content. Batch row refs also name dependencies.')FILE = string(1024, pattern=r'^(?!/)(?!.*(?:\\|:))(?!.*(?:^|/)\.\.(?:/|$)).+$')-FRAME = {'oneOf': [enum(('first', 'last')), number(0)]}+FRAME = {'oneOf': [enum(('first', 'last')), number(0, 86400)]} # Seconds into the video; the bound keeps it a float.WAIT = number(0, default=0, description='x-clamp caps accepted wait values at 25 seconds without rejecting larger values.', **{'x-clamp': 25})CLIENT_WAIT = number(0, 25, default=25)# Waiting for the user's words is longer: a person types slowly, and each wait is one tool call.@@ -859,8 +859,8 @@ def drama_route_table():CAST_REFERENCE = {'enum': [None, 'cards', 'partial', 'missing', 'inherited', 'own'],'description': 'How the shot carries cast cards: cards; partial (cast_omitted did not fit at all, or ''cast_voice_omitted came without their voice); missing '- '(a card was deleted, cast_missing shoot from text); inherited (continues the '- 'previous shot); own (the shot names its own first frame or references); null.'}+ '(a card was deleted, cast_missing shoot from text); inherited (a film made before continuing '+ 'shots carried cards); own (the shot names its own first frame or references); null.'}def production_response():@@ -1087,8 +1087,9 @@ def cross_issues(schema, value, path):if value.get('scene_image') and not value.get('people'):bad('scene_image', 'omitted unless people is supplied', value['scene_image'])if kind == 'generate':- if value.get('continue_from') and value.get('media'):- bad('media', 'omitted when continue_from is supplied', value['media'])+ if value.get('continue_from') and isinstance(value.get('media'), dict) and any(+ v is not None for k, v in value['media'].items() if k != 'references'):+ bad('media', 'only references when continue_from is supplied', value['media'])if value.get('refine_from') is None:custom = value.get('sampling', {})two, base, refine = QUALITY[value.get('quality', 'light')]diff --git a/freevideo_engine/agent/spec.py b/freevideo_engine/agent/spec.pyindex e1af7de..3997350 100644--- a/freevideo_engine/agent/spec.py+++ b/freevideo_engine/agent/spec.py@@ -9,6 +9,8 @@ from .length import single_frame_limitQUALITY, ASPECTS = contract.QUALITY, contract.ASPECTSKINDS = tuple(contract.KINDS)FRAMES = ('first', 'last')+# A part that continues a video carries at most this many reference pictures, and no other reference media.+CONTINUED_PICTURES = 3MAX_SEED = contract.generate()['properties']['seed']['maximum']JOB_ID = re.compile(contract.JOB['pattern'].strip('^$'))LIBRARY_ID = re.compile(contract.SAVED['pattern'].strip('^$'))@@ -142,6 +144,19 @@ def generation_media(value):return result+def still_picture(item):+ """A reference that is one picture: a frame of a video, or a picture file."""+ if isinstance(item, str):+ item = {'file': item}+ if not isinstance(item, dict):+ return False+ if 'frame' in item:+ return True+ from ..comfy_assets import EXTENSIONS+ source = item.get('file') or item.get('path')+ return isinstance(source, str) and source.lower().endswith(tuple(EXTENSIONS['image']))++def task(media):if media.get('references'):return 'ref2va'