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.

Refuse a request over the part limit before submission

Bowen Xue39f40522fa62
diff --git a/freevideo_engine/chain_plan.py b/freevideo_engine/chain_plan.py
index d7cf593..5eb36f5 100644
--- a/freevideo_engine/chain_plan.py
+++ b/freevideo_engine/chain_plan.py
@@ -35,11 +35,14 @@ def _first_frames(seconds):
return geometry(seconds=seconds)['frames']
-def plan(seconds, single=False, max_frames=None, single_limit_seconds=None, block_seconds=None, continued=False):
+def plan(seconds, single=False, max_frames=None, single_limit_seconds=None, block_seconds=None, continued=False, max_parts=None):
"""`max_frames`: the most frames this device generates at once for the current settings (unknown: 15 s).
`continued`: the video goes on from a saved one, so its first block too spends OVERLAP frames on what
came before and adds only the rest.
+
+ `max_parts`: the most parts one video may have. A new video that needs more is refused here, before anything
+ is submitted; a continued one adds to parts this planner does not know, so the server checks it on submission.
"""
_number(seconds, 'Length')
if type(single) is not bool:
@@ -104,6 +107,8 @@ def plan(seconds, single=False, max_frames=None, single_limit_seconds=None, bloc
raise PlanError('length_not_splittable', 'This length cannot be cut into parts of the requested length')
if count > MAX_BLOCKS:
raise PlanError('too_long', 'This length needs too many blocks')
+ if max_parts is not None and not continued and count + 1 > max_parts:
+ raise PlanError('too_many_parts', 'One continuous shot can have up to %d parts. Make it shorter.' % max_parts)
lengths = [whole // count + (index < whole % count) for index in range(count)]
if continued:
lengths[0] = round(lengths[0] - (whole - total), 6) # a fractional request keeps its length in the first part
diff --git a/freevideo_engine/comfy_chain.py b/freevideo_engine/comfy_chain.py
index 482e681..aa4b5cb 100644
--- a/freevideo_engine/comfy_chain.py
+++ b/freevideo_engine/comfy_chain.py
@@ -333,7 +333,7 @@ def register(host_factory=None):
value = await body(request)
result = chain_plan.plan(
value.get('seconds'), value.get('single', False), value.get('max_frames'),
- value.get('single_limit_seconds'), value.get('block_seconds'))
+ value.get('single_limit_seconds'), value.get('block_seconds'), max_parts=runner.max_parts)
if not result['single'] and not continuation_supported():
# A device that cannot continue a video has one block to give: never a plan in parts.
raise chain_plan.PlanError('device_limit', 'This device cannot generate this length at this size')
diff --git a/web/error_panel.js b/web/error_panel.js
index e1d8a33..c3cd3f2 100644
--- a/web/error_panel.js
+++ b/web/error_panel.js
@@ -47,6 +47,9 @@ const PLAIN_ERRORS = [
{key: 'media-mixed-layout', message: 'Choose keyframes or experimental references; mixed layouts are not supported',
title: ['First and last frames cannot be used with references', '首尾帧不能和参考素材同时使用'],
summary: ['Turn off the media cards or inputs you are not using, then generate again.', '请关闭本次不用的素材卡片或输入,再重新生成。']},
+ {key: 'chain-too-long', prefixes: ['One continuous shot can have up to '],
+ title: ['This shot has too many parts', '这个镜头的段数太多'],
+ summary: ['Choose a shorter duration, or add the next shot in Edit.', '请缩短时长,或在剪辑视图中添加下一个镜头。']},
{key: 'continuation-frames', message: 'Frame count must be 5 + 17n and at least 39 (39, 56, 73, 90, ...).',
aliases: ['Frames must be 0 to use Duration, or 5 + 17n and at least 39 (for example, 39, 56, 141 or 243). The total includes 22 overlap frames when continuing.'],
title: ['Choose a supported frame count', '请选择支持的帧数'],
diff --git a/web/length_plan.js b/web/length_plan.js
index 773bad3..525405c 100644
--- a/web/length_plan.js
+++ b/web/length_plan.js
@@ -32,7 +32,7 @@ export function readLengthPlan(reply) {
export function classifyPlanError(reply) {
if (reply?.code === 'device_limit') return 'continuation_unavailable';
- if (reply?.code === 'too_long') return 'too_long';
+ if (reply?.code === 'too_long' || reply?.code === 'too_many_parts') return 'too_long';
if (['block_too_long', 'block_too_short', 'too_short', 'invalid'].includes(reply?.code)) return 'other';
const value = reply?.error;
const message = reply?.code || (typeof value === 'string' ? value : value?.code || value?.message || '');