@tmhs/screencast-mcp 0.54.0 → 0.55.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/README.md +2 -2
- package/assets/ui/player.html +24 -1
- package/assets/ui/player.js +150 -9
- package/dist/index.js +156 -125
- package/dist/wgcRecorder.js +9 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -154,7 +154,7 @@ Cut, convert, compress, and redact. A tool that writes a file refuses to replace
|
|
|
154
154
|
| [`cut_idle`](https://tmhsdigital.github.io/screencast-mcp/tools/cut_idle.html) | Remove dead air: cut stretches where the screen is frozen (and silent), keeping a short pad. Returns the time saved. |
|
|
155
155
|
| [`cut_by_transcript`](https://tmhsdigital.github.io/screencast-mcp/tools/cut_by_transcript.html) | Edit a video by its transcript: cut quoted text, cue numbers, or fillers. Also writes the re-timed .srt. |
|
|
156
156
|
| [`redact_region`](https://tmhsdigital.github.io/screencast-mcp/tools/redact_region.html) | Cover given rectangles in a video or screenshot (e.g. secrets on screen). Not automatic detection: find them with find_text redact: true. Off-frame regions are rejected. |
|
|
157
|
-
| [`pipeline`](https://tmhsdigital.github.io/screencast-mcp/tools/pipeline.html) | Run several edits (trim, crop, scale, speed, cut_idle, redact, callout, keystroke_overlay, cursor, reframe, zoom, backdrop, audio, burn_subtitles, music, then optionally export_preset or export_gif) in one ffmpeg pass: one re-encode, no intermediate files. Prefer it over chaining edit tools; a recipe does the usual polish in one call. |
|
|
157
|
+
| [`pipeline`](https://tmhsdigital.github.io/screencast-mcp/tools/pipeline.html) | Run several edits (trim, crop, scale, speed, cut_idle, redact, callout, keystroke_overlay, cursor, reframe, zoom, backdrop, audio, burn_subtitles, title_card, music, then optionally export_preset or export_gif) in one ffmpeg pass: one re-encode, no intermediate files. Prefer it over chaining edit tools; a recipe does the usual polish in one call. |
|
|
158
158
|
|
|
159
159
|
</details>
|
|
160
160
|
|
|
@@ -208,7 +208,7 @@ Extract, clean up, level, transcribe, and score the soundtrack.
|
|
|
208
208
|
> [!IMPORTANT]
|
|
209
209
|
> `redact_region` covers only the rectangles **you** declare; it is not automatic secret detection (use `find_text` with `redact: true` to locate them). Prefer the default `box` style for real secrets: it is a solid, irreversible fill, while `blur` and `pixelate` can be partially recovered.
|
|
210
210
|
|
|
211
|
-
Every capture tool takes one `target` string: `full`, `monitor:<index>`, `window:<title>`, `window:exe=<app.exe>`, `window:hwnd=<handle>`, or `region:<x>,<y>,<w>,<h>`; `list_targets` returns ready-made ones. See [`start_recording`](https://tmhsdigital.github.io/screencast-mcp/tools/start_recording.html) and the [Windows notes](https://tmhsdigital.github.io/screencast-mcp/#windows-notes) for how windows, monitors, and `backend: "wgc"` are captured.
|
|
211
|
+
Every capture tool takes one `target` string: `full`, `monitor:<index>`, `window:<title>`, `window:exe=<app.exe>`, `window:hwnd=<handle>`, or `region:<x>,<y>,<w>,<h>`; `list_targets` returns ready-made ones. See [`start_recording`](https://tmhsdigital.github.io/screencast-mcp/tools/start_recording.html) and the [Windows notes](https://tmhsdigital.github.io/screencast-mcp/#windows-notes) for how windows, monitors, and `backend: "wgc"` are captured. With no `backend`, a window target records through WGC, so other windows can cover it. Without WGC, the window is kept on top until the capture ends (`alwaysOnTop` overrides this). A minimized target is restored without taking focus.
|
|
212
212
|
|
|
213
213
|
## Configuration
|
|
214
214
|
|
package/assets/ui/player.html
CHANGED
|
@@ -93,11 +93,15 @@
|
|
|
93
93
|
width: 5.2rem; padding: .3rem .45rem; font: 12px var(--mono); color: var(--ink);
|
|
94
94
|
background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
|
|
95
95
|
}
|
|
96
|
+
#boxFields .win { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
|
|
96
97
|
#boxFields:disabled { opacity: .45; }
|
|
97
98
|
#sampling { margin-left: auto; }
|
|
98
99
|
#status { font: 12px var(--mono); color: var(--dim); overflow-wrap: anywhere; }
|
|
99
100
|
#status.ok { color: var(--ok); }
|
|
100
101
|
#status.err { color: var(--rec); }
|
|
102
|
+
#shortcuts { position: fixed; right: 12px; bottom: 12px; z-index: 10; padding: 10px 14px; border: 1px solid var(--rec); border-radius: 8px; background: Canvas; color: CanvasText; font: 13px/1.5 sans-serif; }
|
|
103
|
+
#shortcuts ul { margin: 0 0 8px; padding-left: 18px; }
|
|
104
|
+
#shortcuts kbd { font: 11px var(--mono); border: 1px solid currentColor; border-radius: 3px; padding: 0 3px; }
|
|
101
105
|
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }
|
|
102
106
|
</style>
|
|
103
107
|
</head>
|
|
@@ -115,7 +119,7 @@
|
|
|
115
119
|
<div class="controls">
|
|
116
120
|
<button class="btn" id="play" type="button" disabled>Play</button>
|
|
117
121
|
<button class="btn" id="draw" type="button" aria-pressed="false" disabled>Draw redaction box</button>
|
|
118
|
-
<span id="hint">Drag the amber handles to trim (or focus one and use the arrow keys). Draw or type boxes over anything secret.</span>
|
|
122
|
+
<span id="hint">Drag the amber handles to trim (or focus one and use the arrow keys). Draw or type boxes over anything secret. Press ? for keyboard shortcuts.</span>
|
|
119
123
|
</div>
|
|
120
124
|
<div class="timeline" id="timeline" role="group" aria-label="Timeline">
|
|
121
125
|
<div id="strip"></div>
|
|
@@ -141,6 +145,14 @@
|
|
|
141
145
|
<label>Y <input id="by" type="number" min="0" step="1" inputmode="numeric"></label>
|
|
142
146
|
<label>W <input id="bw" type="number" min="4" step="1" inputmode="numeric"></label>
|
|
143
147
|
<label>H <input id="bh" type="number" min="4" step="1" inputmode="numeric"></label>
|
|
148
|
+
<!-- #377: an optional window, in seconds of the original video; both blank = the whole video.
|
|
149
|
+
It applies to the next box added, drawn or typed. -->
|
|
150
|
+
<span class="win">
|
|
151
|
+
<label>FROM s <input id="bs" type="number" min="0" step="0.1" inputmode="decimal" placeholder="start"></label>
|
|
152
|
+
<button class="btn" type="button" id="bsNow" aria-label="Set window start to the playhead">Playhead</button>
|
|
153
|
+
<label>TO s <input id="be" type="number" min="0" step="0.1" inputmode="decimal" placeholder="end"></label>
|
|
154
|
+
<button class="btn" type="button" id="beNow" aria-label="Set window end to the playhead">Playhead</button>
|
|
155
|
+
</span>
|
|
144
156
|
<button class="btn" type="submit">Add box</button>
|
|
145
157
|
</fieldset>
|
|
146
158
|
</form>
|
|
@@ -149,6 +161,17 @@
|
|
|
149
161
|
<button class="btn" id="openResult" type="button" hidden>Review the result</button>
|
|
150
162
|
<span id="status" role="status"></span>
|
|
151
163
|
</div>
|
|
164
|
+
<div id="shortcuts" role="dialog" aria-modal="false" aria-label="Keyboard shortcuts" hidden>
|
|
165
|
+
<ul>
|
|
166
|
+
<li><kbd>Space</kbd> or <kbd>K</kbd>: play / pause</li>
|
|
167
|
+
<li><kbd>J</kbd> / <kbd>L</kbd> or <kbd>,</kbd> / <kbd>.</kbd>: step one frame back / forward</li>
|
|
168
|
+
<li><kbd>I</kbd> / <kbd>O</kbd>: set IN / OUT at the playhead</li>
|
|
169
|
+
<li><kbd>D</kbd>: toggle draw mode</li>
|
|
170
|
+
<li><kbd>Delete</kbd>: remove the focused box</li>
|
|
171
|
+
<li><kbd>Esc</kbd>: cancel a draft box or close this list</li>
|
|
172
|
+
</ul>
|
|
173
|
+
<button class="btn" id="shortcutsClose" type="button">Close</button>
|
|
174
|
+
</div>
|
|
152
175
|
</main>
|
|
153
176
|
<script src="player.js"></script>
|
|
154
177
|
</body>
|
package/assets/ui/player.js
CHANGED
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
stop();
|
|
87
87
|
S.input = input;
|
|
88
88
|
S.boxes = [];
|
|
89
|
+
$("bs").value = $("be").value = "";
|
|
89
90
|
$("file").textContent = input.split(/[\\/]/).pop();
|
|
90
91
|
$("file").title = input;
|
|
91
92
|
setEmpty("Loading frames...");
|
|
@@ -158,6 +159,7 @@
|
|
|
158
159
|
$("tc").textContent = `${fmt(t)} / ${fmt(S.duration)}`;
|
|
159
160
|
$("head").style.left = `${pct(t)}%`;
|
|
160
161
|
setSlider($("seek"), t, `${fmt(t)} of ${fmt(S.duration)}`);
|
|
162
|
+
placeBoxes(); // the stage shows only the boxes active at this frame (#377)
|
|
161
163
|
}
|
|
162
164
|
|
|
163
165
|
function setSlider(el, t, text) {
|
|
@@ -289,7 +291,10 @@
|
|
|
289
291
|
if (!start) return;
|
|
290
292
|
const r = rectOf(start, toVideo(e.clientX, e.clientY));
|
|
291
293
|
dropDraft();
|
|
292
|
-
if (r.width >= 4 && r.height >= 4)
|
|
294
|
+
if (r.width >= 4 && r.height >= 4) {
|
|
295
|
+
const win = readWindow();
|
|
296
|
+
if (win) S.boxes.push({ ...r, ...win });
|
|
297
|
+
}
|
|
293
298
|
render();
|
|
294
299
|
});
|
|
295
300
|
// A cancelled drag adds nothing and leaves no dashed box behind (#243).
|
|
@@ -313,11 +318,34 @@
|
|
|
313
318
|
}
|
|
314
319
|
const r = { x, y, width: Math.min(w, S.W - x), height: Math.min(h, S.H - y) };
|
|
315
320
|
if (r.width < 4 || r.height < 4) return status("A box needs to be at least 4 px wide and tall inside the video.", "err");
|
|
316
|
-
|
|
321
|
+
const win = readWindow();
|
|
322
|
+
if (!win) return;
|
|
323
|
+
S.boxes.push({ ...r, ...win });
|
|
317
324
|
render();
|
|
318
|
-
status(`Added box ${S.boxes.length}: ${r.width}\u00d7${r.height} at ${r.x},${r.y}.`);
|
|
325
|
+
status(`Added box ${S.boxes.length}: ${r.width}\u00d7${r.height} at ${r.x},${r.y}${windowText(S.boxes.at(-1)) ? `, visible ${windowText(S.boxes.at(-1))}` : ""}.`);
|
|
319
326
|
});
|
|
320
327
|
|
|
328
|
+
// The optional time window (#377). Blank fields mean the video's start / end,
|
|
329
|
+
// and both blank means the whole video, which sends no start/end at all.
|
|
330
|
+
/** {start?, end?} in seconds from the FROM / TO fields, or null (after a status message) when invalid. */
|
|
331
|
+
function readWindow() {
|
|
332
|
+
const [start, end] = ["bs", "be"].map((id) => ($(id).value.trim() === "" ? undefined : Math.round(Number($(id).value) * 1000) / 1000));
|
|
333
|
+
if ([start, end].some((v) => v !== undefined && !(v >= 0 && v <= S.duration))) {
|
|
334
|
+
status(`A window time needs to be within 0-${S.duration.toFixed(1)}s.`, "err");
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
if (end !== undefined && end <= (start ?? 0)) {
|
|
338
|
+
status("A window needs to end after it starts.", "err");
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
341
|
+
return { ...(start !== undefined && { start }), ...(end !== undefined && { end }) };
|
|
342
|
+
}
|
|
343
|
+
for (const [btn, field] of [["bsNow", "bs"], ["beNow", "be"]]) {
|
|
344
|
+
$(btn).addEventListener("click", () => {
|
|
345
|
+
$(field).value = String(Math.round((S.times[S.i] || 0) * 1000) / 1000);
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
|
|
321
349
|
function placeBox(el, r) {
|
|
322
350
|
const ir = img.getBoundingClientRect(), sr = stage.getBoundingClientRect();
|
|
323
351
|
const k = ir.width / S.W;
|
|
@@ -326,11 +354,17 @@
|
|
|
326
354
|
el.style.width = `${r.width * k}px`;
|
|
327
355
|
el.style.height = `${r.height * k}px`;
|
|
328
356
|
}
|
|
329
|
-
|
|
357
|
+
/** Whether box r covers time t. A missing start/end is the video's edge;
|
|
358
|
+
* both ends are inclusive, as in the ffmpeg between() the export uses. */
|
|
359
|
+
const activeAt = (r, t) => (r.start === undefined || t >= r.start) && (r.end === undefined || t <= r.end);
|
|
360
|
+
/** "01:10.0-01:13.5" for a limited box, "" for one that covers the whole video. */
|
|
361
|
+
const windowText = (r) => (r.start === undefined && r.end === undefined ? "" : `${fmt(r.start ?? 0)}\u2013${r.end === undefined ? "end" : fmt(r.end)}`);
|
|
362
|
+
/** Draws the boxes active at the current frame on the stage (#377). */
|
|
363
|
+
function placeBoxes() {
|
|
330
364
|
stage.querySelectorAll(".box:not(.draft)").forEach((b) => b.remove());
|
|
331
|
-
const
|
|
332
|
-
list.replaceChildren();
|
|
365
|
+
const t = S.times[S.i] || 0;
|
|
333
366
|
S.boxes.forEach((r, n) => {
|
|
367
|
+
if (!activeAt(r, t)) return;
|
|
334
368
|
const el = document.createElement("div");
|
|
335
369
|
el.className = "box";
|
|
336
370
|
const tag = document.createElement("span");
|
|
@@ -338,8 +372,16 @@
|
|
|
338
372
|
el.appendChild(tag);
|
|
339
373
|
stage.appendChild(el);
|
|
340
374
|
placeBox(el, r);
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
function renderBoxes() {
|
|
378
|
+
placeBoxes();
|
|
379
|
+
const list = $("boxList");
|
|
380
|
+
list.replaceChildren();
|
|
381
|
+
S.boxes.forEach((r, n) => {
|
|
341
382
|
const li = document.createElement("li");
|
|
342
383
|
li.textContent = `#${n + 1} ${r.width}\u00d7${r.height} at ${r.x},${r.y}`;
|
|
384
|
+
if (windowText(r)) li.textContent += ` ${windowText(r)}`;
|
|
343
385
|
const rm = document.createElement("button");
|
|
344
386
|
rm.type = "button";
|
|
345
387
|
rm.textContent = "\u2715";
|
|
@@ -356,14 +398,113 @@
|
|
|
356
398
|
list.appendChild(li);
|
|
357
399
|
});
|
|
358
400
|
}
|
|
359
|
-
img.addEventListener("load",
|
|
360
|
-
new ResizeObserver(
|
|
401
|
+
img.addEventListener("load", placeBoxes);
|
|
402
|
+
new ResizeObserver(placeBoxes).observe(stage);
|
|
403
|
+
|
|
404
|
+
// --- player-wide shortcuts (#380) ---------------------------------------
|
|
405
|
+
/** The player action a key triggers. A pure map, null for other keys; the
|
|
406
|
+
* slider keys (arrows, Page Up/Down, Home/End) stay on the sliders, whose
|
|
407
|
+
* focus keeps its own meaning. */
|
|
408
|
+
function shortcutForKey(key) {
|
|
409
|
+
switch (key) {
|
|
410
|
+
case " ": case "k": case "K": return "play-pause";
|
|
411
|
+
case "j": case "J": case ",": return "step-back";
|
|
412
|
+
case "l": case "L": case ".": return "step-forward";
|
|
413
|
+
case "i": case "I": return "set-in";
|
|
414
|
+
case "o": case "O": return "set-out";
|
|
415
|
+
case "d": case "D": return "toggle-draw";
|
|
416
|
+
case "Delete": case "Backspace": return "delete-box";
|
|
417
|
+
case "Escape": return "cancel";
|
|
418
|
+
case "?": return "help";
|
|
419
|
+
default: return null;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
/** Typing in a field keeps its keys; shortcuts fire anywhere else. */
|
|
423
|
+
const isEditableTarget = (t) => t instanceof Element && t.closest("input, textarea, select, [contenteditable]") !== null;
|
|
424
|
+
|
|
425
|
+
let helpReturnFocus = null;
|
|
426
|
+
const shortcutsPanel = () => $("shortcuts");
|
|
427
|
+
function openHelp() {
|
|
428
|
+
helpReturnFocus = document.activeElement;
|
|
429
|
+
shortcutsPanel().hidden = false;
|
|
430
|
+
$("shortcutsClose").focus();
|
|
431
|
+
}
|
|
432
|
+
function closeHelp() {
|
|
433
|
+
shortcutsPanel().hidden = true;
|
|
434
|
+
(helpReturnFocus || $("play")).focus();
|
|
435
|
+
helpReturnFocus = null;
|
|
436
|
+
}
|
|
437
|
+
$("shortcutsClose").addEventListener("click", closeHelp);
|
|
438
|
+
|
|
439
|
+
document.addEventListener("keydown", (e) => {
|
|
440
|
+
// Ctrl/Cmd/Alt combinations stay with the browser (Ctrl+L, Ctrl+D, ...).
|
|
441
|
+
if (e.defaultPrevented || e.ctrlKey || e.metaKey || e.altKey || isEditableTarget(e.target)) return;
|
|
442
|
+
// Space on a focused button presses that button, as it does everywhere.
|
|
443
|
+
if (e.key === " " && e.target instanceof Element && e.target.closest("button")) return;
|
|
444
|
+
const action = shortcutForKey(e.key);
|
|
445
|
+
if (!action) return;
|
|
446
|
+
// While the shortcut list is open it keeps the keys; Esc closes it.
|
|
447
|
+
if (!shortcutsPanel().hidden) {
|
|
448
|
+
if (action === "cancel" || action === "help") {
|
|
449
|
+
e.preventDefault();
|
|
450
|
+
closeHelp();
|
|
451
|
+
}
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
switch (action) {
|
|
455
|
+
case "help":
|
|
456
|
+
e.preventDefault();
|
|
457
|
+
openHelp();
|
|
458
|
+
return;
|
|
459
|
+
case "play-pause":
|
|
460
|
+
e.preventDefault();
|
|
461
|
+
$("play").click();
|
|
462
|
+
return;
|
|
463
|
+
case "step-back":
|
|
464
|
+
case "step-forward":
|
|
465
|
+
if (!S.frames.length) return;
|
|
466
|
+
e.preventDefault();
|
|
467
|
+
show(S.i + (action === "step-back" ? -1 : 1));
|
|
468
|
+
return;
|
|
469
|
+
case "set-in":
|
|
470
|
+
if (!S.frames.length) return;
|
|
471
|
+
e.preventDefault();
|
|
472
|
+
S.inI = Math.min(S.i, S.outI);
|
|
473
|
+
render();
|
|
474
|
+
return;
|
|
475
|
+
case "set-out":
|
|
476
|
+
if (!S.frames.length) return;
|
|
477
|
+
e.preventDefault();
|
|
478
|
+
S.outI = Math.max(S.i, S.inI);
|
|
479
|
+
render();
|
|
480
|
+
return;
|
|
481
|
+
case "toggle-draw":
|
|
482
|
+
e.preventDefault();
|
|
483
|
+
$("draw").click();
|
|
484
|
+
return;
|
|
485
|
+
case "delete-box": {
|
|
486
|
+
const focused = document.activeElement;
|
|
487
|
+
if (focused instanceof HTMLButtonElement && focused.closest("#boxList")) {
|
|
488
|
+
e.preventDefault();
|
|
489
|
+
focused.click();
|
|
490
|
+
}
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
case "cancel":
|
|
494
|
+
if (draft) {
|
|
495
|
+
e.preventDefault();
|
|
496
|
+
dropDraft();
|
|
497
|
+
}
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
});
|
|
361
501
|
|
|
362
502
|
// --- export: one pipeline call -----------------------------------------
|
|
363
503
|
$("apply").addEventListener("click", async () => {
|
|
364
504
|
stop();
|
|
365
505
|
const steps = [];
|
|
366
|
-
// Redact first, so a box covers every frame of the kept range.
|
|
506
|
+
// Redact first, so a box covers every frame of the kept range. That also
|
|
507
|
+
// keeps a box's start/end in the original video's time, not the trimmed copy's.
|
|
367
508
|
if (S.boxes.length) steps.push({ op: "redact", regions: S.boxes.map((b) => ({ ...b })) });
|
|
368
509
|
const tin = Math.round((S.times[S.inI] || 0) * 1000) / 1000, tout = Math.round(end(S.outI) * 1000) / 1000;
|
|
369
510
|
if (trimmed()) steps.push({ op: "trim", start: tin, end: Math.min(tout, S.duration) });
|