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 name is enough to start a new timeline

Bowen Xue3dcec1d892f2
diff --git a/freevideo_engine/agent/guide.py b/freevideo_engine/agent/guide.py
index ae08a12..ad420ec 100644
--- a/freevideo_engine/agent/guide.py
+++ b/freevideo_engine/agent/guide.py
@@ -103,6 +103,7 @@ GUIDE = {
],
'editing_projects': [
'GET /projects lists timelines shared with the editor page. First GET /projects/{id} to read revision and clip IDs.',
+ 'For a new timeline POST /projects with {"project": {"name": "..."}} (width and height too if not 1344x768); it comes back empty at revision 1. Then add each clip with an insert operation.',
'POST /projects/{id}/operations sends revision and 1-64 operations, using whole frames at 24 fps. The batch saves once or changes nothing.',
'On 409 project_changed, recompute edits from error.project and its current_revision, then send a new request. On clip_busy wait for generation to finish.',
'POST /projects/{id}/generate reserves pending parts for clip_ids or a start/frames range and fills them as the returned job finishes. POST /projects/{id}/export renders the revision you read; wait for its job.',
diff --git a/freevideo_engine/agent/projects.py b/freevideo_engine/agent/projects.py
index 348d5b8..afd7180 100644
--- a/freevideo_engine/agent/projects.py
+++ b/freevideo_engine/agent/projects.py
@@ -35,6 +35,12 @@ RULE_EXPECTED = {
}
+def new_project(given):
+ """The page's empty timeline with what the caller sent on top; a name alone is enough to start one."""
+ return dict(dict(version=1, id=None, revision=0, name='', fps=comfy_editor.FPS, width=1344, height=768, settings=None, serial=0,
+ tracks=[dict(id='v1', kind='video', clips=[]), dict(id='a1', kind='audio', clips=[])]), **given)
+
+
class ProjectError(JobError):
"""A project error; a conflict carries the current project so the caller can retry from it."""
@@ -64,7 +70,7 @@ def _refused(project, error):
reason = str(error) if type(error) is ValueError and re.fullmatch(r'[A-Z][A-Za-z ]{2,60}', str(error)) else ''
row = schema.diagnostic('/project', 'a valid editor project' + (' (%s)' % (reason[:1].lower() + reason[1:]) if reason else ''),
project)
- row['next'] = ('Correct that part of /project. To place clips, create the project with empty tracks, '
+ row['next'] = ('Correct that part of /project. For a new timeline send only {"project": {"name": "..."}}; '
'then add each clip with an insert operation.')
return spec.SpecError([row])
@@ -196,8 +202,9 @@ class Projects:
if replay is not None:
return replay
project = value.get('project') if isinstance(value, dict) else None
- if not isinstance(project, dict) or project.get('id') is not None or project.get('revision') != 0:
- raise _invalid('/project', 'a new project with id null and revision 0')
+ project = new_project(project) if isinstance(project, dict) else None
+ if project is None or project.get('id') is not None or project.get('revision') != 0:
+ raise _invalid('/project', 'a new project: its name is enough, with no id and no revision')
# The page's receipt makes a repeated create return the first project.
create = _operation_key(ref, client) if ref is not None else None
self._lengths(project)
diff --git a/freevideo_engine/agent/schema.py b/freevideo_engine/agent/schema.py
index 38410e1..1ca0174 100644
--- a/freevideo_engine/agent/schema.py
+++ b/freevideo_engine/agent/schema.py
@@ -635,7 +635,7 @@ def image_schema(name):
PROJECT_OPERATIONS = {
'list': ('GET', '/projects', 'List editing projects shared with the editor page. Then get one to read its revision and clip IDs.'),
'get': ('GET', '/projects/{id}', 'Read a timeline and authenticated source URLs. Read its revision and clip IDs before editing.'),
- 'create': ('POST', '/projects', 'Create an editor timeline. Send a valid editor project with id null and revision 0.'),
+ 'create': ('POST', '/projects', 'Create an editor timeline. Send {"project": {"name": "..."}}; the rest of an empty timeline is filled in.'),
'write': ('PUT', '/projects/{id}', 'Replace a timeline. First get the project and preserve its id and revision; recompute from error.project on project_changed.'),
'operations': ('POST', '/projects/{id}/operations', 'Apply 1-64 timeline edits atomically and save once. First get revision and clip IDs; on project_changed recompute from error.project, and on clip_busy wait for generation to finish.'),
'generate': ('POST', '/projects/{id}/generate', 'Make new picture and sound for selected clips or a frame range, as the page Generate does. First get revision and clip IDs; the parts are reserved at once and fill in as the returned job finishes.'),
@@ -730,7 +730,9 @@ def session_schema(name):
def project_schema(name):
if name in ('create', 'write'):
- return obj(dict(project={'type': 'object', 'description': 'The editor page project record; validated by the shared editor save.'}, ref=REF), ('project',))
+ text = ('A new timeline: {"name": "..."} is enough (width and height if not 1344x768); the rest is filled in. Add clips with insert operations afterwards.'
+ if name == 'create' else 'The whole project record as you read it, with your changes; validated by the shared editor save.')
+ return obj(dict(project={'type': 'object', 'description': text}, ref=REF), ('project',))
ids = array(CLIP, 1, 500)
revision = number(1, integer=True, description='The saved revision you read; a later save returns project_changed.')
if name == 'generate':