@clipen/clipen-cli 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -48
- package/apps/web/dist/assets/{index-D5D2HiB1.js → index-DPHwA954.js} +1 -1
- package/apps/web/dist/index.html +1 -1
- package/bin/clipen.js +1 -1
- package/package.json +7 -6
- package/pyproject.toml +18 -2
- package/requirements/dev.txt +2 -0
- package/src/clipen/__init__.py +1 -1
- package/src/clipen/analysis/__init__.py +7 -7
- package/src/clipen/analysis/artifacts.py +4 -10
- package/src/clipen/analysis/audio.py +10 -8
- package/src/clipen/analysis/evidence_service.py +345 -167
- package/src/clipen/analysis/image_similarity.py +5 -14
- package/src/clipen/analysis/keyframes.py +5 -17
- package/src/clipen/analysis/models.py +5 -7
- package/src/clipen/analysis/qwen_worker.py +19 -54
- package/src/clipen/analysis/resources.py +2 -1
- package/src/clipen/analysis/runtime.py +1 -3
- package/src/clipen/analysis/service.py +16 -48
- package/src/clipen/analysis/setup.py +11 -25
- package/src/clipen/analysis/setup_cli.py +5 -15
- package/src/clipen/analysis/storage.py +96 -278
- package/src/clipen/analysis/transcription.py +40 -82
- package/src/clipen/analysis/visual.py +109 -48
- package/src/clipen/annotations/__init__.py +5 -2
- package/src/clipen/annotations/models.py +1 -1
- package/src/clipen/annotations/storage.py +132 -84
- package/src/clipen/annotations/suggestions.py +3 -8
- package/src/clipen/asr_release.py +4 -11
- package/src/clipen/bootstrap.py +71 -61
- package/src/clipen/{planning/models.py → candidates.py} +29 -47
- package/src/clipen/cli.py +4 -9
- package/src/clipen/controller/app.py +401 -214
- package/src/clipen/controller/server.py +28 -38
- package/src/clipen/domain/__init__.py +1 -1
- package/src/clipen/domain/media_time.py +3 -10
- package/src/clipen/domain/timeline.py +45 -47
- package/src/clipen/domain/validation.py +0 -1
- package/src/clipen/editing/__init__.py +1 -1
- package/src/clipen/editing/agent_models.py +4 -11
- package/src/clipen/editing/agent_repository.py +393 -172
- package/src/clipen/editing/agent_tools.py +180 -99
- package/src/clipen/editing/alignment.py +92 -52
- package/src/clipen/editing/alignment_setup.py +118 -70
- package/src/clipen/editing/alignment_worker.py +11 -9
- package/src/clipen/editing/change_report.py +95 -38
- package/src/clipen/editing/compiler.py +0 -1
- package/src/clipen/editing/component_looks.py +58 -34
- package/src/clipen/editing/component_review.py +34 -38
- package/src/clipen/editing/coordinator.py +213 -92
- package/src/clipen/editing/editorial_review.py +217 -95
- package/src/clipen/editing/evidence_jobs.py +457 -200
- package/src/clipen/editing/history_changes.py +129 -68
- package/src/clipen/editing/music_choices.py +8 -5
- package/src/clipen/editing/production_catalog.py +573 -136
- package/src/clipen/editing/production_limits.py +43 -17
- package/src/clipen/editing/production_media.py +376 -167
- package/src/clipen/editing/production_preview.py +322 -129
- package/src/clipen/editing/production_progress.py +164 -69
- package/src/clipen/editing/production_requirements.py +106 -39
- package/src/clipen/editing/production_tools.py +1064 -462
- package/src/clipen/editing/program_audio.py +211 -81
- package/src/clipen/editing/program_direction.py +59 -25
- package/src/clipen/editing/program_story.py +83 -45
- package/src/clipen/editing/program_subtitles.py +194 -96
- package/src/clipen/editing/programme_review.py +98 -50
- package/src/clipen/editing/prompt_history.py +64 -27
- package/src/clipen/editing/recut.py +65 -25
- package/src/clipen/editing/refinement_references.py +176 -86
- package/src/clipen/editing/resolve_export.py +449 -218
- package/src/clipen/editing/resolve_titles.py +162 -105
- package/src/clipen/editing/skill_tools.py +530 -154
- package/src/clipen/editing/source_dialogue.py +177 -67
- package/src/clipen/editing/speech_coverage.py +42 -22
- package/src/clipen/editing/speech_quality.py +6 -1
- package/src/clipen/editing/tool_receipts.py +78 -32
- package/src/clipen/editing/versions.py +122 -64
- package/src/clipen/editing/visual_preview.py +157 -61
- package/src/clipen/editing/workbench.py +104 -42
- package/src/clipen/finishing/audio.py +69 -30
- package/src/clipen/finishing/catalog.py +176 -93
- package/src/clipen/finishing/models.py +1 -1
- package/src/clipen/finishing/renderer.py +33 -14
- package/src/clipen/mcp_editing/__main__.py +3 -1
- package/src/clipen/mcp_editing/server.py +77 -34
- package/src/clipen/media/__init__.py +3 -3
- package/src/clipen/media/discovery.py +7 -20
- package/src/clipen/media/models.py +7 -18
- package/src/clipen/media/preview.py +14 -24
- package/src/clipen/media/probe.py +16 -44
- package/src/clipen/media/service.py +6 -19
- package/src/clipen/media/storage.py +33 -81
- package/src/clipen/music_vocabulary.py +33 -4
- package/src/clipen/power.py +8 -3
- package/src/clipen/projects/__init__.py +1 -1
- package/src/clipen/projects/deletion.py +19 -32
- package/src/clipen/projects/finishing_schema.py +3 -1
- package/src/clipen/projects/models.py +2 -5
- package/src/clipen/projects/picker.py +13 -37
- package/src/clipen/projects/service.py +8 -24
- package/src/clipen/projects/storage.py +226 -246
- package/src/clipen/provider_registry.py +9 -20
- package/src/clipen/providers/account.py +86 -35
- package/src/clipen/providers/claude.py +59 -25
- package/src/clipen/providers/claude_editing.py +14 -7
- package/src/clipen/providers/codex.py +73 -118
- package/src/clipen/providers/codex_editing.py +2 -2
- package/src/clipen/providers/editing_agent.py +19 -17
- package/src/clipen/providers/recovery.py +7 -8
- package/src/clipen/rendering/cover.py +18 -5
- package/src/clipen/rendering/custom_components.py +167 -79
- package/src/clipen/rendering/custom_render.py +62 -41
- package/src/clipen/rendering/production_effects.py +77 -45
- package/src/clipen/rendering/program_components.py +134 -73
- package/src/clipen/rendering/program_creator.py +432 -277
- package/src/clipen/rendering/program_identities.py +277 -182
- package/src/clipen/rendering/program_motion.py +140 -95
- package/src/clipen/rendering/program_studio.py +175 -116
- package/src/clipen/rendering/program_styles.py +231 -145
- package/src/clipen/rendering/program_subtitles.py +71 -34
- package/src/clipen/rendering/renderer.py +150 -121
- package/src/clipen/rendering/storage.py +9 -22
- package/src/clipen/rendering/titles.py +193 -86
- package/src/clipen/skills/__init__.py +1 -0
- package/src/clipen/skills/catalog.py +151 -55
- package/src/clipen/skills/library.py +13 -7
- package/src/clipen/skills/package.py +46 -23
- package/src/clipen/skills/visual_styles.py +29 -18
- package/src/clipen/workspace.py +15 -44
- package/install +0 -25
- package/src/clipen/planning/__init__.py +0 -9
- package/uninstall +0 -25
|
@@ -3,50 +3,129 @@
|
|
|
3
3
|
Stages report how far the AI has observably got, never a percentage of the
|
|
4
4
|
work: an agent revisits steps and has no fixed number of them.
|
|
5
5
|
"""
|
|
6
|
-
import json
|
|
7
6
|
|
|
7
|
+
import json
|
|
8
8
|
|
|
9
9
|
_TOOL_GROUPS = (
|
|
10
|
-
(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
(
|
|
10
|
+
(
|
|
11
|
+
"理解製作需求與影片風格",
|
|
12
|
+
(
|
|
13
|
+
"get_edit_status",
|
|
14
|
+
"list_editing_tools",
|
|
15
|
+
"list_production_skills",
|
|
16
|
+
"read_production_skill",
|
|
17
|
+
"list_program_components",
|
|
18
|
+
),
|
|
19
|
+
),
|
|
20
|
+
(
|
|
21
|
+
"尋找與檢視來源素材",
|
|
22
|
+
(
|
|
23
|
+
"list_source_media",
|
|
24
|
+
"search_media",
|
|
25
|
+
"search_source_dialogue",
|
|
26
|
+
"register_source_range",
|
|
27
|
+
"sample_source",
|
|
28
|
+
"inspect_candidates",
|
|
29
|
+
"inspect_clip",
|
|
30
|
+
),
|
|
31
|
+
),
|
|
32
|
+
("準備本機語音模型", ("prepare_local_speech",)),
|
|
33
|
+
(
|
|
34
|
+
"辨識與對齊來源口語",
|
|
35
|
+
("transcribe_source_range", "align_source_speech", "revise_source_speech", "list_transcripts"),
|
|
36
|
+
),
|
|
37
|
+
(
|
|
38
|
+
"安排故事與剪輯",
|
|
39
|
+
(
|
|
40
|
+
"record_story_plan",
|
|
41
|
+
"read_story_plan",
|
|
42
|
+
"plan_episode",
|
|
43
|
+
"replace_sequence",
|
|
44
|
+
"replace_clip_source",
|
|
45
|
+
"trim_clip",
|
|
46
|
+
"reorder_clips",
|
|
47
|
+
"split_clip",
|
|
48
|
+
"insert_clip",
|
|
49
|
+
"set_canvas",
|
|
50
|
+
"remove_item",
|
|
51
|
+
),
|
|
52
|
+
),
|
|
53
|
+
(
|
|
54
|
+
"製作字幕與畫面設計",
|
|
55
|
+
(
|
|
56
|
+
"replace_subtitles",
|
|
57
|
+
"remove_program_component",
|
|
58
|
+
"add_custom_component",
|
|
59
|
+
"update_custom_component",
|
|
60
|
+
"set_component_look",
|
|
61
|
+
"set_color_grade",
|
|
62
|
+
"set_mosaic",
|
|
63
|
+
"set_transition",
|
|
64
|
+
"set_fade",
|
|
65
|
+
"add_effect",
|
|
66
|
+
"remove_clip_effect",
|
|
67
|
+
),
|
|
68
|
+
),
|
|
69
|
+
(
|
|
70
|
+
"尋找與安排配樂、音效",
|
|
71
|
+
(
|
|
72
|
+
"search_music",
|
|
73
|
+
"list_audio_assets",
|
|
74
|
+
"extract_audio",
|
|
75
|
+
"inspect_audio",
|
|
76
|
+
"place_audio",
|
|
77
|
+
"remove_audio",
|
|
78
|
+
"set_source_audio",
|
|
79
|
+
),
|
|
80
|
+
),
|
|
81
|
+
("輸出樣片預覽", ("render_preview",)),
|
|
82
|
+
(
|
|
83
|
+
"檢查畫面、字幕與聲音",
|
|
84
|
+
("inspect_preview", "inspect_cut", "review_cut", "validate_sequence", "inspect_mix", "inspect_pacing"),
|
|
85
|
+
),
|
|
86
|
+
("等待或處理本機工作結果", ("read_evidence_job", "retry_evidence_job", "cancel_evidence_job")),
|
|
87
|
+
("整理交付檔案", ("export_edit", "finish_edit")),
|
|
21
88
|
)
|
|
22
89
|
_TOOL_LABELS = {tool: label for label, tools in _TOOL_GROUPS for tool in tools}
|
|
23
90
|
_EVENT_LABELS = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
91
|
+
"run_created": "製作工作已建立",
|
|
92
|
+
"run_started": "AI 已開始製作",
|
|
93
|
+
"refinement_requested": "收到你的修改要求",
|
|
94
|
+
"run_resumed": "接續上次的草稿",
|
|
95
|
+
"provider_switched": "換另一個 AI 接手",
|
|
96
|
+
"revision_created": "草稿已儲存",
|
|
97
|
+
"production_preview": "已提交預覽合成",
|
|
28
98
|
# Reviewing a preview and its mix are the same step to the viewer as the review tools.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
99
|
+
"production_review": "檢查畫面、字幕與聲音",
|
|
100
|
+
"mix_review": "檢查畫面、字幕與聲音",
|
|
101
|
+
"run_finished": "樣片製作已完成,等待你觀看",
|
|
102
|
+
"provider_failed": "AI 這次沒有完成製作",
|
|
103
|
+
"run_cancelled": "製作已停止",
|
|
104
|
+
"run_interrupted": "製作已中斷",
|
|
105
|
+
"budget_exhausted": "本次工作已達操作上限",
|
|
34
106
|
}
|
|
35
107
|
# A failed attempt is described by why it stopped, not as a generic error.
|
|
36
108
|
_FAILURE_LABELS = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
109
|
+
"delivery_blocked": "AI 做完草稿,但還有項目沒通過檢查",
|
|
110
|
+
"provider_stopped_early": "AI 先停下來了,請看 AI 的說明",
|
|
111
|
+
"provider_usage_limit": "AI 額度不足,暫停製作",
|
|
112
|
+
"provider_timed_out": "超過製作時間上限,暫停製作",
|
|
41
113
|
}
|
|
42
114
|
# The furthest stage reached moves only forward. Checking the cut before any
|
|
43
115
|
# preview is part of editing; reviewing only counts once a film was rendered.
|
|
44
|
-
STAGES = (
|
|
116
|
+
STAGES = ("understand", "sources", "edit", "graphics", "music", "render", "review")
|
|
45
117
|
_STAGE_OF_LABEL = {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
118
|
+
"理解製作需求與影片風格": "understand",
|
|
119
|
+
"尋找與檢視來源素材": "sources",
|
|
120
|
+
"準備本機語音模型": "sources",
|
|
121
|
+
"辨識與對齊來源口語": "sources",
|
|
122
|
+
"安排故事與剪輯": "edit",
|
|
123
|
+
"製作字幕與畫面設計": "graphics",
|
|
124
|
+
"尋找與安排配樂、音效": "music",
|
|
125
|
+
"輸出樣片預覽": "render",
|
|
126
|
+
"已提交預覽合成": "render",
|
|
127
|
+
"檢查畫面、字幕與聲音": "review",
|
|
128
|
+
"整理交付檔案": "review",
|
|
50
129
|
}
|
|
51
130
|
|
|
52
131
|
|
|
@@ -56,86 +135,102 @@ def _stages(labels, finished):
|
|
|
56
135
|
stage = _STAGE_OF_LABEL.get(label)
|
|
57
136
|
if stage is None:
|
|
58
137
|
continue
|
|
59
|
-
if stage ==
|
|
138
|
+
if stage == "render":
|
|
60
139
|
rendered = True
|
|
61
|
-
if stage ==
|
|
62
|
-
stage =
|
|
140
|
+
if stage == "review" and not rendered:
|
|
141
|
+
stage = "edit"
|
|
63
142
|
furthest = max(furthest, STAGES.index(stage))
|
|
64
143
|
if finished:
|
|
65
144
|
furthest = len(STAGES)
|
|
66
|
-
return {
|
|
145
|
+
return {"stages": STAGES, "reached": furthest}
|
|
67
146
|
|
|
68
147
|
|
|
69
148
|
# Each request (a new film, a revision, a resume) starts a fresh activity list.
|
|
70
|
-
_STARTS = (
|
|
149
|
+
_STARTS = ("run_created", "refinement_requested", "run_resumed")
|
|
71
150
|
_SHOWN = 10
|
|
72
151
|
|
|
73
152
|
|
|
74
153
|
def _duration(seconds):
|
|
75
154
|
minutes = max(1, round(seconds / 60))
|
|
76
|
-
return f
|
|
155
|
+
return f"{minutes} 分鐘" if minutes < 60 else f"{minutes // 60} 小時 {minutes % 60} 分鐘"
|
|
77
156
|
|
|
78
157
|
|
|
79
158
|
def _provider_name(provider_id):
|
|
80
159
|
from clipen.provider_registry import get_provider
|
|
160
|
+
|
|
81
161
|
try:
|
|
82
162
|
return get_provider(provider_id).display_name
|
|
83
163
|
except (KeyError, ValueError, TypeError):
|
|
84
|
-
return
|
|
164
|
+
return "AI"
|
|
85
165
|
|
|
86
166
|
|
|
87
167
|
def _latest_start(database, run_id, kinds):
|
|
88
168
|
return database.execute(
|
|
89
169
|
f"SELECT COALESCE(MAX(sequence),0) FROM edit_agent_events WHERE run_id=? AND event_type IN ({','.join('?' for _ in kinds)})",
|
|
90
|
-
(run_id, *kinds)
|
|
170
|
+
(run_id, *kinds),
|
|
171
|
+
).fetchone()[0]
|
|
91
172
|
|
|
92
173
|
|
|
93
174
|
def production_activity(database, run_id):
|
|
94
175
|
boundary = _latest_start(database, run_id, _STARTS)
|
|
95
176
|
# Resuming continues the same request, so its stages carry on from before.
|
|
96
|
-
request_boundary = _latest_start(database, run_id, (
|
|
97
|
-
kinds = (
|
|
98
|
-
placeholders =
|
|
177
|
+
request_boundary = _latest_start(database, run_id, ("run_created", "refinement_requested"))
|
|
178
|
+
kinds = ("tool_called", "provider_finished", "machine_slept", *_EVENT_LABELS)
|
|
179
|
+
placeholders = ",".join("?" for _ in kinds)
|
|
99
180
|
rows = database.execute(
|
|
100
|
-
f
|
|
101
|
-
f
|
|
181
|
+
f"SELECT sequence,event_type,payload_json,created_at FROM edit_agent_events "
|
|
182
|
+
f"WHERE run_id=? AND sequence>=? AND event_type IN ({placeholders}) ORDER BY sequence",
|
|
102
183
|
(run_id, request_boundary, *kinds),
|
|
103
184
|
).fetchall()
|
|
104
185
|
activity, message, request, labels, finished, slept = [], None, None, [], False, 0
|
|
105
|
-
started_at = next((row[
|
|
186
|
+
started_at = next((row["created_at"] for row in rows if row["sequence"] >= boundary), None)
|
|
106
187
|
for row in rows:
|
|
107
|
-
payload = json.loads(row[
|
|
108
|
-
kind = row[
|
|
109
|
-
finished = finished or kind ==
|
|
110
|
-
if kind in {
|
|
111
|
-
message = payload.get(
|
|
112
|
-
if kind ==
|
|
188
|
+
payload = json.loads(row["payload_json"])
|
|
189
|
+
kind = row["event_type"]
|
|
190
|
+
finished = finished or kind == "run_finished"
|
|
191
|
+
if kind in {"provider_finished", "provider_failed"} and row["sequence"] >= boundary:
|
|
192
|
+
message = payload.get("message") or message
|
|
193
|
+
if kind == "provider_finished":
|
|
113
194
|
continue
|
|
114
|
-
if kind ==
|
|
115
|
-
request = payload.get(
|
|
116
|
-
tool = payload.get(
|
|
117
|
-
if kind ==
|
|
118
|
-
label = _TOOL_LABELS.get(tool,
|
|
119
|
-
elif kind ==
|
|
120
|
-
label = _FAILURE_LABELS.get(payload.get(
|
|
121
|
-
elif kind ==
|
|
122
|
-
if row[
|
|
123
|
-
slept += payload.get(
|
|
195
|
+
if kind == "refinement_requested":
|
|
196
|
+
request = payload.get("instruction")
|
|
197
|
+
tool = payload.get("tool", "") if kind == "tool_called" else None
|
|
198
|
+
if kind == "tool_called":
|
|
199
|
+
label = _TOOL_LABELS.get(tool, "AI 正在操作剪輯工具")
|
|
200
|
+
elif kind == "provider_failed":
|
|
201
|
+
label = _FAILURE_LABELS.get(payload.get("error_code"), _EVENT_LABELS[kind])
|
|
202
|
+
elif kind == "machine_slept":
|
|
203
|
+
if row["sequence"] >= boundary:
|
|
204
|
+
slept += payload.get("seconds", 0)
|
|
124
205
|
label = f"Mac 睡眠約 {_duration(payload.get('seconds', 0))},製作暫停"
|
|
125
|
-
elif kind ==
|
|
206
|
+
elif kind == "provider_switched":
|
|
126
207
|
label = f"改由 {_provider_name(payload.get('to'))} 接手修改"
|
|
127
208
|
else:
|
|
128
209
|
label = _EVENT_LABELS[kind]
|
|
129
210
|
labels.append(label)
|
|
130
|
-
if row[
|
|
211
|
+
if row["sequence"] < boundary:
|
|
131
212
|
continue
|
|
132
213
|
# Many tool calls in a row are one step to the viewer; keep its latest time.
|
|
133
|
-
if activity and activity[-1][
|
|
134
|
-
activity[-1].update(sequence=row[
|
|
214
|
+
if activity and activity[-1]["label"] == label:
|
|
215
|
+
activity[-1].update(sequence=row["sequence"], created_at=row["created_at"], count=activity[-1]["count"] + 1)
|
|
135
216
|
continue
|
|
136
|
-
activity.append(
|
|
137
|
-
|
|
217
|
+
activity.append(
|
|
218
|
+
{
|
|
219
|
+
"sequence": row["sequence"],
|
|
220
|
+
"kind": kind,
|
|
221
|
+
"label": label,
|
|
222
|
+
"tool": tool,
|
|
223
|
+
"created_at": row["created_at"],
|
|
224
|
+
"count": 1,
|
|
225
|
+
}
|
|
226
|
+
)
|
|
138
227
|
activity = activity[-_SHOWN:]
|
|
139
|
-
return {
|
|
140
|
-
|
|
141
|
-
|
|
228
|
+
return {
|
|
229
|
+
"activity": activity,
|
|
230
|
+
"updated_at": activity[-1]["created_at"] if activity else None,
|
|
231
|
+
"ai_message": message,
|
|
232
|
+
"request": request,
|
|
233
|
+
"started_at": started_at,
|
|
234
|
+
"slept_seconds": slept,
|
|
235
|
+
**_stages(labels, finished),
|
|
236
|
+
}
|
|
@@ -1,50 +1,117 @@
|
|
|
1
1
|
"""Actual production contents and explicit user requirements, not aesthetic scoring."""
|
|
2
|
-
|
|
3
|
-
from clipen.domain import EditTimeline
|
|
2
|
+
|
|
4
3
|
import json
|
|
4
|
+
|
|
5
|
+
from clipen.domain import EditTimeline, TrackKind
|
|
6
|
+
|
|
5
7
|
from .production_media import AgentAudioStore
|
|
6
8
|
|
|
7
9
|
|
|
8
|
-
def production_contents(projects,project_id,timeline):
|
|
9
|
-
fps=timeline.frame_rate.numerator/timeline.frame_rate.denominator
|
|
10
|
-
videos=[i for t in timeline.tracks if t.kind is TrackKind.VIDEO for i in t.items]
|
|
11
|
-
directory=projects.root/project_id/
|
|
12
|
-
assets=
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
def production_contents(projects, project_id, timeline):
|
|
11
|
+
fps = timeline.frame_rate.numerator / timeline.frame_rate.denominator
|
|
12
|
+
videos = [i for t in timeline.tracks if t.kind is TrackKind.VIDEO for i in t.items]
|
|
13
|
+
directory = projects.root / project_id / "agent-audio"
|
|
14
|
+
assets = (
|
|
15
|
+
{a["asset_id"]: a for a in AgentAudioStore(projects, project_id).public_assets()} if directory.exists() else {}
|
|
16
|
+
)
|
|
17
|
+
music = []
|
|
18
|
+
transitions = []
|
|
19
|
+
motion = []
|
|
20
|
+
for n, item in enumerate(videos):
|
|
15
21
|
for effect in item.effects:
|
|
16
|
-
if effect.effect_id==
|
|
17
|
-
for layer in effect.parameters[
|
|
18
|
-
asset=assets.get(layer[
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
if effect.effect_id == "audio.layers":
|
|
23
|
+
for layer in effect.parameters["layers"]:
|
|
24
|
+
asset = assets.get(layer["asset_id"], {})
|
|
25
|
+
provenance = asset.get("provenance", {})
|
|
26
|
+
licensed = (
|
|
27
|
+
all(provenance.get(k) for k in ("title", "creator", "source_url", "license_url", "license"))
|
|
28
|
+
and provenance.get("license") != "unknown"
|
|
29
|
+
)
|
|
30
|
+
music.append(
|
|
31
|
+
{
|
|
32
|
+
"asset_id": layer["asset_id"],
|
|
33
|
+
"name": asset.get("name", "未取得音訊來源"),
|
|
34
|
+
"role": asset.get("role", "unknown"),
|
|
35
|
+
"start_seconds": (item.start_frame + layer["start_frame"]) / fps,
|
|
36
|
+
"duration_seconds": layer["duration_frames"] / fps,
|
|
37
|
+
"source_offset_seconds": layer["source_offset_seconds"],
|
|
38
|
+
"source_duration_seconds": asset.get("duration_seconds"),
|
|
39
|
+
"gain_db": layer["gain_db"],
|
|
40
|
+
"duck": layer["duck"],
|
|
41
|
+
"licensed": bool(licensed),
|
|
42
|
+
"provenance": provenance,
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
elif effect.effect_id == "video.transition" and n > 0 and effect.parameters["kind"] != "none":
|
|
46
|
+
transitions.append({"item_id": item.item_id, "at_seconds": item.start_frame / fps, **effect.parameters})
|
|
47
|
+
elif effect.effect_id in {"video.punch_in", "video.slow_push", "video.reframe", "video.speed_ramp"}:
|
|
48
|
+
motion.append({"item_id": item.item_id, "effect_id": effect.effect_id})
|
|
49
|
+
return {
|
|
50
|
+
"clip_count": len(videos),
|
|
51
|
+
"cut_count": max(0, len(videos) - 1),
|
|
52
|
+
"music": music,
|
|
53
|
+
"transitions": transitions,
|
|
54
|
+
"motion": motion,
|
|
55
|
+
"scope": "Actual timeline contents; placement and metadata do not prove listening or aesthetic quality.",
|
|
56
|
+
}
|
|
30
57
|
|
|
31
58
|
|
|
32
59
|
def requirement_issues(tools):
|
|
33
|
-
direction=tools.repository.creative_direction(tools.project_id,tools.run_id)
|
|
34
|
-
required=direction.get(
|
|
35
|
-
if not any(required.values()):
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
60
|
+
direction = tools.repository.creative_direction(tools.project_id, tools.run_id)
|
|
61
|
+
required = direction.get("production_requirements", {})
|
|
62
|
+
if not any(required.values()):
|
|
63
|
+
return []
|
|
64
|
+
contents = production_contents(tools.repository.projects, tools.project_id, tools._timeline())
|
|
65
|
+
issues = []
|
|
66
|
+
choice = tools._session_value()["intent"].get("music_choice")
|
|
67
|
+
if (
|
|
68
|
+
choice
|
|
69
|
+
and choice.get("mode") == "user"
|
|
70
|
+
and any(m["role"] == "music" and m.get("asset_id") != choice["asset_id"] for m in contents["music"])
|
|
71
|
+
):
|
|
72
|
+
issues.append({"code": "user_music_mismatch", "message": "請使用使用者指定的配樂,不可替換成其他曲目。"})
|
|
73
|
+
if required.get("music") and not any(
|
|
74
|
+
m["role"] == "music"
|
|
75
|
+
and (m["licensed"] or (choice and m.get("asset_id") == choice["asset_id"]))
|
|
76
|
+
and m["duration_seconds"] > 0
|
|
77
|
+
and m["gain_db"] > -60
|
|
78
|
+
for m in contents["music"]
|
|
79
|
+
):
|
|
80
|
+
issues.append(
|
|
81
|
+
{
|
|
82
|
+
"code": "production_music_required",
|
|
83
|
+
"message": "使用者要求配樂。請搜尋或選擇有作者、來源與授權的公開音樂,實際用 place_audio 放入並調整音量/人聲壓低;只有原音或讀取曲目清單不算完成。",
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
if required.get("transitions") and not contents["transitions"]:
|
|
87
|
+
issues.append(
|
|
88
|
+
{
|
|
89
|
+
"code": "production_transition_required",
|
|
90
|
+
"message": "使用者要求轉場。請在有敘事用途的剪點使用 set_transition;只有片尾淡出不算剪點轉場。",
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
if required.get("editing"):
|
|
45
94
|
with tools.repository.projects.connect(tools.project_id) as db:
|
|
46
|
-
first=db.execute(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
95
|
+
first = db.execute(
|
|
96
|
+
"SELECT payload_json FROM edit_agent_revisions WHERE run_id=? AND ordinal=0", (tools.run_id,)
|
|
97
|
+
).fetchone()
|
|
98
|
+
|
|
99
|
+
def sequence(timeline):
|
|
100
|
+
return [
|
|
101
|
+
(i.source.span.to_storage(), i.duration_frames)
|
|
102
|
+
for t in timeline.tracks
|
|
103
|
+
if t.kind is TrackKind.VIDEO
|
|
104
|
+
for i in t.items
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
if contents["cut_count"] < 1 or (
|
|
108
|
+
first
|
|
109
|
+
and sequence(EditTimeline.from_payload(json.loads(first["payload_json"]))) == sequence(tools._timeline())
|
|
110
|
+
):
|
|
111
|
+
issues.append(
|
|
112
|
+
{
|
|
113
|
+
"code": "production_editing_required",
|
|
114
|
+
"message": "請實際選材、精剪及安排至少一個剪點,不能只在原版加字幕。",
|
|
115
|
+
}
|
|
116
|
+
)
|
|
50
117
|
return issues
|