Skip to content

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: a long video can take one description per part

Bowen Xueeebae0441555
diff --git a/freevideo_engine/agent/guide.py b/freevideo_engine/agent/guide.py
index 9230167..e94e477 100644
--- a/freevideo_engine/agent/guide.py
+++ b/freevideo_engine/agent/guide.py
@@ -77,6 +77,9 @@ GUIDE = {
'Multiple blocks or continue_from need two-pass text generation: quality "light" '
'or sampling.two_pass=true, no preview and no media. '
'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; '
+ 'without it FreeVideo splits prompt itself. '
'A continue_from job saves a new video that holds only the added part; to hand the user one video, '
'insert both into a project and export it.',
'first_frame_reference (default false) reduces drift in a continued video: each continuing part also '
diff --git a/freevideo_engine/agent/jobs.py b/freevideo_engine/agent/jobs.py
index 0f517fb..c02cf7a 100644
--- a/freevideo_engine/agent/jobs.py
+++ b/freevideo_engine/agent/jobs.py
@@ -157,6 +157,24 @@ def cut_problems(spec, seconds, prefix='', *, editor=None):
return [dict(problem, got=got, message=problem['message'].replace('received None', 'received ' + got))]
+def part_prompt_problems(spec, prefix=''):
+ """part_prompts gives one description per planned part; the chain backend refuses any other count."""
+ if spec['kind'] != 'generate' or not spec.get('part_prompts'):
+ return []
+ from ..chain_plan import PlanError, plan
+ try:
+ count = len(plan(spec['seconds'], max_frames=single_frame_limit(spec),
+ continued=bool(spec.get('continue_from')))['blocks'])
+ except PlanError:
+ return [] # parts_problems names the length.
+ given = len(spec['part_prompts'])
+ if given == count:
+ return []
+ allowed = '%d description%s, one for each of the chain_plan.blocks POST /plan gives for %g s' % (
+ count, '' if count == 1 else 's', spec['seconds'])
+ return [schema.diagnostic(prefix + '/part_prompts', allowed, given)]
+
+
def _continued_part_problem(seconds, chain):
"""True when a video that continues another has a part the backend refuses, or is under 10 s.
@@ -733,6 +751,7 @@ class Jobs:
work=self.continued_work(normalized),
planned=self.planned_parts(normalized, rows)))
problems.extend(cut_problems(normalized, normalized.get('seconds'), prefix, editor=editor))
+ problems.extend(part_prompt_problems(normalized, prefix))
try:
self.port.check(normalized)
except specs.SpecError as error:
@@ -1476,6 +1495,10 @@ class Jobs:
# Planned as a continuation, so the new video is as long as the request says.
payload.update(after=dict(work=self.port.output_relative(self.source_video(spec['continue_from']))),
text=prompt, seed=spec['seed'])
+ if spec.get('part_prompts') and 'seconds' in payload:
+ # Each part plays its own description, with the same LoRA trigger words the whole prompt gets.
+ from ..lora_triggers import apply_triggers
+ payload['texts'] = [apply_triggers(text, spec.get('loras', [])) for text in spec['part_prompts']]
self.start_chain(row, payload=payload)
work = asyncio.create_task(asyncio.to_thread(prepare))
try:
diff --git a/freevideo_engine/agent/routes.py b/freevideo_engine/agent/routes.py
index ef1e926..0dfc247 100644
--- a/freevideo_engine/agent/routes.py
+++ b/freevideo_engine/agent/routes.py
@@ -231,8 +231,8 @@ def plan(port, value, jobs=None):
result = dict(spec={k: v for k, v in spec.items() if k != 'depends_on'}, warnings=[])
if spec['kind'] != 'generate' or spec.get('refine_from'):
return result
- from .jobs import continuation_problems, cut_problems, parts_problems
- problems = continuation_problems(spec) + cut_problems(spec, spec['seconds'])
+ from .jobs import continuation_problems, cut_problems, part_prompt_problems, parts_problems
+ problems = continuation_problems(spec) + cut_problems(spec, spec['seconds']) + part_prompt_problems(spec)
if jobs is not None:
problems += parts_problems(spec, jobs.port.chain_runner(), work=jobs.continued_work(spec),
planned=jobs.planned_parts(spec))
diff --git a/freevideo_engine/agent/schema.py b/freevideo_engine/agent/schema.py
index 1e3d01c..6e6b423 100644
--- a/freevideo_engine/agent/schema.py
+++ b/freevideo_engine/agent/schema.py
@@ -162,11 +162,14 @@ def generate(*, local=False):
first_frame_reference={'type': 'boolean', 'default': False, 'description':
'Reduces drift over a continued video: every continuing part also sees the first frame of the whole '
'video. It holds framing and motion close to that frame.'},
+ part_prompts=array(string(20000), 1, 5, description='One description per part of a video made in several '
+ 'parts, in order, so each part plays its own share of the story. The count must equal the '
+ 'chain_plan.blocks POST /plan gives for this length. Omitted: FreeVideo splits prompt into parts before the first part.'),
takes=number(1, 8, integer=True, default=1), **common()),
allOf=[{'if': {'required': ['refine_from'], 'properties': {'refine_from': {'type': 'string'}}},
'then': {'properties': {k: False for k in ('prompt', 'width', 'height', 'aspect', 'megapixels',
'seconds', 'seed', 'quality', 'sampling', 'media', 'loras', 'preview', 'continue_from',
- 'first_frame_reference')}},
+ 'first_frame_reference', 'part_prompts')}},
'else': {'required': ['prompt']}},
{'if': {'anyOf': [{'required': [k]} for k in ('aspect', 'megapixels')]},
'then': {'not': {'anyOf': [{'required': [k]} for k in ('width', 'height')]}}},
diff --git a/freevideo_engine/agent/spec.py b/freevideo_engine/agent/spec.py
index 96ab196..e1af7de 100644
--- a/freevideo_engine/agent/spec.py
+++ b/freevideo_engine/agent/spec.py
@@ -191,6 +191,8 @@ def normalize(value, *, port=None):
result['continue_from'] = dict(value['continue_from'])
if value['first_frame_reference']:
result['first_frame_reference'] = True
+ if value.get('part_prompts'):
+ result['part_prompts'] = list(value['part_prompts'])
result['loras'] = [dict(name=row, strength=1.) if isinstance(row, str) else {'strength': 1., **row}
for row in value['loras']]
if port is not None: