fablecut 1.19.0 → 1.20.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 +62 -4
- package/README.md +1 -0
- package/app.js +71 -38
- package/delivery.js +12 -7
- package/focus.js +165 -0
- package/index.html +2 -0
- package/manifest.json +59 -0
- package/mcp-server.js +54 -1
- package/package.json +2 -1
- package/paths.js +4 -3
- package/select-menu.js +295 -0
- package/server.js +76 -7
- package/style.css +245 -1
- package/workflows.js +153 -0
package/CLAUDE.md
CHANGED
|
@@ -74,6 +74,9 @@ Every Claude Code session then has these tools:
|
|
|
74
74
|
always the open one. See "Projects" below.
|
|
75
75
|
- `fablecut_versions` — a project's saved versions: save one before big edits, compare
|
|
76
76
|
a version with now, restore one (never destructive), mark the final cut. See "Versions" below.
|
|
77
|
+
- `fablecut_workflows` — saved workflows: recipes of steps (and the tool calls that did
|
|
78
|
+
them) the user wants repeated on other projects. Save one, list them, show one and follow
|
|
79
|
+
it. See "Workflows" below.
|
|
77
80
|
|
|
78
81
|
### Token-efficient editing (important for agents)
|
|
79
82
|
|
|
@@ -219,8 +222,9 @@ Reusable assets, visible in the editor's left-panel tabs and never copied:
|
|
|
219
222
|
| `library/fonts/` | font editor | `.ttf/.otf/.woff/.woff2`, auto-registered, family name = file name; a variable font draws every `weight` |
|
|
220
223
|
| `library/presets/` | Inspector → Motion → Presets | saved animation presets, one `.json` each (see "Presets and templates") |
|
|
221
224
|
| `library/templates/`| **Templates** | saved templates, one `.json` each, listed after the built-in ones |
|
|
225
|
+
| `library/workflows/`| — | saved workflows, one `.json` each (see "Workflows") |
|
|
222
226
|
|
|
223
|
-
- List via `GET /api/library?dir=sfx|elements|svg|fonts|presets|templates` (recursive; subfolders OK).
|
|
227
|
+
- List via `GET /api/library?dir=sfx|elements|svg|fonts|presets|templates|workflows` (recursive; subfolders OK).
|
|
224
228
|
- To use one in the timeline, add a media entry whose `src` is its library path,
|
|
225
229
|
e.g. `{ "id":"m_x", "name":"whoosh.mp3", "kind":"audio", "src":"/library/sfx/whoosh.mp3" }`
|
|
226
230
|
— then reference it from clips like any other media.
|
|
@@ -1892,6 +1896,55 @@ and restore if the user prefers the old one; **client rounds** — save "Round 1
|
|
|
1892
1896
|
"Round 2", … with the feedback in the note, mark the approved one final;
|
|
1893
1897
|
**what did the agent do?** — `diff` against the "Before agent edits" version.
|
|
1894
1898
|
|
|
1899
|
+
### Workflows
|
|
1900
|
+
|
|
1901
|
+
A **workflow** is a recipe the user wants repeated on other projects: "my podcast
|
|
1902
|
+
clean-up", "the weekly reel", "client delivery". It is a name, what it is for, and
|
|
1903
|
+
its steps in order. Each step says in plain words what to do, and may carry the
|
|
1904
|
+
tool call that did it last time. Workflows are shared by every project, one JSON
|
|
1905
|
+
file each in `library/workflows/<id>.json`:
|
|
1906
|
+
|
|
1907
|
+
```jsonc
|
|
1908
|
+
{ "id": "podcast-clean-up", "name": "Podcast clean-up",
|
|
1909
|
+
"description": "Voice level, no dead air, captions, a Shorts cut.", "tags": ["podcast"],
|
|
1910
|
+
"steps": [
|
|
1911
|
+
{ "text": "Reduce the room noise on the voice clips.",
|
|
1912
|
+
"call": { "tool": "fablecut_denoise", "args": { "clipIds": ["c_vo"], "amount": "medium" } } },
|
|
1913
|
+
{ "text": "Normalize the voice to -16 LUFS.",
|
|
1914
|
+
"call": { "tool": "fablecut_normalize_audio", "args": { "clipIds": ["c_vo"], "target": -16 } } },
|
|
1915
|
+
{ "text": "Cut the pauses longer than half a second, keeping the music bed running." },
|
|
1916
|
+
{ "text": "Export for YouTube Shorts.", "call": { "tool": "fablecut_export", "args": { "preset": "youtube-shorts" } } } ],
|
|
1917
|
+
"created": "…", "updated": "…" }
|
|
1918
|
+
```
|
|
1919
|
+
|
|
1920
|
+
| key | does |
|
|
1921
|
+
|---|---|
|
|
1922
|
+
| `name` · `id` | up to 80 characters; the id is made from the name, and saving the same name again updates that workflow (it keeps its `created`) |
|
|
1923
|
+
| `description` · `tags` | what it is for (up to 600 characters) · up to 12 labels |
|
|
1924
|
+
| `steps` | 1–50, each `{text, call?}` (a plain string is a step with only text); `text` up to 1000 characters |
|
|
1925
|
+
| `call` | `{tool, args}`: a FableCut tool (not `fablecut_workflows`) and the arguments it was given, up to 20 000 characters |
|
|
1926
|
+
|
|
1927
|
+
**Following one is a job for judgement, not a replay.** The new project has other
|
|
1928
|
+
clips, ids and times, so a step's call is a worked example: read what the step says,
|
|
1929
|
+
look at the project (`fablecut_get_project {compact:true}`, `fablecut_frame`), and
|
|
1930
|
+
make the call that does that here. A step with no call is one only the agent's
|
|
1931
|
+
judgement can do ("pick the three strongest shots").
|
|
1932
|
+
|
|
1933
|
+
**Agents** use `fablecut_workflows` (or the REST endpoints below):
|
|
1934
|
+
|
|
1935
|
+
- `{}` lists them (id, name, steps, tags, description); `{action:"show", id}` gives
|
|
1936
|
+
the steps to follow (id or name).
|
|
1937
|
+
- `{action:"save", workflow:{name, description?, tags?, steps}}` keeps one. Save when
|
|
1938
|
+
the user asks to keep or repeat what was just done: write each step the way you would
|
|
1939
|
+
explain it to another editor, and attach the calls that worked. A call to a tool that
|
|
1940
|
+
doesn't exist refuses the save.
|
|
1941
|
+
- `{action:"delete", id}` removes one: only when the user asks.
|
|
1942
|
+
|
|
1943
|
+
Recipes: **"do what you did last week"** — `{}`, then `show` the one that matches and do
|
|
1944
|
+
its steps; **a house style for every episode** — after the first episode is right, save
|
|
1945
|
+
its loudness, captions, grade and export steps as one workflow; **hand a routine to another
|
|
1946
|
+
agent** — the file in `library/workflows/` is plain JSON any agent can read.
|
|
1947
|
+
|
|
1895
1948
|
### Sequences
|
|
1896
1949
|
|
|
1897
1950
|
A project can hold several **sequences**: timelines of their own that share
|
|
@@ -2261,6 +2314,9 @@ obvious cuts were missed, raise it if motion is being misread as cuts.
|
|
|
2261
2314
|
- `GET /api/presets` · `GET /api/templates` — the saved presets / templates, validated (bad files skipped);
|
|
2262
2315
|
`POST /api/presets {preset}` · `POST /api/templates {template}` — validate one and save it as
|
|
2263
2316
|
`library/presets/<id>.json` / `library/templates/<id>.json`, returning `{id, name, file}`
|
|
2317
|
+
- `GET /api/workflows[?id=]` — the saved workflows, validated (bad files skipped), or one by id or name (404 if none) ·
|
|
2318
|
+
`POST /api/workflows {workflow}` — validate and save it as `library/workflows/<id>.json`, returning it with
|
|
2319
|
+
`created` / `updated` · `POST /api/workflows/delete {id}` → `{deleted}`. See "Workflows".
|
|
2264
2320
|
- `POST /api/upload?name=foo.mp4` — raw body saved into ./media, returns `{src}`.
|
|
2265
2321
|
MP4/MOV/M4V uploads are auto-remuxed with `+faststart` (needs ffmpeg on PATH).
|
|
2266
2322
|
Files copied straight into ./media by external tools skip this — remux big ones
|
|
@@ -2668,7 +2724,8 @@ A spec (every key optional — what is left out comes from its `preset`):
|
|
|
2668
2724
|
limit is passed, and estimates the file size where it can (bitrate and fixed-rate
|
|
2669
2725
|
codecs; CRF cannot know).
|
|
2670
2726
|
- Outputs that keep more than 4:2:0 8-bit (ProRes, DNxHR, FFV1, 10-bit, 4:2:2, 4:4:4)
|
|
2671
|
-
get
|
|
2727
|
+
get lossless PNG frames instead of JPEG, so no chroma is lost on the way: the canvas
|
|
2728
|
+
is 8-bit RGB, so PNG carries exactly its pixels. Slower to encode than JPEG.
|
|
2672
2729
|
- The audio is cut to exactly the frames' length.
|
|
2673
2730
|
- **Loudness** (`audio.loudness`): the mix is measured and turned to the target with
|
|
2674
2731
|
ffmpeg's two-pass `loudnorm` — one linear gain, and a true-peak limiter at `truePeak`.
|
|
@@ -2714,7 +2771,7 @@ ones and starts.
|
|
|
2714
2771
|
the compositor draws each frame once and every output's ffmpeg encodes it (up to 8 per
|
|
2715
2772
|
render). Four 1080p files take about as long as one. Outputs at another frame rate get
|
|
2716
2773
|
their own render. When any output needs full chroma (ProRes, 10-bit, lossless) the
|
|
2717
|
-
frames go as
|
|
2774
|
+
frames go as lossless PNG to all of them.
|
|
2718
2775
|
- **The export frame** is the picture for outputs of its own shape (and for the
|
|
2719
2776
|
picture's own size). An output of another shape reframes the whole canvas — a project
|
|
2720
2777
|
framed for 9:16 still makes a proper 16:9 file.
|
|
@@ -2724,7 +2781,8 @@ ones and starts.
|
|
|
2724
2781
|
empties it. One output that fails does not stop the others in its render.
|
|
2725
2782
|
- REST: `POST /api/export/begin {deliveries:[{delivery, name}, …], canvasW, canvasH,
|
|
2726
2783
|
region?, duration, fps, hasAudio}` → `{id, input, jpegQuality, outputs:[{file, spec,
|
|
2727
|
-
summary, notes, size}]}
|
|
2784
|
+
summary, notes, size}]}` (`input` is `"jpeg"` or `"png"`: post frames in that format,
|
|
2785
|
+
PNG for full-chroma outputs); frames and audio as for one output; `/api/export/end` →
|
|
2728
2786
|
`{src, outputs:[{file, ok, src, report:{ok, checks:[{ok, text}], line}, mixLoudness?} | {file, ok:false, error}]}`.
|
|
2729
2787
|
|
|
2730
2788
|
### Encoding profiles (`encoding-profiles.json`)
|
package/README.md
CHANGED
|
@@ -161,6 +161,7 @@ big operation (cutting silences, snapping to the beat, reframing), and every
|
|
|
161
161
|
- **Projects** — a dashboard of every project with pictures, notes and tags: open, create from a canvas or a saved project template, duplicate, rename, archive and delete, import an old project file; media is shared, so copies cost no footage
|
|
162
162
|
- **Sequences** — several timelines in one project (a 16:9 and a 9:16 cut, cut-downs, alternatives) sharing its media and compositions, each with its own canvas, frame rate, mix and delivery settings; switch from the menu at the left of the timeline toolbar
|
|
163
163
|
- **Versions** — non-destructive history: save a version (Ctrl/Cmd+S), automatic versions every 10 minutes and before an agent edits, compare a version with now, restore (the current state is kept as a version first), mark the final cut; backups carry every version, and an unreadable `project.json` is recovered at startup
|
|
164
|
+
- **Workflows** — save a routine you want repeated (a podcast clean-up, the weekly reel) as plain-language steps plus the tool calls that did them, in `library/workflows/`; an agent lists them and follows one on the next project, fitting each step to the new footage (`fablecut_workflows`)
|
|
164
165
|
- **Proxies** — light, frame-accurate H.264 copies of 4K / HEVC / ProRes footage made in the background (ffmpeg); edit on the proxy with the monitor's **Proxy** button, export always renders the originals
|
|
165
166
|
- **Import from URL** — **+ URL** downloads an HTTPS video/audio/image into
|
|
166
167
|
`./media/` (same-origin after import). Remote SVG is refused. Agents use
|
package/app.js
CHANGED
|
@@ -6922,8 +6922,12 @@ function renderInspector(lite) {
|
|
|
6922
6922
|
});
|
|
6923
6923
|
els.inspector.querySelectorAll("[data-k]").forEach((input) => {
|
|
6924
6924
|
const k = input.dataset.k;
|
|
6925
|
+
let armed = null; // the project as it was when a field / slider got focus; recorded on its first edit
|
|
6925
6926
|
input.addEventListener("input", (e) => {
|
|
6926
6927
|
if (!input.isConnected) return;
|
|
6928
|
+
// a dropdown pick is a whole edit: one undo step each; a field or slider takes one per focus that edits
|
|
6929
|
+
if (input.tagName === "SELECT") pushUndo();
|
|
6930
|
+
else if (armed) { pushUndo(armed); armed = null; }
|
|
6927
6931
|
if (input.type === "range" && (e.ctrlKey || e.metaKey)) return;
|
|
6928
6932
|
let v = input.type === "checkbox" ? input.checked
|
|
6929
6933
|
: input.type === "range" || input.type === "number" ? parseFloat(input.value)
|
|
@@ -6978,9 +6982,9 @@ function renderInspector(lite) {
|
|
|
6978
6982
|
if (ANIMATABLE.includes(k)) syncInspectorPlayhead();
|
|
6979
6983
|
});
|
|
6980
6984
|
input.addEventListener("focus", () => {
|
|
6981
|
-
|
|
6985
|
+
if (input.tagName !== "SELECT") armed = undoSnapshot();
|
|
6982
6986
|
if (ANIMATABLE.includes(k) && state.playing) pause();
|
|
6983
|
-
}
|
|
6987
|
+
});
|
|
6984
6988
|
});
|
|
6985
6989
|
els.inspector.querySelectorAll("[data-action]").forEach((btn) => {
|
|
6986
6990
|
btn.addEventListener("click", () => {
|
|
@@ -16740,6 +16744,12 @@ async function openExportSetup() {
|
|
|
16740
16744
|
if (!els.exportSetup.contains(document.activeElement)) $("exportRangeSel")?.focus();
|
|
16741
16745
|
}).finally(() => { exportSetupOpening = false; });
|
|
16742
16746
|
}
|
|
16747
|
+
/* The progress overlay takes focus: left on the Export button, Space would
|
|
16748
|
+
play the timeline under a running export (focus.js) instead of pressing Cancel. */
|
|
16749
|
+
function showExportOverlay() {
|
|
16750
|
+
els.exportOverlay.classList.remove("hidden");
|
|
16751
|
+
$("btnCancelExport")?.focus();
|
|
16752
|
+
}
|
|
16743
16753
|
function closeExportSetup() {
|
|
16744
16754
|
els.exportSetup.classList.add("hidden");
|
|
16745
16755
|
$("btnExport")?.focus();
|
|
@@ -16863,31 +16873,15 @@ function snapshotExportFrame() {
|
|
|
16863
16873
|
return { kind: "rgba", data: img.data, w: src.width, h: src.height };
|
|
16864
16874
|
} catch (e) { throw canvasTaintError(e); }
|
|
16865
16875
|
}
|
|
16866
|
-
let exportRgbaOff = null, exportRgbaCtx = null;
|
|
16867
|
-
/** Raw RGBA of the frame, for outputs that keep more than JPEG's 4:2:0 8-bit
|
|
16868
|
-
* (ProRes, DNxHR, FFV1, 10-bit, 4:2:2 / 4:4:4). */
|
|
16869
|
-
function snapshotExportRgba() {
|
|
16870
|
-
const src = exportSourceCanvas();
|
|
16871
|
-
try {
|
|
16872
|
-
if (!exportRgbaOff || exportRgbaOff.width !== src.width || exportRgbaOff.height !== src.height) {
|
|
16873
|
-
exportRgbaOff = typeof OffscreenCanvas === "function" ? new OffscreenCanvas(src.width, src.height)
|
|
16874
|
-
: Object.assign(document.createElement("canvas"), { width: src.width, height: src.height });
|
|
16875
|
-
exportRgbaCtx = exportRgbaOff.getContext("2d", { alpha: false, willReadFrequently: true });
|
|
16876
|
-
}
|
|
16877
|
-
exportRgbaCtx.drawImage(src, 0, 0);
|
|
16878
|
-
const img = exportRgbaCtx.getImageData(0, 0, src.width, src.height);
|
|
16879
|
-
return new Uint8Array(img.data.buffer, img.data.byteOffset, img.data.byteLength);
|
|
16880
|
-
} catch (e) { throw canvasTaintError(e); }
|
|
16881
|
-
}
|
|
16882
16876
|
const JPEG_WORKER_SRC = `"use strict";
|
|
16883
16877
|
self.onmessage = async (e) => {
|
|
16884
|
-
const { id, bmp, quality } = e.data;
|
|
16878
|
+
const { id, bmp, quality, type } = e.data;
|
|
16885
16879
|
try {
|
|
16886
16880
|
const c = new OffscreenCanvas(bmp.width, bmp.height);
|
|
16887
16881
|
const ctx = c.getContext("2d", { alpha: false });
|
|
16888
16882
|
ctx.drawImage(bmp, 0, 0);
|
|
16889
16883
|
bmp.close();
|
|
16890
|
-
const blob = await c.convertToBlob({ type: "image/jpeg", quality: quality || 0.92 });
|
|
16884
|
+
const blob = await c.convertToBlob(type === "image/png" ? { type } : { type: "image/jpeg", quality: quality || 0.92 });
|
|
16891
16885
|
const buf = await blob.arrayBuffer();
|
|
16892
16886
|
self.postMessage({ id, buf }, [buf]);
|
|
16893
16887
|
} catch (err) {
|
|
@@ -16923,12 +16917,12 @@ function createJpegWorkers(n) {
|
|
|
16923
16917
|
w.onerror = () => {};
|
|
16924
16918
|
}
|
|
16925
16919
|
return {
|
|
16926
|
-
encode(bmp, quality) {
|
|
16920
|
+
encode(bmp, quality, type) {
|
|
16927
16921
|
const id = nextId++;
|
|
16928
16922
|
const w = workers[rr++ % workers.length];
|
|
16929
16923
|
return new Promise((resolve, reject) => {
|
|
16930
16924
|
pending.set(id, { resolve, reject });
|
|
16931
|
-
try { w.postMessage({ id, bmp, quality }, [bmp]); }
|
|
16925
|
+
try { w.postMessage({ id, bmp, quality, type }, [bmp]); }
|
|
16932
16926
|
catch (e) { pending.delete(id); reject(e); }
|
|
16933
16927
|
});
|
|
16934
16928
|
},
|
|
@@ -16939,7 +16933,7 @@ function createJpegWorkers(n) {
|
|
|
16939
16933
|
},
|
|
16940
16934
|
};
|
|
16941
16935
|
}
|
|
16942
|
-
function jpegFromBitmap(bmp, quality) {
|
|
16936
|
+
function jpegFromBitmap(bmp, quality, type = "image/jpeg") {
|
|
16943
16937
|
const c = document.createElement("canvas");
|
|
16944
16938
|
c.width = bmp.width; c.height = bmp.height;
|
|
16945
16939
|
c.getContext("2d", { alpha: false }).drawImage(bmp, 0, 0);
|
|
@@ -16949,7 +16943,7 @@ function jpegFromBitmap(bmp, quality) {
|
|
|
16949
16943
|
c.toBlob((b) => {
|
|
16950
16944
|
if (!b) return rej(new Error("frame encode failed"));
|
|
16951
16945
|
b.arrayBuffer().then(res, rej);
|
|
16952
|
-
},
|
|
16946
|
+
}, type, quality);
|
|
16953
16947
|
} catch (e) { rej(canvasTaintError(e)); }
|
|
16954
16948
|
});
|
|
16955
16949
|
}
|
|
@@ -17019,6 +17013,29 @@ async function armExportCors() {
|
|
|
17019
17013
|
if (missing.length)
|
|
17020
17014
|
toast("No CORS on " + missing.join(", ") + " — blank in the export. Import into the project or add Access-Control-Allow-Origin.");
|
|
17021
17015
|
}
|
|
17016
|
+
/* One frame upload. XMLHttpRequest, not fetch: in Chromium each fetch body leaves
|
|
17017
|
+
about twice its size of native memory behind for the life of the tab, an
|
|
17018
|
+
XHR body about half that, and a long export runs the renderer out of memory
|
|
17019
|
+
(#165). */
|
|
17020
|
+
function postFrames(url, body, signal) {
|
|
17021
|
+
return new Promise((ok, bad) => {
|
|
17022
|
+
if (signal && signal.aborted) return bad(new Error("cancelled"));
|
|
17023
|
+
const xhr = new XMLHttpRequest();
|
|
17024
|
+
const onAbort = () => xhr.abort();
|
|
17025
|
+
const done = (fn) => { if (signal) signal.removeEventListener("abort", onAbort); fn(); };
|
|
17026
|
+
xhr.open("POST", url, true);
|
|
17027
|
+
xhr.onload = () => done(() => {
|
|
17028
|
+
if (xhr.status >= 200 && xhr.status < 300) return ok();
|
|
17029
|
+
let msg = "frame upload failed";
|
|
17030
|
+
try { msg = JSON.parse(xhr.responseText).error || msg; } catch { }
|
|
17031
|
+
bad(new Error(msg));
|
|
17032
|
+
});
|
|
17033
|
+
xhr.onerror = () => done(() => bad(new Error("frame upload failed")));
|
|
17034
|
+
xhr.onabort = () => done(() => bad(new Error("cancelled")));
|
|
17035
|
+
if (signal) signal.addEventListener("abort", onAbort, { once: true });
|
|
17036
|
+
xhr.send(body);
|
|
17037
|
+
});
|
|
17038
|
+
}
|
|
17022
17039
|
/* Sequential /frame POSTs, batched. Concurrent bodies can still race on ffmpeg
|
|
17023
17040
|
stdin if they complete out of order, so the client starts each fetch only
|
|
17024
17041
|
after the previous one settles; rendering runs ahead under backpressure.
|
|
@@ -17046,10 +17063,7 @@ function createExportUploader(sessId, { batchItems, batchBytes, signal, getError
|
|
|
17046
17063
|
if (cancelled()) throw new Error("cancelled");
|
|
17047
17064
|
const err = getError();
|
|
17048
17065
|
if (err) throw err;
|
|
17049
|
-
|
|
17050
|
-
method: "POST", body, signal,
|
|
17051
|
-
});
|
|
17052
|
-
if (!r.ok) throw new Error((await r.json().catch(() => ({}))).error || "frame upload failed");
|
|
17066
|
+
await postFrames("/api/export/frame?id=" + sessId, body, signal);
|
|
17053
17067
|
});
|
|
17054
17068
|
uploadTail = p.catch((err) => {
|
|
17055
17069
|
if (!getError()) setError(err);
|
|
@@ -17689,7 +17703,7 @@ async function fastExport(opts = {}) {
|
|
|
17689
17703
|
state.exporting = true; state.rendering = true; renderCancelled = false;
|
|
17690
17704
|
exportAbort = new AbortController();
|
|
17691
17705
|
const signal = exportAbort.signal;
|
|
17692
|
-
if (!opts.silent)
|
|
17706
|
+
if (!opts.silent) showExportOverlay();
|
|
17693
17707
|
els.exportProgress.style.width = "0%";
|
|
17694
17708
|
els.exportNote.textContent = "Rendering frames → ffmpeg. You can switch tabs; export continues.";
|
|
17695
17709
|
restoreExportVideoState();
|
|
@@ -17724,7 +17738,9 @@ async function fastExport(opts = {}) {
|
|
|
17724
17738
|
if (!begin.id) throw new Error(begin.error || "export begin failed");
|
|
17725
17739
|
sessId = begin.id;
|
|
17726
17740
|
const jpegQ = delivery ? begin.jpegQuality ?? 0.95 : exportProfileMeta(profileId).jpegQuality ?? 0.95;
|
|
17727
|
-
|
|
17741
|
+
// lossless PNG frames for outputs that keep more than JPEG's 4:2:0: the canvas is 8-bit RGB,
|
|
17742
|
+
// so PNG carries exactly its pixels, at about a tenth of raw RGBA's upload (#165)
|
|
17743
|
+
const frameType = begin.input === "png" ? "image/png" : "image/jpeg";
|
|
17728
17744
|
exportFullCanvas = !!delivery;
|
|
17729
17745
|
if (wav) {
|
|
17730
17746
|
const r = await fetch("/api/export/audio?id=" + sessId, { method: "POST", body: wav, signal });
|
|
@@ -17768,12 +17784,11 @@ async function fastExport(opts = {}) {
|
|
|
17768
17784
|
await seekVideosTo(t, { queueBusy });
|
|
17769
17785
|
await prepareFrameAssets(t);
|
|
17770
17786
|
drawFrame(t);
|
|
17771
|
-
const snap =
|
|
17787
|
+
const snap = snapshotExportFrame();
|
|
17772
17788
|
pixelsInflight++;
|
|
17773
17789
|
let jpegP;
|
|
17774
|
-
if (snap.kind === "
|
|
17775
|
-
|
|
17776
|
-
jpegP = workers ? workers.encode(snap.bmp, jpegQ) : jpegFromBitmap(snap.bmp, jpegQ);
|
|
17790
|
+
if (snap.kind === "bmp") {
|
|
17791
|
+
jpegP = workers ? workers.encode(snap.bmp, jpegQ, frameType) : jpegFromBitmap(snap.bmp, jpegQ, frameType);
|
|
17777
17792
|
} else {
|
|
17778
17793
|
const c = document.createElement("canvas");
|
|
17779
17794
|
c.width = snap.w; c.height = snap.h;
|
|
@@ -17783,7 +17798,7 @@ async function fastExport(opts = {}) {
|
|
|
17783
17798
|
c.toBlob((b) => {
|
|
17784
17799
|
if (!b) return rej(new Error("frame encode failed"));
|
|
17785
17800
|
b.arrayBuffer().then(res, rej);
|
|
17786
|
-
},
|
|
17801
|
+
}, frameType, jpegQ);
|
|
17787
17802
|
} catch (e) { rej(canvasTaintError(e)); }
|
|
17788
17803
|
});
|
|
17789
17804
|
}
|
|
@@ -18422,7 +18437,7 @@ async function webCodecsExport(name) {
|
|
|
18422
18437
|
state.exporting = true; state.rendering = true; renderCancelled = false;
|
|
18423
18438
|
exportAbort = new AbortController();
|
|
18424
18439
|
const signal = exportAbort.signal;
|
|
18425
|
-
|
|
18440
|
+
showExportOverlay();
|
|
18426
18441
|
els.exportProgress.style.width = "0%";
|
|
18427
18442
|
els.exportNote.textContent = "Encoding with WebCodecs → ffmpeg mux. You can switch tabs; export continues.";
|
|
18428
18443
|
restoreExportVideoState();
|
|
@@ -18608,7 +18623,7 @@ async function startExport(name) {
|
|
|
18608
18623
|
a.click();
|
|
18609
18624
|
setTimeout(() => URL.revokeObjectURL(a.href), 30_000);
|
|
18610
18625
|
};
|
|
18611
|
-
|
|
18626
|
+
showExportOverlay();
|
|
18612
18627
|
els.exportProgress.style.width = "0%";
|
|
18613
18628
|
state.exporting = true;
|
|
18614
18629
|
try { recorder.start(250); }
|
|
@@ -19623,8 +19638,26 @@ window.addEventListener("keydown", (e) => {
|
|
|
19623
19638
|
closeImportUrl();
|
|
19624
19639
|
return;
|
|
19625
19640
|
}
|
|
19641
|
+
// Space on a button / select / slider still focused from a mouse click plays
|
|
19642
|
+
// instead of pressing that control again (focus.js)
|
|
19643
|
+
if (k === " " && !e.ctrlKey && !e.metaKey && !e.altKey && typeof FableCutFocus !== "undefined") {
|
|
19644
|
+
const el = document.activeElement;
|
|
19645
|
+
if (FableCutFocus.spaceShouldPlay(el)) {
|
|
19646
|
+
e.preventDefault();
|
|
19647
|
+
FableCutFocus.release(el);
|
|
19648
|
+
if (!e.repeat) toggleTransportPlay();
|
|
19649
|
+
return;
|
|
19650
|
+
}
|
|
19651
|
+
// mid-drag, playing would move the slider's value under the pointer
|
|
19652
|
+
if (FableCutFocus.isDragging(el)) { e.preventDefault(); return; }
|
|
19653
|
+
// reached with Tab, or in a dialog / popover: Space presses the control as usual.
|
|
19654
|
+
// A slider has nothing for Space to press, so outside dialogs it still plays.
|
|
19655
|
+
const slider = el && el.tagName === "INPUT" && el.type === "range";
|
|
19656
|
+
if (FableCutFocus.isClickControl(el) && !(slider && !FableCutFocus.inKeyboardScope(el))) return;
|
|
19657
|
+
}
|
|
19626
19658
|
if (isTypingTarget(document.activeElement)) return;
|
|
19627
|
-
|
|
19659
|
+
// holding Space plays or pauses once, not on every key repeat
|
|
19660
|
+
if (k === " ") { e.preventDefault(); if (!e.repeat) toggleTransportPlay(); }
|
|
19628
19661
|
// JKL shuttle — bare keys only, so Cmd/Ctrl+J/K/L stay with the browser.
|
|
19629
19662
|
// K stops; hold K and tap J / L to step a frame, hold both to crawl.
|
|
19630
19663
|
else if ((k === "k" || k === "K") && !e.ctrlKey && !e.metaKey && !e.altKey) {
|
package/delivery.js
CHANGED
|
@@ -502,7 +502,7 @@
|
|
|
502
502
|
return parts.join(",");
|
|
503
503
|
}
|
|
504
504
|
|
|
505
|
-
/** One ffmpeg pass. o: {fps, input:"jpeg"|"rgba", canvasW, canvasH, frame
|
|
505
|
+
/** One ffmpeg pass. o: {fps, input:"jpeg"|"png"|"rgba", canvasW, canvasH, frame
|
|
506
506
|
* (from reframe), wavPath|null, outPath, duration (s, frames ÷ fps),
|
|
507
507
|
* loudnorm (pass-one measurement, when the spec has a loudness target), dry}. `dry` swaps stdin for a
|
|
508
508
|
* 0.1 s synthetic picture of the canvas size, to check the settings
|
|
@@ -510,8 +510,11 @@
|
|
|
510
510
|
function ffmpegArgs(spec, o) {
|
|
511
511
|
const rate = fpsRational(o.fps);
|
|
512
512
|
const args = ["-y", "-hide_banner"];
|
|
513
|
-
const rgba = o.input === "rgba";
|
|
514
|
-
|
|
513
|
+
const rgba = o.input === "rgba", png = o.input === "png";
|
|
514
|
+
// PNG and raw RGBA both arrive as full-range RGB
|
|
515
|
+
const rgb = rgba || png;
|
|
516
|
+
if (o.dry) args.push("-f", "lavfi", "-i", `color=c=black:s=${o.canvasW}x${o.canvasH}:r=${rate}:d=0.1,format=${rgb ? "rgba" : "yuvj420p"}`);
|
|
517
|
+
else if (png) args.push("-thread_queue_size", "64", "-f", "image2pipe", "-framerate", rate, "-c:v", "png", "-i", "-");
|
|
515
518
|
else if (rgba) args.push("-thread_queue_size", "8", "-f", "rawvideo", "-pix_fmt", "rgba", "-s", `${o.canvasW}x${o.canvasH}`, "-framerate", rate, "-i", "-");
|
|
516
519
|
else args.push("-thread_queue_size", "64", "-f", "image2pipe", "-framerate", rate, "-c:v", "mjpeg", "-i", "-");
|
|
517
520
|
const audio = spec.audio.codec !== "none" && (o.dry ? o.hasAudio !== false : !!o.wavPath);
|
|
@@ -521,7 +524,7 @@
|
|
|
521
524
|
}
|
|
522
525
|
args.push("-map", "0:v:0");
|
|
523
526
|
if (audio) args.push("-map", "1:a:0");
|
|
524
|
-
args.push("-vf", videoFilter(spec, o.frame,
|
|
527
|
+
args.push("-vf", videoFilter(spec, o.frame, rgb ? "bt709" : "bt601"));
|
|
525
528
|
args.push(...videoArgs(spec, +o.fps));
|
|
526
529
|
const c = COLORS[spec.color] || COLORS.bt709;
|
|
527
530
|
args.push("-colorspace", c.matrix, "-color_primaries", c.primaries, "-color_trc", c.trc, "-color_range", c.range);
|
|
@@ -646,11 +649,13 @@
|
|
|
646
649
|
return `${m}:${r < 10 ? "0" : ""}${r.toFixed(2)}`;
|
|
647
650
|
}
|
|
648
651
|
|
|
649
|
-
/** How the browser should hand frames over: JPEG is 4:2:0 8-bit, so
|
|
650
|
-
*
|
|
652
|
+
/** How the browser should hand frames over: JPEG is 4:2:0 8-bit, so anything
|
|
653
|
+
* that keeps more chroma or bit depth gets lossless PNG instead. The canvas is
|
|
654
|
+
* 8-bit RGB, so PNG carries exactly its pixels (as raw RGBA did) at about a
|
|
655
|
+
* tenth of the bytes, and every byte uploaded costs the tab memory (#165). */
|
|
651
656
|
function frameInput(spec) {
|
|
652
657
|
const v = spec.video;
|
|
653
|
-
return v.codec === "ffv1" || /422|444|10le/.test(v.pixFmt) ? "
|
|
658
|
+
return v.codec === "ffv1" || /422|444|10le/.test(v.pixFmt) ? "png" : "jpeg";
|
|
654
659
|
}
|
|
655
660
|
function jpegQuality(spec) {
|
|
656
661
|
const v = spec.video;
|
package/focus.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/* FableCut focus hygiene — keyboard shortcuts keep working after the mouse
|
|
2
|
+
uses a control.
|
|
3
|
+
|
|
4
|
+
A button, checkbox, slider or <select> keeps keyboard focus after it is
|
|
5
|
+
clicked. Space then pressed that control again (re-toggling Snap, say)
|
|
6
|
+
instead of playing the timeline, and ←/→ nudged the last slider instead of
|
|
7
|
+
stepping the playhead. Here:
|
|
8
|
+
|
|
9
|
+
- a control used with the mouse gives focus back to the page once the click
|
|
10
|
+
or drag is over (its own handler runs first; if that moves focus on, into
|
|
11
|
+
a popover's field say, it is left alone);
|
|
12
|
+
- Space on a control that still has focus from the mouse plays the timeline
|
|
13
|
+
(spaceShouldPlay, used by the editor's Space handler).
|
|
14
|
+
|
|
15
|
+
Inside a dialog or a popover nothing changes: Tab / Space / Enter work there
|
|
16
|
+
as usual. A control reached with Tab keeps its focus and Space presses it,
|
|
17
|
+
so the editor stays usable from the keyboard. Text fields are never touched.
|
|
18
|
+
|
|
19
|
+
Loaded by the editor as a plain script (global `FableCutFocus`, installed on
|
|
20
|
+
load) and required by the tests. */
|
|
21
|
+
(function (root, factory) {
|
|
22
|
+
const api = factory();
|
|
23
|
+
if (typeof module === "object" && module.exports) module.exports = api;
|
|
24
|
+
else {
|
|
25
|
+
root.FableCutFocus = api;
|
|
26
|
+
if (typeof document !== "undefined") api.install(root, document);
|
|
27
|
+
}
|
|
28
|
+
})(typeof self !== "undefined" ? self : this, function () {
|
|
29
|
+
"use strict";
|
|
30
|
+
|
|
31
|
+
/* Where keys belong to the UI under focus (dialogs, popovers, menus). */
|
|
32
|
+
const KEYBOARD_SCOPE = ".overlay, .ctx-menu, .style-menu, [role=dialog], [role=menu], [role=listbox]";
|
|
33
|
+
/* <input> types that are clicked or dragged, not typed into. */
|
|
34
|
+
const CLICK_INPUTS = ["range", "checkbox", "radio", "button", "submit", "reset", "color", "file"];
|
|
35
|
+
const CLICK_ROLES = ["button", "tab", "checkbox", "switch"];
|
|
36
|
+
|
|
37
|
+
/** A control that is clicked or dragged, not typed into. */
|
|
38
|
+
function isClickControl(el) {
|
|
39
|
+
if (!el || !el.tagName) return false;
|
|
40
|
+
const tag = el.tagName.toUpperCase();
|
|
41
|
+
if (tag === "BUTTON" || tag === "SUMMARY") return true;
|
|
42
|
+
// a dropdown is clicked; a list box (multiple, or size > 1) is worked from the keyboard (Space selects in it)
|
|
43
|
+
if (tag === "SELECT") return !el.multiple && !(el.size > 1);
|
|
44
|
+
if (tag === "INPUT") return CLICK_INPUTS.includes(String(el.type || "text").toLowerCase());
|
|
45
|
+
if (tag === "A") return !!(el.hasAttribute && el.hasAttribute("href"));
|
|
46
|
+
const role = el.getAttribute && el.getAttribute("role");
|
|
47
|
+
return CLICK_ROLES.includes(role);
|
|
48
|
+
}
|
|
49
|
+
/** Inside a dialog, popover or menu, where keys belong to that UI. */
|
|
50
|
+
function inKeyboardScope(el) {
|
|
51
|
+
return !!(el && el.closest && el.closest(KEYBOARD_SCOPE));
|
|
52
|
+
}
|
|
53
|
+
/* The element that last got focus from the keyboard (Tab) or from code, not a click.
|
|
54
|
+
:focus-visible can't tell: Chrome turns it on for a focused <select> as soon as a key is pressed. */
|
|
55
|
+
let keyFocused = null;
|
|
56
|
+
/* The slider a pointer is dragging right now (set by install). */
|
|
57
|
+
let dragHeld = null;
|
|
58
|
+
/** Record how `el` got focus: true = keyboard / code, false = pointer. */
|
|
59
|
+
function noteFocus(el, byKeyboard) { keyFocused = byKeyboard ? el : null; }
|
|
60
|
+
/** Space with focus on `el` should play the timeline, not press `el`. */
|
|
61
|
+
function spaceShouldPlay(el) {
|
|
62
|
+
// a slider still under the pointer keeps its focus: released mid-drag, playback would move its thumb under the pointer
|
|
63
|
+
return isClickControl(el) && !inKeyboardScope(el) && el !== keyFocused && el !== dragHeld;
|
|
64
|
+
}
|
|
65
|
+
/** Give focus back to the page when `el` is a click control outside a dialog. */
|
|
66
|
+
function release(el) {
|
|
67
|
+
if (!isClickControl(el) || inKeyboardScope(el)) return false;
|
|
68
|
+
el.blur();
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function install(win, doc) {
|
|
73
|
+
if (install.done) return;
|
|
74
|
+
install.done = true;
|
|
75
|
+
let byPointer = false;
|
|
76
|
+
// the slider a pointer is dragging and that pointer's id, until that same pointer
|
|
77
|
+
// lifts or cancels (a key pressed mid-drag, or a second finger, doesn't end it)
|
|
78
|
+
let dragging = null, dragPointer = null;
|
|
79
|
+
// bumped by each new drag, so a release left pending by the last one can't blur it
|
|
80
|
+
let dragGen = 0;
|
|
81
|
+
// The pointerdown a click comes from. byPointer only says what the last input was;
|
|
82
|
+
// a screen reader's virtual-cursor click fires `click` with no pointerdown, so a
|
|
83
|
+
// click counts as a mouse click only when a pointerdown on that same element came
|
|
84
|
+
// just before it.
|
|
85
|
+
let downOn = null, downAt = 0;
|
|
86
|
+
const CLICK_MS = 1500; // a press held longer than this isn't paired (the click is left to the keyboard path)
|
|
87
|
+
win.addEventListener("pointerdown", (e) => {
|
|
88
|
+
// only the primary button: a right-click opens a menu, it doesn't use the control
|
|
89
|
+
if (e.button > 0) return;
|
|
90
|
+
byPointer = true;
|
|
91
|
+
downOn = e.target; downAt = Date.now();
|
|
92
|
+
// clicking a control that already had keyboard focus (no new focusin): it is now a mouse focus
|
|
93
|
+
if (keyFocused && (e.target === keyFocused || (keyFocused.contains && keyFocused.contains(e.target)))) keyFocused = null;
|
|
94
|
+
const t = e.target;
|
|
95
|
+
if (dragging) return; // another pointer is already dragging a slider
|
|
96
|
+
if (t && t.tagName === "INPUT" && t.type === "range") { dragging = dragHeld = t; dragPointer = e.pointerId; dragGen++; }
|
|
97
|
+
}, { capture: true, passive: true });
|
|
98
|
+
// a press the browser cancelled (a touch that became a scroll) clicks nothing
|
|
99
|
+
win.addEventListener("pointercancel", () => { downOn = null; }, { capture: true, passive: true });
|
|
100
|
+
win.addEventListener("keydown", () => { byPointer = false; }, { capture: true, passive: true });
|
|
101
|
+
/** True when `t` is the element a recent mouse press landed on (or its label / control):
|
|
102
|
+
the focus or click on `t` comes from that press. Anything else (Tab, a screen reader's
|
|
103
|
+
virtual cursor, el.focus() / el.click() from code) is not from the mouse. */
|
|
104
|
+
const fromPress = (t) => byPointer && !!downOn && !!t && Date.now() - downAt < CLICK_MS &&
|
|
105
|
+
(downOn === t || (downOn.contains && downOn.contains(t)) || (t.contains && t.contains(downOn)) ||
|
|
106
|
+
(t.control && (t.control === downOn || (t.control.contains && t.control.contains(downOn)))) ||
|
|
107
|
+
(downOn.control && downOn.control === t) || pressedLabelOf(t));
|
|
108
|
+
// a press on the text inside a <label> focuses the label's control
|
|
109
|
+
const pressedLabelOf = (t) => {
|
|
110
|
+
const lab = downOn.closest && downOn.closest("label");
|
|
111
|
+
return !!lab && (lab.control === t || (lab.contains && lab.contains(t)));
|
|
112
|
+
};
|
|
113
|
+
doc.addEventListener("focusin", (e) => noteFocus(e.target, !fromPress(e.target)), true);
|
|
114
|
+
// Bubble phase: the control's own click handler has run by now.
|
|
115
|
+
win.addEventListener("click", (e) => {
|
|
116
|
+
const paired = fromPress(e.target);
|
|
117
|
+
// A click on a label is passed on to its control (focus, then a click of its own)
|
|
118
|
+
// after this listener has run: keep the press for that one.
|
|
119
|
+
const lab = paired && e.target && e.target.closest && e.target.closest("label");
|
|
120
|
+
const passesOn = !!(lab && lab.control && lab.control !== e.target && !(lab.control.contains && lab.control.contains(e.target)));
|
|
121
|
+
if (!passesOn) downOn = null;
|
|
122
|
+
if (!paired) return; // a click with no mouse press (screen reader, el.click() in code): focus stays
|
|
123
|
+
const el = doc.activeElement;
|
|
124
|
+
// a <select> stays focused while its list is open; a text field is typed into
|
|
125
|
+
if (!el || !isClickControl(el) || el.tagName === "SELECT") return;
|
|
126
|
+
const t = e.target;
|
|
127
|
+
const label = t && t.closest && t.closest("label");
|
|
128
|
+
if (el === t || el.contains(t) || (label && (label.contains(el) || label.control === el))) release(el);
|
|
129
|
+
});
|
|
130
|
+
// A slider lets go when the drag ends; a select once a value is picked.
|
|
131
|
+
// that pointer lifting, or the browser cancelling it (a touch turned into a scroll), ends the drag
|
|
132
|
+
const endDrag = (e) => {
|
|
133
|
+
if (!dragging || e.pointerId !== dragPointer) return;
|
|
134
|
+
const el = dragging;
|
|
135
|
+
dragging = dragHeld = null; dragPointer = null;
|
|
136
|
+
const gen = dragGen;
|
|
137
|
+
setTimeout(() => { if (gen === dragGen && doc.activeElement === el) release(el); }, 0);
|
|
138
|
+
};
|
|
139
|
+
win.addEventListener("pointerup", endDrag, true);
|
|
140
|
+
win.addEventListener("pointercancel", endDrag, true);
|
|
141
|
+
win.addEventListener("change", (e) => {
|
|
142
|
+
const el = e.target;
|
|
143
|
+
// picked from a select the mouse focused (a key held meanwhile, Shift say, doesn't change that)
|
|
144
|
+
if (el === doc.activeElement && el.tagName === "SELECT" && el !== keyFocused) release(el);
|
|
145
|
+
});
|
|
146
|
+
// A native select picker closed without a change (Esc, a click outside, the
|
|
147
|
+
// same option) leaves the select focused, and ←/→ would change its value
|
|
148
|
+
// instead of moving the playhead. An arrow key on a select still focused from
|
|
149
|
+
// the mouse lets it go first, so the editor's arrow shortcuts run (Space is
|
|
150
|
+
// handled by the editor's Space check). The picker is closed by then: while
|
|
151
|
+
// it is open the browser keeps the keys, so nothing here closes it early.
|
|
152
|
+
win.addEventListener("keydown", (e) => {
|
|
153
|
+
const el = doc.activeElement;
|
|
154
|
+
if (!el || el.tagName !== "SELECT" || el === keyFocused || inKeyboardScope(el)) return;
|
|
155
|
+
// the editor's themed list (select-menu.js) is open on it: the arrows move through the list
|
|
156
|
+
if (el.classList && el.classList.contains("fc-open")) return;
|
|
157
|
+
if (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "ArrowUp" || e.key === "ArrowDown") release(el);
|
|
158
|
+
}, true);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** True while a pointer is dragging slider `el`: Space neither plays nor presses it then. */
|
|
162
|
+
function isDragging(el) { return el != null && el === dragHeld; }
|
|
163
|
+
|
|
164
|
+
return { isClickControl, inKeyboardScope, spaceShouldPlay, isDragging, noteFocus, release, install, KEYBOARD_SCOPE };
|
|
165
|
+
});
|
package/index.html
CHANGED
|
@@ -724,6 +724,8 @@
|
|
|
724
724
|
<script src="command-search.js"></script>
|
|
725
725
|
<script src="delivery.js"></script>
|
|
726
726
|
<script src="mp4-demux.js"></script>
|
|
727
|
+
<script src="focus.js"></script>
|
|
728
|
+
<script src="select-menu.js"></script>
|
|
727
729
|
<script src="app.js"></script>
|
|
728
730
|
</body>
|
|
729
731
|
</html>
|