fablecut 1.20.0 → 1.22.0
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/CLAUDE.md +140 -6
- package/README.md +9 -2
- package/app.js +564 -96
- package/clips.js +207 -0
- package/import-url.js +10 -3
- package/index.html +13 -5
- package/manifest.json +3 -1
- package/mcp-server.js +177 -20
- package/music.js +253 -0
- package/package.json +1 -1
- package/project-ops.js +12 -2
- package/server.js +3 -1
- package/style.css +52 -0
package/clips.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/* FableCut clips — a long video into short clips, one call. The agent picks the
|
|
2
|
+
segments (from the transcript: a tip, an answer, a story); for each one this makes
|
|
3
|
+
a new sequence on the clip's canvas holding only that part of the open timeline,
|
|
4
|
+
then frames it (reframe), adds a hook title and captions, and can export it.
|
|
5
|
+
Zero dependencies; loaded by the editor as a plain script (global
|
|
6
|
+
`FableCutClips`) and required by the MCP server, so fablecut_clips and Studio
|
|
7
|
+
run the same steps. The steps themselves are the editor's own tools, passed in
|
|
8
|
+
as `env`: read() the project, patch(ops), reframe(args), captions(args),
|
|
9
|
+
exportClip(args) — each answering text, or throwing — and, optionally, progress(text)
|
|
10
|
+
as each clip and step starts. exportClip gets a `timeout` (seconds) for that clip and
|
|
11
|
+
answers once its export has ended (done, failed, or stopped when its time was up): the
|
|
12
|
+
next clip opens another sequence, and the editor renders the open one live. An answer
|
|
13
|
+
that says it is still running stops the batch there. */
|
|
14
|
+
(function (root, factory) {
|
|
15
|
+
const api = factory();
|
|
16
|
+
if (typeof module === "object" && module.exports) module.exports = api;
|
|
17
|
+
else root.FableCutClips = api;
|
|
18
|
+
})(typeof self !== "undefined" ? self : this, function () {
|
|
19
|
+
"use strict";
|
|
20
|
+
|
|
21
|
+
const ASPECTS = { "9:16": [9, 16], "1:1": [1, 1], "4:5": [4, 5], "16:9": [16, 9] };
|
|
22
|
+
const CAPTION_STYLES = ["pop", "highlight", "karaoke", "subtitle"];
|
|
23
|
+
const MAX_CLIPS = 10, MIN_LEN = 3, MAX_LEN = 180, TITLE_SECS = 3;
|
|
24
|
+
// each clip's export gets this long (3 min, or 6 s per second of the clip): one stuck past it is stopped
|
|
25
|
+
// and reported, so it can't hold up the clips after it
|
|
26
|
+
const EXPORT_MIN_S = 180, EXPORT_PER_S = 6;
|
|
27
|
+
|
|
28
|
+
/** The canvas for a shape, keeping the project's shorter side (1920×1080 → 1080×1920 for 9:16), even sizes. */
|
|
29
|
+
function canvasFor(aspect, W, H) {
|
|
30
|
+
const r = ASPECTS[aspect];
|
|
31
|
+
if (!r) throw new Error(`aspect must be one of ${Object.keys(ASPECTS).join(", ")}`);
|
|
32
|
+
const short = Math.min(W || 1920, H || 1080);
|
|
33
|
+
const even = (v) => Math.max(16, Math.round(v / 2) * 2);
|
|
34
|
+
return r[0] <= r[1] ? { width: even(short), height: even(short * r[1] / r[0]) } : { width: even(short * r[0] / r[1]), height: even(short) };
|
|
35
|
+
}
|
|
36
|
+
const end = (doc) => (doc.clips || []).reduce((m, c) => Math.max(m, (+c.start || 0) + (+c.duration || 0)), 0);
|
|
37
|
+
const clean = (s, n) => String(s == null ? "" : s).replace(/\s+/g, " ").trim().slice(0, n);
|
|
38
|
+
const fileName = (s) => clean(s, 60).replace(/[\\/:*?"<>|]+/g, "").replace(/\s+/g, "-").toLowerCase() || "clip";
|
|
39
|
+
|
|
40
|
+
/** Checked arguments: {clips:[{from, to, name, title}], aspect, captions, title, exportPreset}. Throws on anything wrong. */
|
|
41
|
+
function options(args, doc) {
|
|
42
|
+
args = args || {};
|
|
43
|
+
const list = args.clips;
|
|
44
|
+
if (!Array.isArray(list) || !list.length) throw new Error("clips must be a list of {from, to, name?, title?} — the parts of the timeline to make into clips (seconds)");
|
|
45
|
+
if (list.length > MAX_CLIPS) throw new Error(`up to ${MAX_CLIPS} clips at a time`);
|
|
46
|
+
const len = end(doc);
|
|
47
|
+
if (!(len > 0)) throw new Error("the open timeline is empty — put the long video on it first");
|
|
48
|
+
// each clip is cut out of a copy by extracting the rest, and an extract leaves locked material as it is:
|
|
49
|
+
// the copy would keep it whole and out of step with the rest, so the call is refused before anything changes
|
|
50
|
+
const lockedLanes = new Set(Array.isArray(doc.lockedTracks) ? doc.lockedTracks : []);
|
|
51
|
+
const locked = (doc.clips || []).filter((c) => c && (c.locked || lockedLanes.has(c.track)));
|
|
52
|
+
if (locked.length) throw new Error(`the timeline has locked material (${locked.slice(0, 4).map((c) => c.id + " on " + c.track).join(", ")}${locked.length > 4 ? ", …" : ""}): ` +
|
|
53
|
+
"clips are cut out of a copy by extracting the rest, and locked clips can't be cut — unlock them (updateClip set:{locked:null}, or the lane's lock) only if the user agrees, then call again");
|
|
54
|
+
const clips = list.map((c, i) => {
|
|
55
|
+
const from = +(c && c.from), to = +(c && c.to);
|
|
56
|
+
if (!Number.isFinite(from) || !Number.isFinite(to)) throw new Error(`clip ${i + 1}: from and to must be numbers (timeline seconds)`);
|
|
57
|
+
if (from < 0 || to > len + 0.05) throw new Error(`clip ${i + 1}: ${from}–${to} s is outside the timeline (0–${len.toFixed(2)} s)`);
|
|
58
|
+
if (to - from < MIN_LEN) throw new Error(`clip ${i + 1}: at least ${MIN_LEN} s`);
|
|
59
|
+
if (to - from > MAX_LEN) throw new Error(`clip ${i + 1}: at most ${MAX_LEN} s`);
|
|
60
|
+
return { from: Math.round(from * 1000) / 1000, to: Math.round(Math.min(to, len) * 1000) / 1000,
|
|
61
|
+
name: clean(c.name, 80) || `Clip ${i + 1}`, title: clean(c.title, 120) };
|
|
62
|
+
});
|
|
63
|
+
const aspect = args.aspect == null ? "9:16" : String(args.aspect);
|
|
64
|
+
if (!ASPECTS[aspect]) throw new Error(`aspect must be one of ${Object.keys(ASPECTS).join(", ")}`);
|
|
65
|
+
let captions = args.captions == null ? "pop" : args.captions;
|
|
66
|
+
if (captions !== false && !CAPTION_STYLES.includes(captions)) throw new Error(`captions must be one of ${CAPTION_STYLES.join(", ")}, or false`);
|
|
67
|
+
const exportPreset = args.export == null || args.export === false ? null : String(args.export);
|
|
68
|
+
return { clips, aspect, captions, title: args.title !== false, reframe: args.reframe !== false, exportPreset };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** The hook title: big outlined words in the top third, popping in for the first seconds. */
|
|
72
|
+
function titleClip(id, text, track, W, H, len) {
|
|
73
|
+
const size = Math.round(Math.min(W, H) * 0.085);
|
|
74
|
+
return { id, kind: "text", mediaId: null, track, start: 0, in: 0, duration: Math.min(TITLE_SECS, len), name: "Hook title",
|
|
75
|
+
props: { text, font: "Anton", fontSize: size, uppercase: true, color: "#ffffff", strokeWidth: Math.max(3, Math.round(size * 0.07)),
|
|
76
|
+
strokeColor: "#000000", textShadow: 12, align: "center", boxW: Math.round(W * 0.86), boxH: Math.round(H * 0.22), boxFit: true,
|
|
77
|
+
y: -Math.round(H * 0.36), textAnim: "word-pop", wordRate: 0.12 },
|
|
78
|
+
transitionOut: { type: "fade", duration: 0.3 } };
|
|
79
|
+
}
|
|
80
|
+
/** The top video lane, when nothing is on it during the title; else null (the title is left out). */
|
|
81
|
+
function freeTopLane(doc, until) {
|
|
82
|
+
const lanes = (Array.isArray(doc.tracks) && doc.tracks.length ? doc.tracks : [{ id: "V3", kind: "video" }, { id: "V2", kind: "video" }, { id: "V1", kind: "video" }])
|
|
83
|
+
.filter((t) => t && t.kind === "video").map((t) => t.id).sort((a, b) => +b.slice(1) - +a.slice(1));
|
|
84
|
+
const top = lanes[0];
|
|
85
|
+
if (!top || (doc.lockedTracks || []).includes(top)) return null;
|
|
86
|
+
return (doc.clips || []).some((c) => c.track === top && c.start < until && c.start + c.duration > 0) ? null : top;
|
|
87
|
+
}
|
|
88
|
+
const first = (s) => String(s || "").split("\n")[0].slice(0, 200);
|
|
89
|
+
/** An export answer that says it hasn't ended ("Export x_1 running — 40% …"). */
|
|
90
|
+
const RUNNING = /\bExport (?:\S+ )?(?:pending|running|queued)\b/;
|
|
91
|
+
|
|
92
|
+
/** exportClip for a host whose exports run as jobs it can poll and cancel: start one, wait up to
|
|
93
|
+
* a.timeout for its end, cancel it past that, and answer once its status says it ended — else
|
|
94
|
+
* "Export <id> running: …", which stops the batch. io: start(a) → text naming the job (throws only
|
|
95
|
+
* when nothing was accepted), status(id, waitSecs) → text, cancel(id), sleep(ms). */
|
|
96
|
+
async function exportUntilEnded(io, a) {
|
|
97
|
+
const started = String(await io.start(a));
|
|
98
|
+
const id = (/\bExport (\S+) /.exec(started) || [])[1];
|
|
99
|
+
if (!id || !RUNNING.test(started)) return started;
|
|
100
|
+
let r;
|
|
101
|
+
try { r = String(await io.status(id, a.timeout)); }
|
|
102
|
+
catch (e) { r = `Export ${id} running (its status couldn't be read: ${first(e && e.message)})`; }
|
|
103
|
+
if (!RUNNING.test(r)) return r;
|
|
104
|
+
try { await io.cancel(id); } catch { }
|
|
105
|
+
await io.sleep(2000); // a running tab hears the cancel in the answer to its next progress report, once a second
|
|
106
|
+
let now = "";
|
|
107
|
+
try { now = String(await io.status(id, 0)); } catch { }
|
|
108
|
+
if (/\bExport \S+ done\b/.test(now)) return now;
|
|
109
|
+
if (/\bExport \S+ (?:cancelled|failed)\b/.test(now)) return `Export ${id} stopped: it didn't finish in ${a.timeout} s`;
|
|
110
|
+
return `Export ${id} running: it couldn't be confirmed stopped${now ? " (" + first(now) + ")" : ""}`;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Make the clips. Returns the reply text. */
|
|
114
|
+
async function run(args, env) {
|
|
115
|
+
const doc0 = await env.read();
|
|
116
|
+
const o = options(args, doc0);
|
|
117
|
+
const canvas = canvasFor(o.aspect, doc0.width, doc0.height);
|
|
118
|
+
const reshaped = canvas.width * (doc0.height || 1080) !== canvas.height * (doc0.width || 1920);
|
|
119
|
+
let source = doc0.sequence || null, opened = false, halted = null;
|
|
120
|
+
const taken = new Set((doc0.sequences || []).map((s) => s.id));
|
|
121
|
+
const made = [], lines = [];
|
|
122
|
+
const step = (i, what) => { if (typeof env.progress === "function") env.progress(`clip ${i + 1} of ${o.clips.length}, ${what}`, made.length); };
|
|
123
|
+
// measured on the source as it was (the open sequence may be the last clip by now); every lane named,
|
|
124
|
+
// since an extract given none skips the untargeted ones, and those must be cut too
|
|
125
|
+
const total = end(doc0);
|
|
126
|
+
const lanes = doc0.tracks && doc0.tracks.length ? doc0.tracks.map((t) => t.id) : [...new Set((doc0.clips || []).map((x) => x.track).filter(Boolean))];
|
|
127
|
+
for (let i = 0; i < o.clips.length; i++) {
|
|
128
|
+
const c = o.clips[i];
|
|
129
|
+
step(i, "cutting");
|
|
130
|
+
let id = "seq_clip" + (i + 1);
|
|
131
|
+
for (let n = 2; taken.has(id); n++) id = "seq_clip" + (i + 1) + "_" + n;
|
|
132
|
+
taken.add(id);
|
|
133
|
+
// the copy: the source timeline on the clip's canvas, cut down to from → to
|
|
134
|
+
const ops = [];
|
|
135
|
+
if (opened) ops.push({ op: "openSequence", id: source }); // the last clip's sequence is open
|
|
136
|
+
ops.push({ op: "addSequence", id, name: c.name, from: "open", width: canvas.width, height: canvas.height, open: true });
|
|
137
|
+
if (c.to < total - 0.001) ops.push({ op: "extract", from: c.to, to: total + 1, tracks: lanes });
|
|
138
|
+
if (c.from > 0.001) ops.push({ op: "extract", from: 0, to: c.from, tracks: lanes });
|
|
139
|
+
ops.push({ op: "setProject", set: { inPoint: null, outPoint: null } });
|
|
140
|
+
// a patch saves all of it or nothing: a clip that can't be cut is reported, and the next one goes on
|
|
141
|
+
try { await env.patch(ops); }
|
|
142
|
+
catch (e) { lines.push(` ${i + 1}. "${c.name}": not made (${first(e.message)})`); continue; }
|
|
143
|
+
opened = true;
|
|
144
|
+
if (!source) source = ((await env.read()).sequences || []).find((s) => s.id !== id)?.id || "main";
|
|
145
|
+
const len = Math.round((c.to - c.from) * 1000) / 1000, notes = [];
|
|
146
|
+
if (o.reframe && reshaped) {
|
|
147
|
+
step(i, "framing");
|
|
148
|
+
// the editor may save while the footage is read (just after opening, probing media): try once more
|
|
149
|
+
let err = null;
|
|
150
|
+
for (let k = 0; k < 2; k++) {
|
|
151
|
+
try { await env.reframe({}); err = null; break; }
|
|
152
|
+
catch (e) { err = e; if (!/changed/i.test(e.message)) break; }
|
|
153
|
+
}
|
|
154
|
+
notes.push(err ? "not reframed (" + first(err.message) + ")" : "framed on the subject");
|
|
155
|
+
}
|
|
156
|
+
if (o.title && c.title) {
|
|
157
|
+
const now = await env.read(), lane = freeTopLane(now, Math.min(TITLE_SECS, len));
|
|
158
|
+
if (lane) {
|
|
159
|
+
try { await env.patch([{ op: "addClip", clip: titleClip(id + "_title", c.title, lane, canvas.width, canvas.height, len) }]); notes.push(`hook title "${c.title}"`); }
|
|
160
|
+
catch (e) { notes.push("no title (" + first(e.message) + ")"); }
|
|
161
|
+
} else notes.push("no title (the top video lane is busy or locked — add a lane, then a title)");
|
|
162
|
+
}
|
|
163
|
+
if (o.captions) {
|
|
164
|
+
step(i, "captions");
|
|
165
|
+
try {
|
|
166
|
+
const r = String(await env.captions({ style: o.captions }));
|
|
167
|
+
// still transcribing (Studio answers before a long first transcription is done): say so, don't claim them
|
|
168
|
+
if (/call \S+ again|carries on/i.test(r)) notes.push("captions not added yet: the speech is still being transcribed — then openSequence and fablecut_captions {style:\"" + o.captions + "\"}");
|
|
169
|
+
else notes.push(o.captions + " captions");
|
|
170
|
+
}
|
|
171
|
+
catch (e) { notes.push("no captions (" + first(e.message) + ")"); }
|
|
172
|
+
}
|
|
173
|
+
let file = "", haltWhy = "";
|
|
174
|
+
if (o.exportPreset) {
|
|
175
|
+
step(i, "exporting");
|
|
176
|
+
try {
|
|
177
|
+
const r = String(await env.exportClip({ preset: o.exportPreset, name: fileName(c.name), timeout: Math.max(EXPORT_MIN_S, Math.ceil(len * EXPORT_PER_S)) }));
|
|
178
|
+
file = (r.match(/exports\/[^\s"'),]+/) || [""])[0];
|
|
179
|
+
// an export that hasn't ended still renders the open sequence: opening another one would change its frames
|
|
180
|
+
if (RUNNING.test(r)) { file = ""; haltWhy = "its export is still running"; notes.push("not exported (" + first(r) + ")"); }
|
|
181
|
+
// only a finished export counts: a stopped one is reported as it is
|
|
182
|
+
else if (file && !/ (failed|cancelled)\b|check again/i.test(r)) notes.push("exported → " + file);
|
|
183
|
+
else { file = ""; notes.push("not exported (" + first(r) + ")"); }
|
|
184
|
+
} catch (e) {
|
|
185
|
+
// the request failed: whether the export started isn't known, and one that did renders the open sequence
|
|
186
|
+
notes.push("not exported (" + first(e.message) + ")");
|
|
187
|
+
haltWhy = "its export request failed, so whether it started isn't known";
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
made.push({ id, name: c.name, file });
|
|
191
|
+
lines.push(` ${i + 1}. "${c.name}" (${id}, ${len.toFixed(1)} s from ${c.from.toFixed(2)}–${c.to.toFixed(2)} s): ${notes.join(", ") || "made"}`);
|
|
192
|
+
if (haltWhy) {
|
|
193
|
+
halted = { clip: c.name, why: haltWhy };
|
|
194
|
+
if (i + 1 < o.clips.length) lines.push(` The clips after "${c.name}" weren't made: ${halted.why}, and opening another sequence would change what a running export renders. ` +
|
|
195
|
+
"Check fablecut_export (its job, or the export queue), then call again with those parts.");
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (!made.length) throw new Error("no clip was made:\n" + lines.join("\n"));
|
|
200
|
+
if (made.length > 1 && !halted) { try { await env.patch([{ op: "openSequence", id: made[0].id }]); } catch { } }
|
|
201
|
+
return `Made ${made.length} clip${made.length === 1 ? "" : "s"} on ${canvas.width}×${canvas.height} (${o.aspect}), each its own sequence; the source timeline is left as it was:\n` +
|
|
202
|
+
lines.join("\n") + (halted ? `\n"${halted.clip}" stays open (${halted.why}). ` : `\nOpened "${made[0].name}". `) + "Check each with fablecut_frame {time} after openSequence; " +
|
|
203
|
+
(o.exportPreset ? "the files are in exports/." : "export one with openSequence then fablecut_export {preset, name}, or call again with export:\"tiktok\".");
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return { ASPECTS, CAPTION_STYLES, MAX_CLIPS, MIN_LEN, MAX_LEN, canvasFor, options, titleClip, freeTopLane, exportUntilEnded, run };
|
|
207
|
+
});
|
package/import-url.js
CHANGED
|
@@ -175,13 +175,20 @@ function requestOnce(u, { signal, timeoutMs }) {
|
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
function saveResponse(res, u, destDir, { signal, maxBytes }) {
|
|
178
|
+
function saveResponse(res, u, destDir, { signal, maxBytes, name: wanted }) {
|
|
179
179
|
const mime = (res.headers["content-type"] || "").split(";")[0].trim().toLowerCase();
|
|
180
180
|
if (mime === "text/html" || mime === "application/json") {
|
|
181
181
|
res.resume();
|
|
182
182
|
return Promise.reject(new Error("URL did not return a media file"));
|
|
183
183
|
}
|
|
184
|
-
|
|
184
|
+
let name = filenameFrom(u, res.headers);
|
|
185
|
+
// a caller's name (e.g. "Title - Artist.mp3") keeps the served file's extension when it has a known one
|
|
186
|
+
if (wanted) {
|
|
187
|
+
const ext = kindFromName(name) ? path.extname(name) : path.extname(String(wanted));
|
|
188
|
+
// no dotfile, and the stem is cut (not the extension) so the type is still known
|
|
189
|
+
const stem = safeName(path.basename(String(wanted), path.extname(String(wanted))).trim().replace(/^\.+/, "")).replace(/^\.+/, "").slice(0, 100);
|
|
190
|
+
name = (stem || "download") + ext.slice(0, 10);
|
|
191
|
+
}
|
|
185
192
|
const kind = kindFromName(name);
|
|
186
193
|
// /media/*.svg is served same-origin as image/svg+xml. A remote file with
|
|
187
194
|
// <script> opened as a document would run on the editor origin.
|
|
@@ -260,7 +267,7 @@ async function downloadImportUrl(raw, destDir, opts = {}) {
|
|
|
260
267
|
res.resume();
|
|
261
268
|
throw new Error("download failed: HTTP " + res.statusCode);
|
|
262
269
|
}
|
|
263
|
-
return saveResponse(res, current, destDir, { signal, maxBytes });
|
|
270
|
+
return saveResponse(res, current, destDir, { signal, maxBytes, name: opts.name });
|
|
264
271
|
}
|
|
265
272
|
throw new Error("too many redirects");
|
|
266
273
|
}
|
package/index.html
CHANGED
|
@@ -58,11 +58,16 @@
|
|
|
58
58
|
</div>
|
|
59
59
|
<div class="bin-tabs" id="binTabs">
|
|
60
60
|
<button type="button" data-tab="project" class="on" title="Media used by this project — right-click for New folder">Project</button>
|
|
61
|
-
<button type="button" data-
|
|
62
|
-
<button type="button" data-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
<button type="button" data-tab="
|
|
61
|
+
<button type="button" data-group="audio" title="Music and sound effects">Audio</button>
|
|
62
|
+
<button type="button" data-group="graphics" title="Overlay art, vector animations, shapes and templates">Graphics</button>
|
|
63
|
+
</div>
|
|
64
|
+
<div class="bin-subtabs hidden" id="binSubTabs">
|
|
65
|
+
<button type="button" data-tab="music" data-group="audio" title="Find openly licensed music (Openverse), each track with its licence">Music</button>
|
|
66
|
+
<button type="button" data-tab="sfx" data-group="audio" title="Sound effects: search online (Freesound, each with its licence) and your library/sfx files">SFX</button>
|
|
67
|
+
<button type="button" data-tab="elements" data-group="graphics" title="Overlay art from library/elements">Elements</button>
|
|
68
|
+
<button type="button" data-tab="svg" data-group="graphics" title="Vector animations from library/svg">SVG</button>
|
|
69
|
+
<button type="button" data-tab="shapes" data-group="graphics" title="Shape layers and null objects">Shapes</button>
|
|
70
|
+
<button type="button" data-tab="templates" data-group="graphics" title="Lower thirds, logo animations and social layouts — with fields you edit in the Inspector">Templates</button>
|
|
66
71
|
</div>
|
|
67
72
|
<div class="bin-tools" id="binTools">
|
|
68
73
|
<input type="search" id="binSearch" class="bin-search" placeholder="Search name, #tag, codec, 4k…" aria-label="Search the Project bin" spellcheck="false" autocomplete="off">
|
|
@@ -449,6 +454,7 @@
|
|
|
449
454
|
</div>
|
|
450
455
|
<div class="export-track-warn hidden" id="dlvWarn" role="status"></div>
|
|
451
456
|
<div class="export-track-warn hidden" id="exportTrackWarn" role="status"></div>
|
|
457
|
+
<div class="export-credits hidden" id="exportCredits"></div>
|
|
452
458
|
</div>
|
|
453
459
|
<div class="dialog-actions">
|
|
454
460
|
<label class="export-skip" title="The Export button then renders straight away with these settings. Settings brings this dialog back."><input type="checkbox" id="exportSkipAsk"> Don't ask again</label>
|
|
@@ -713,6 +719,7 @@
|
|
|
713
719
|
<script src="mask.js"></script>
|
|
714
720
|
<script src="tracker.js"></script>
|
|
715
721
|
<script src="reframe.js"></script>
|
|
722
|
+
<script src="clips.js"></script>
|
|
716
723
|
<script src="highlights.js"></script>
|
|
717
724
|
<script src="motion.js"></script>
|
|
718
725
|
<script src="color.js"></script>
|
|
@@ -721,6 +728,7 @@
|
|
|
721
728
|
<script src="sequences.js"></script>
|
|
722
729
|
<script src="templates.js"></script>
|
|
723
730
|
<script src="media-lib.js"></script>
|
|
731
|
+
<script src="music.js"></script>
|
|
724
732
|
<script src="command-search.js"></script>
|
|
725
733
|
<script src="delivery.js"></script>
|
|
726
734
|
<script src="mp4-demux.js"></script>
|
package/manifest.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"manifest_version": "0.2",
|
|
3
3
|
"name": "fablecut",
|
|
4
4
|
"display_name": "FableCut",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.22.0",
|
|
6
6
|
"description": "Zero-dependency browser video editor that AI agents can drive — JSON timeline, MCP tools, live-reloading UI.",
|
|
7
7
|
"long_description": "FableCut is a Premiere-style non-linear video editor that runs in the browser with zero npm dependencies. An AI agent edits video by patching a single project.json timeline (clips, keyframes, transitions, text animations, filters, speed ramps, adjustment layers) through MCP tools, with color grading, masks and tracking, an audio mixer with effects, motion graphics (shape layers, compositions, animation presets and templates), and media management with offline relink and proxies; the open editor UI live-reloads within ~150 ms and exports through ffmpeg with delivery presets (YouTube, Reels, TikTok, Broadcast ProRes, lossless archive…), batch outputs from one render, loudness normalization and a check of every file. Includes reference-video analysis (shot cuts, beats, BPM, energy, drop) so agents can remake an edit with new footage.",
|
|
8
8
|
"author": {
|
|
@@ -43,9 +43,11 @@
|
|
|
43
43
|
{ "name": "fablecut_beats", "description": "Find the music's beat (BPM, a steady beat grid, the drop), mark it, snap cuts to it, or re-cut a track's clips on it" },
|
|
44
44
|
{ "name": "fablecut_reframe", "description": "Reframe for another shape (9:16, 1:1, 4:5): a copy of the sequence on that canvas whose shots follow the subject" },
|
|
45
45
|
{ "name": "fablecut_highlights", "description": "The best moments of long footage (movement, sound, a clear picture) cut into a short edit in a new sequence" },
|
|
46
|
+
{ "name": "fablecut_clips", "description": "A long video into short clips in one call: each part a new 9:16 sequence, framed on the subject, with a hook title, captions and an optional export" },
|
|
46
47
|
{ "name": "fablecut_transcribe", "description": "Transcribe speech word by word in the browser, read it on the timeline, find a phrase and cut it out (text-based editing)" },
|
|
47
48
|
{ "name": "fablecut_captions", "description": "Make captions from the transcript (subtitle, karaoke, word highlight, word pop), timed word by word; export or import SRT / WebVTT" },
|
|
48
49
|
{ "name": "fablecut_proxy", "description": "Make, check or delete proxies: light copies of heavy footage the editor plays while editing (export always uses the originals)" },
|
|
50
|
+
{ "name": "fablecut_music", "description": "Find openly licensed music and sound effects (Openverse) with each licence spelled out, import a track, and list the credits the edit needs" },
|
|
49
51
|
{ "name": "fablecut_workflows", "description": "Save workflows (recipes of steps and the tool calls that did them) and follow them again on other projects" },
|
|
50
52
|
{ "name": "fablecut_versions", "description": "Save, compare, restore and mark final versions of a project; restoring never loses the current state" },
|
|
51
53
|
{ "name": "fablecut_projects", "description": "List, open, create, duplicate, rename, annotate, archive and delete projects; start new ones from canvas presets or saved project templates" },
|
package/mcp-server.js
CHANGED
|
@@ -39,6 +39,7 @@ const CompLib = require("./comp");
|
|
|
39
39
|
const SeqLib = require("./sequences");
|
|
40
40
|
const Templates = require("./templates");
|
|
41
41
|
const Workflows = require("./workflows");
|
|
42
|
+
const Music = require("./music");
|
|
42
43
|
const Delivery = require("./delivery");
|
|
43
44
|
const { probeFile, infoForEntry } = require("./media-probe");
|
|
44
45
|
const { findProxies } = require("./proxy");
|
|
@@ -354,6 +355,26 @@ const TOOLS = [
|
|
|
354
355
|
},
|
|
355
356
|
},
|
|
356
357
|
},
|
|
358
|
+
{
|
|
359
|
+
name: "fablecut_clips",
|
|
360
|
+
description: "A long video into short clips, in one call: the clipper's job (a podcast, an interview, a talk, a stream into Shorts / Reels / TikToks). First read what is said with fablecut_transcribe and pick the parts that stand on their own (a tip, an answer, a story, a strong opinion; usually 20–60 s each, starting and ending on a full sentence), then pass them here as timeline seconds. For each one it makes a new sequence on the clip's canvas (default 9:16) holding only that part of the open timeline — the source is left as it was — frames each shot on the subject (as fablecut_reframe), adds a hook title in the top third for the first 3 s (when you give `title`), makes captions timed to the words (as fablecut_captions, default style pop), and with export:\"tiktok\" (or any delivery preset) renders each one to exports/, named after the clip. The reply lists each clip and what was done; the first clip is opened. A version is saved first.",
|
|
361
|
+
inputSchema: {
|
|
362
|
+
type: "object",
|
|
363
|
+
required: ["clips"],
|
|
364
|
+
properties: {
|
|
365
|
+
clips: { type: "array", minItems: 1, maxItems: 10, description: "The clips to make, up to 10", items: { type: "object", required: ["from", "to"], properties: {
|
|
366
|
+
from: { type: "number", description: "Start, timeline seconds (start on a sentence)" },
|
|
367
|
+
to: { type: "number", description: "End, timeline seconds (3…180 s after from; end after a sentence)" },
|
|
368
|
+
name: { type: "string", description: "The clip's sequence (and file) name, e.g. \"Tip 1 - comfort zone\"" },
|
|
369
|
+
title: { type: "string", description: "The hook title shown for its first 3 s, a few punchy words (left out: no title)" } } } },
|
|
370
|
+
aspect: { type: "string", enum: ["9:16", "1:1", "4:5", "16:9"], description: "The clips' shape (default 9:16)" },
|
|
371
|
+
captions: { anyOf: [{ type: "string", enum: ["pop", "highlight", "karaoke", "subtitle"] }, { type: "boolean", enum: [false] }], description: "Caption style (default pop), or false for none" },
|
|
372
|
+
reframe: { type: "boolean", description: "Follow the subject on the new canvas (default true)" },
|
|
373
|
+
title: { type: "boolean", description: "false leaves the hook titles out even where clips give one" },
|
|
374
|
+
export: { type: "string", description: "Render each clip with this delivery preset (tiktok, youtube-shorts, instagram-reels, …; see fablecut_encode_profiles). Left out: no export" },
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
},
|
|
357
378
|
{
|
|
358
379
|
name: "fablecut_transcribe",
|
|
359
380
|
description: "What is said, word by word, with times — and text-based editing. Transcribes the clips' speech with Whisper in the editor (an open tab, else headless Chrome / Edge; the speech model downloads once, the audio never leaves the machine), keeps one transcript per file (analysis/transcripts/), and answers with the timeline's words as timed lines (timeline seconds), so you can read an interview, pick the good takes, or find where something is said. find:\"phrase\" (or a list) reports every place it is said — case, punctuation and spacing ignored, whole words only — with the exact span; cut:true then extracts each of them on the targeted tracks (or `tracks`), the words and the pause after them, last first, in one revision: later material moves up, linked stems stay in sync, locked clips stay put (lock the music bed first). A version is saved before a cut. Files already transcribed aren't done again unless again:true. Default clips: every video / audio clip with sound on the open timeline. mediaIds reads whole files instead (file seconds; no cut). The same as the editor's Transcript tab.",
|
|
@@ -471,6 +492,24 @@ const TOOLS = [
|
|
|
471
492
|
},
|
|
472
493
|
},
|
|
473
494
|
},
|
|
495
|
+
{
|
|
496
|
+
name: "fablecut_music",
|
|
497
|
+
description: "Find music (or sound effects) the user may use, and import a track: openly licensed audio from Openverse (Jamendo, Freesound, ccMixter, Wikimedia Commons…). Every result carries its licence and what it allows: free to use (CC0, public domain), credit the artist (BY), non-commercial only (NC), share alike (SA), or no edits (ND — music set to video counts as an edit, so it can't go into one). Search: {query:'upbeat acoustic', kind?:'music'|'sfx', length?:'shortest'|'short'|'medium'|'long' (under 30 s · 30 s–2 min · 2–10 min · over 10 min), commercial?:true (only licences that allow commercial use), edits?:true, licenses?:['by','cc0',…], page?} → 20 tracks a page (id, title, artist, length, licence). Import: {import:'<track id>'} downloads it into media/ and registers it with its licence (m.license); place it with addClip on an audio track, then fablecut_beats {clipId} finds its tempo. Credits: {credits:true} → the credit lines the edit's licensed music needs (for the video's description) and any licence warnings. Tell the user which licence a track has before they publish; when they plan to monetize, search with commercial:true. Search when the user asks for music or a song; import the one they pick (or the best fit, when they asked you to choose). Anonymous Openverse use allows about 20 searches a minute and 200 a day.",
|
|
498
|
+
inputSchema: {
|
|
499
|
+
type: "object",
|
|
500
|
+
properties: {
|
|
501
|
+
query: { type: "string", description: "search: words about the music — mood, genre, instrument (e.g. 'chill lo-fi piano'); leave out for the newest tracks" },
|
|
502
|
+
kind: { type: "string", enum: ["music", "sfx"], description: "search: music (default) or sound effects" },
|
|
503
|
+
length: { type: "string", enum: ["shortest", "short", "medium", "long"], description: "search: under 30 s · 30 s–2 min · 2–10 min · over 10 min" },
|
|
504
|
+
commercial: { type: "boolean", description: "search: only licences that allow commercial use" },
|
|
505
|
+
edits: { type: "boolean", description: "search: only licences that allow edits (leaves out ND)" },
|
|
506
|
+
licenses: { type: "array", items: { type: "string", enum: ["cc0", "pdm", "by", "by-sa", "by-nc", "by-nc-sa", "by-nd", "by-nc-nd", "sampling+", "nc-sampling+"] }, description: "search: only these licences" },
|
|
507
|
+
page: { type: "integer", description: "search: page 1–12 of the results" },
|
|
508
|
+
import: { type: "string", description: "a track id from a search: download it into media/ and register it" },
|
|
509
|
+
credits: { type: "boolean", description: "the credit lines for the licensed music the edit uses" },
|
|
510
|
+
},
|
|
511
|
+
},
|
|
512
|
+
},
|
|
474
513
|
{
|
|
475
514
|
name: "fablecut_proxy",
|
|
476
515
|
description: "Proxies: light H.264 copies (540p by default, 720p or 1080p; never larger than the source) of heavy footage — 4K, HEVC, ProRes, long phone clips — that the editor plays while the user edits, so playback and scrubbing stay smooth. Export, fablecut_frame, fablecut_scopes and every measurement always read the original, so a proxy never changes the result. Without create or delete it reports each video's proxy (ready, being made with its progress, failed, none). create:true makes them (one at a time, in the background on the server) and waits until they are done unless wait:false; delete:true removes them. mediaIds defaults to every video in the project. The user turns proxy playback on or off with the monitor's Proxy button. Needs ffmpeg on PATH.",
|
|
@@ -945,6 +984,29 @@ async function highlightsTool(args) {
|
|
|
945
984
|
"\nCheck a moment with fablecut_frame {time}; with music under it, fablecut_beats {clipId, retime:{every:2}} cuts it on the beat." +
|
|
946
985
|
(verWarn || "\nThe project as it was is kept as a version (fablecut_versions; restore undoes it).");
|
|
947
986
|
}
|
|
987
|
+
/* fablecut_clips: clips.js runs the steps, each through the tool that does it here. */
|
|
988
|
+
async function clipsTool(args) {
|
|
989
|
+
const Clips = require("./clips.js");
|
|
990
|
+
Clips.options(args, readProject()); // refuse bad arguments before anything changes
|
|
991
|
+
let verWarn = "";
|
|
992
|
+
try { createHistory({ projects: createProjects({ dataDir: DATA_DIR, projectFile: PROJECT_FILE, libraryDir: LIBRARY_DIR }) }).beforeAgent("Before making clips"); }
|
|
993
|
+
catch (e) { verWarn = ` Warning: no version was saved first (${e.message}).`; }
|
|
994
|
+
const text = (r) => (typeof r === "string" ? r : (r?.content || []).map((c) => c.text || "").join("\n"));
|
|
995
|
+
const reply = await Clips.run(args, {
|
|
996
|
+
read: () => readProject(),
|
|
997
|
+
patch: async (ops) => text(await callTool("fablecut_patch_project", { ops }, 0)),
|
|
998
|
+
reframe: (a) => reframeTool(a),
|
|
999
|
+
captions: (a) => captionsTool(a),
|
|
1000
|
+
// answers once its export has ended, before the next clip opens another sequence (clips.js)
|
|
1001
|
+
exportClip: (a) => Clips.exportUntilEnded({
|
|
1002
|
+
start: async (x) => text(await exportTool({ ...x, wait: false })),
|
|
1003
|
+
status: async (id, secs) => text(await exportTool(secs ? { job: id, wait: true, timeout: secs } : { job: id })),
|
|
1004
|
+
cancel: (id) => exportTool({ cancel: id }),
|
|
1005
|
+
sleep,
|
|
1006
|
+
}, a),
|
|
1007
|
+
});
|
|
1008
|
+
return reply + (verWarn || "\nThe project as it was is kept as a version (fablecut_versions; restore undoes it).");
|
|
1009
|
+
}
|
|
948
1010
|
/** What words are placed by and cuts land on: where each clip sits and plays from, the track
|
|
949
1011
|
* switches and the frame rate. An editor saving probed media details while a transcription runs
|
|
950
1012
|
* doesn't change it; a moved, trimmed or cut clip does. */
|
|
@@ -1223,8 +1285,9 @@ async function denoiseTool(args) {
|
|
|
1223
1285
|
if (!m) {
|
|
1224
1286
|
m = { id: "m_" + uid(), name: r.name, kind: "audio", src, duration: r.duration, folderId: base.folderId || null,
|
|
1225
1287
|
derivedFrom: base.id, denoise: amount };
|
|
1288
|
+
if (base.license) m.license = { ...base.license }; // the credit stays with the sound
|
|
1226
1289
|
proj.media.push(m);
|
|
1227
|
-
}
|
|
1290
|
+
} else if (base.license && !m.license) m.license = { ...base.license }; // a copy made before the file had a licence
|
|
1228
1291
|
swap.set(id, m.id);
|
|
1229
1292
|
report.push(`${id} → ${m.id} "${r.name}"${r.cached ? " (already rendered)" : ""}`);
|
|
1230
1293
|
}
|
|
@@ -1298,6 +1361,95 @@ async function projectsTool(args) {
|
|
|
1298
1361
|
if (out.from) return `Opened ${describeProject(out.project)}\nThe editor switched to it (${out.from} was saved first). Read it with fablecut_get_project {compact:true} before editing.`;
|
|
1299
1362
|
return describeProject(out.project);
|
|
1300
1363
|
}
|
|
1364
|
+
/** Register a file already in media/ as project media (probed) → the entry. extra: more keys
|
|
1365
|
+
* (license, name); extra.keepRead: leave lastReadRevision alone, so a set_project after this
|
|
1366
|
+
* needs a fresh read (the caller never handed the new document back). */
|
|
1367
|
+
async function registerFile(target, kind, extra = {}) {
|
|
1368
|
+
const entry = {
|
|
1369
|
+
id: "m_" + uid(),
|
|
1370
|
+
name: extra.name || path.basename(target),
|
|
1371
|
+
kind,
|
|
1372
|
+
src: "/media/" + encodeURIComponent(path.basename(target)),
|
|
1373
|
+
duration: kind === "image" || kind === "svg" ? undefined : ffprobeDuration(target),
|
|
1374
|
+
};
|
|
1375
|
+
Object.assign(entry, infoForEntry(await probeFile(target), entry));
|
|
1376
|
+
if (extra.license) entry.license = extra.license;
|
|
1377
|
+
const proj = readProject();
|
|
1378
|
+
// import only appends a media entry (never touches clips), so it merges
|
|
1379
|
+
// into the live document; keep lastReadRevision in step only if it
|
|
1380
|
+
// already was — otherwise a later set_project must still re-read
|
|
1381
|
+
const wasCurrent = lastReadRevision === (proj.revision || 0);
|
|
1382
|
+
proj.media.push(entry);
|
|
1383
|
+
proj.revision = (proj.revision || 0) + 1;
|
|
1384
|
+
writeProject(proj);
|
|
1385
|
+
if (wasCurrent && !extra.keepRead) lastReadRevision = proj.revision;
|
|
1386
|
+
return entry;
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
/* fablecut_music: Openverse search (music.js builds the URLs and reads the licences). */
|
|
1390
|
+
async function openverse(url) {
|
|
1391
|
+
// tests only: a local stand-in for the Openverse API (its files are then on 127.0.0.1 too)
|
|
1392
|
+
if (process.env.FABLECUT_TEST_OPENVERSE) url = url.replace(Music.API, process.env.FABLECUT_TEST_OPENVERSE);
|
|
1393
|
+
let r;
|
|
1394
|
+
try {
|
|
1395
|
+
r = await fetch(url, { headers: { Accept: "application/json", "User-Agent": "FableCut (+https://fablecut.space)" }, signal: AbortSignal.timeout(20_000) });
|
|
1396
|
+
} catch (e) {
|
|
1397
|
+
throw new Error("couldn't reach Openverse (" + (e && e.name === "TimeoutError" ? "no answer in 20 s" : e.message) + ")");
|
|
1398
|
+
}
|
|
1399
|
+
if (r.status === 429) throw new Error("Openverse's limit for anonymous searches is used up for now (about 20 a minute, 200 a day) — try again later");
|
|
1400
|
+
if (r.status === 404) throw new Error("Openverse has no such track");
|
|
1401
|
+
const body = await r.json().catch(() => null);
|
|
1402
|
+
if (!r.ok) throw new Error("Openverse answered " + r.status + (body && body.detail ? ": " + body.detail : ""));
|
|
1403
|
+
if (!body || typeof body !== "object") throw new Error("Openverse's answer couldn't be read — try again");
|
|
1404
|
+
return body;
|
|
1405
|
+
}
|
|
1406
|
+
const fmtLen = (s) => s == null ? "?:??" : Music.fmtLen(s);
|
|
1407
|
+
function creditsText(proj) {
|
|
1408
|
+
const list = Music.credits(proj, Music.editUsage(proj)); // the open sequence and the comps it places
|
|
1409
|
+
if (!list.length) return "";
|
|
1410
|
+
return [`CREDITS — licensed music in this edit (put these in the video's description):`,
|
|
1411
|
+
...list.map((c) => ` ${c.needsCredit ? c.line : c.line + " (no credit required)"}`),
|
|
1412
|
+
...list.flatMap((c) => c.warnings.map((w) => ` ⚠ ${w}`))].join("\n");
|
|
1413
|
+
}
|
|
1414
|
+
async function musicTool(args) {
|
|
1415
|
+
if (args.credits) {
|
|
1416
|
+
const text = creditsText(readProject());
|
|
1417
|
+
return text || "The edit uses no music imported with its licence (fablecut_music import) — no credits to list.";
|
|
1418
|
+
}
|
|
1419
|
+
if (args.import) {
|
|
1420
|
+
const t = Music.track(await openverse(Music.trackUrl(args.import)));
|
|
1421
|
+
if (!t.url) throw new Error("Openverse lists no file for this track");
|
|
1422
|
+
// a new file every time (the downloader never reuses a name), so a failed registration removes it
|
|
1423
|
+
const got = await downloadImportUrl(t.url, MEDIA_DIR, { name: Music.fileName(t), allowLoopback: !!process.env.FABLECUT_TEST_OPENVERSE });
|
|
1424
|
+
let entry;
|
|
1425
|
+
try {
|
|
1426
|
+
const kind = kindFromName(got.name);
|
|
1427
|
+
if (kind !== "audio" && kind !== "video") throw new Error("the track's file isn't audio: " + got.name);
|
|
1428
|
+
// always an audio entry, even in a video container: it's a music track, placed on an A track
|
|
1429
|
+
entry = await registerFile(got.target, "audio", { name: `${t.title} — ${t.creator}`, license: Music.mediaLicense(t), keepRead: true });
|
|
1430
|
+
} catch (e) {
|
|
1431
|
+
try { fs.rmSync(got.target, { force: true }); } catch {}
|
|
1432
|
+
throw e;
|
|
1433
|
+
}
|
|
1434
|
+
const lic = t.license, limits = Music.warnings(lic);
|
|
1435
|
+
return [`Imported "${t.title}" by ${t.creator} → ${entry.id} (${fmtLen(entry.duration)}, ${entry.src})`,
|
|
1436
|
+
`Licence: ${lic.label} — ${lic.note}.`,
|
|
1437
|
+
lic.credit ? `Credit: ${Music.creditLine(entry.license)}` : "",
|
|
1438
|
+
...limits.map((w) => `⚠ ${w}`),
|
|
1439
|
+
!lic.edits || lic.sampling
|
|
1440
|
+
? `Don't set this track under the video as it is: its licence doesn't allow that. Search again for one whose licence allows edits (edits:true).`
|
|
1441
|
+
: `Place it: {op:"addClip", clip:{mediaId:"${entry.id}", kind:"audio", track:"A1", start:0, in:0, duration:<≤ ${entry.duration || "its length"}>}} — then fablecut_beats {clipId} for its tempo.`,
|
|
1442
|
+
].filter(Boolean).join("\n");
|
|
1443
|
+
}
|
|
1444
|
+
if (args.page != null && !(Number.isInteger(args.page) && args.page >= 1 && args.page <= Music.MAX_PAGE)) throw new Error(`page is 1–${Music.MAX_PAGE}`);
|
|
1445
|
+
const res = Music.results(await openverse(Music.searchUrl(args)), args.page || 1);
|
|
1446
|
+
if (!res.tracks.length) return `No ${args.kind === "sfx" ? "sound effects" : "music"} found${args.query ? ` for "${args.query}"` : ""} — try other words, or drop a filter.`;
|
|
1447
|
+
return [`${res.count >= 240 ? "240+" : res.count} result(s), page ${res.page}/${res.pages || 1}${args.query ? ` for "${args.query}"` : " (newest)"}. {import:"<id>"} downloads one.`,
|
|
1448
|
+
...res.tracks.map((t, i) => `${i + 1}. ${t.id} "${t.title}" — ${t.creator} · ${fmtLen(t.duration)} · ${t.license.label} [${t.flags.join(", ")}]` +
|
|
1449
|
+
(t.genres.length ? ` · ${t.genres.join("/")}` : "") + (t.source ? ` · ${t.source}` : "")),
|
|
1450
|
+
Music.ABOUT].join("\n");
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1301
1453
|
/* fablecut_workflows: saved recipes in library/workflows/, read and written here directly
|
|
1302
1454
|
(like saved presets), so it works without the editor server. */
|
|
1303
1455
|
function savedWorkflows() {
|
|
@@ -1478,6 +1630,8 @@ async function exportTool(args) {
|
|
|
1478
1630
|
const r = await apiJSON("POST", "/api/export/request", { range: args.range, profile: args.profile, preset: args.preset, delivery: args.delivery, outputs: args.outputs, name, where: args.where || "auto" });
|
|
1479
1631
|
if (r.status !== 200) throw new Error(r.body?.error || `export request failed (${r.status})`);
|
|
1480
1632
|
job = r.body;
|
|
1633
|
+
// the credits of the timeline this job renders, kept with the job for later polls
|
|
1634
|
+
try { const p = readProject(); jobCredits.set(job.id, { revision: p.revision || 0, text: creditsText(p) }); } catch {}
|
|
1481
1635
|
if (job.notes && job.notes.length) startNote = `Settings adjusted: ${job.notes.join("; ")}\n`;
|
|
1482
1636
|
if (args.wait === false) return (job.delivery ? `Output: ${job.delivery}\n` : "") + startNote + describeExportJob(job);
|
|
1483
1637
|
}
|
|
@@ -1490,8 +1644,23 @@ async function exportTool(args) {
|
|
|
1490
1644
|
if (r.status !== 200) throw new Error(r.body?.error || "lost track of the export job");
|
|
1491
1645
|
job = r.body;
|
|
1492
1646
|
}
|
|
1493
|
-
|
|
1647
|
+
// licensed music the edit uses: the credits belong in the video's description
|
|
1648
|
+
let credits = "";
|
|
1649
|
+
if (job.status === "done" && jobCredits.has(job.id)) {
|
|
1650
|
+
// the editor renders the live timeline: the credits taken at the request match it unless it changed meanwhile
|
|
1651
|
+
const kept = jobCredits.get(job.id);
|
|
1652
|
+
let now = null;
|
|
1653
|
+
try { now = readProject(); } catch {}
|
|
1654
|
+
if (now && (now.revision || 0) !== kept.revision) {
|
|
1655
|
+
const text = creditsText(now);
|
|
1656
|
+
credits = text !== kept.text
|
|
1657
|
+
? "The timeline changed while it exported, and so did its licensed music — check which version the file has before using these credits.\n" + (text || kept.text)
|
|
1658
|
+
: text;
|
|
1659
|
+
} else credits = kept.text;
|
|
1660
|
+
}
|
|
1661
|
+
return startNote + describeExportJob(job) + (credits ? "\n" + credits : "");
|
|
1494
1662
|
}
|
|
1663
|
+
const jobCredits = new Map(); // export job id → the credits of the timeline it rendered
|
|
1495
1664
|
|
|
1496
1665
|
/* ── Frames (fablecut_frame) ──
|
|
1497
1666
|
The tool is the only one that answers with an image, so it returns content
|
|
@@ -1704,6 +1873,8 @@ async function callTool(name, args, attempt = 0) {
|
|
|
1704
1873
|
return reframeTool(args);
|
|
1705
1874
|
case "fablecut_highlights":
|
|
1706
1875
|
return highlightsTool(args);
|
|
1876
|
+
case "fablecut_clips":
|
|
1877
|
+
return clipsTool(args);
|
|
1707
1878
|
case "fablecut_transcribe":
|
|
1708
1879
|
return transcribeTool(args);
|
|
1709
1880
|
case "fablecut_captions":
|
|
@@ -1718,6 +1889,8 @@ async function callTool(name, args, attempt = 0) {
|
|
|
1718
1889
|
return versionsTool(args);
|
|
1719
1890
|
case "fablecut_workflows":
|
|
1720
1891
|
return workflowsTool(args);
|
|
1892
|
+
case "fablecut_music":
|
|
1893
|
+
return musicTool(args);
|
|
1721
1894
|
case "fablecut_status": {
|
|
1722
1895
|
const up = await ensureUIServer();
|
|
1723
1896
|
const proj = readProject();
|
|
@@ -2056,23 +2229,7 @@ async function callTool(name, args, attempt = 0) {
|
|
|
2056
2229
|
fs.copyFileSync(src, target);
|
|
2057
2230
|
}
|
|
2058
2231
|
if (!kind) throw new Error("Unsupported media type");
|
|
2059
|
-
const entry =
|
|
2060
|
-
id: "m_" + uid(),
|
|
2061
|
-
name: path.basename(target),
|
|
2062
|
-
kind,
|
|
2063
|
-
src: "/media/" + encodeURIComponent(path.basename(target)),
|
|
2064
|
-
duration: kind === "image" || kind === "svg" ? undefined : ffprobeDuration(target),
|
|
2065
|
-
};
|
|
2066
|
-
Object.assign(entry, infoForEntry(await probeFile(target), entry));
|
|
2067
|
-
const proj = readProject();
|
|
2068
|
-
// import only appends a media entry (never touches clips), so it merges
|
|
2069
|
-
// into the live document; keep lastReadRevision in step only if it
|
|
2070
|
-
// already was — otherwise a later set_project must still re-read
|
|
2071
|
-
const wasCurrent = lastReadRevision === (proj.revision || 0);
|
|
2072
|
-
proj.media.push(entry);
|
|
2073
|
-
proj.revision = (proj.revision || 0) + 1;
|
|
2074
|
-
writeProject(proj);
|
|
2075
|
-
if (wasCurrent) lastReadRevision = proj.revision;
|
|
2232
|
+
const entry = await registerFile(target, kind);
|
|
2076
2233
|
return `Imported → ${JSON.stringify(entry)}\n` +
|
|
2077
2234
|
(entry.duration == null && kind !== "image"
|
|
2078
2235
|
? "Note: duration unknown (no ffprobe). The browser UI will probe and fill it in; re-read the project before trimming this media."
|
|
@@ -2133,7 +2290,7 @@ async function handle(msg) {
|
|
|
2133
2290
|
result: {
|
|
2134
2291
|
protocolVersion: negotiateProtocolVersion(params?.protocolVersion),
|
|
2135
2292
|
capabilities: { tools: {} },
|
|
2136
|
-
serverInfo: { name: "fablecut", version: "1.
|
|
2293
|
+
serverInfo: { name: "fablecut", version: "1.22.0" },
|
|
2137
2294
|
},
|
|
2138
2295
|
});
|
|
2139
2296
|
}
|