@tmhs/screencast-mcp 0.48.2 → 0.49.1
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 +8 -7
- package/dist/resources.js +26 -0
- package/dist/server.js +2 -0
- package/dist/tools/backdrop.js +1 -11
- package/dist/tools/bugReport.js +5 -28
- package/dist/tools/burnSubtitles.js +2 -2
- package/dist/tools/callout.js +7 -49
- package/dist/tools/contactSheet.js +3 -24
- package/dist/tools/cursor.js +2 -22
- package/dist/tools/deleteRecording.js +119 -0
- package/dist/tools/denoise.js +2 -2
- package/dist/tools/findText.js +1 -3
- package/dist/tools/indexRecording.js +6 -6
- package/dist/tools/keystrokeOverlay.js +3 -44
- package/dist/tools/normalizeAudio.js +3 -4
- package/dist/tools/pipeline.js +16 -19
- package/dist/tools/redactRegion.js +7 -16
- package/dist/tools/reframe.js +3 -3
- package/dist/tools/sampleFrames.js +6 -2
- package/dist/tools/stepGuide.js +13 -10
- package/dist/tools/titleCard.js +1 -1
- package/dist/tools/waitForChange.js +28 -46
- package/dist/tools/zoom.js +3 -18
- package/dist/utils/audio.js +4 -0
- package/dist/utils/backdrop.js +12 -1
- package/dist/utils/bugReport.js +23 -0
- package/dist/utils/callout.js +48 -2
- package/dist/utils/captions.js +1 -0
- package/dist/utils/cursor.js +22 -1
- package/dist/utils/diff.js +6 -4
- package/dist/utils/frameQueue.js +50 -0
- package/dist/utils/images.js +4 -4
- package/dist/utils/keystrokes.js +44 -1
- package/dist/utils/media.js +27 -3
- package/dist/utils/ocrScan.js +35 -19
- package/dist/utils/paths.js +3 -0
- package/dist/utils/pool.js +29 -0
- package/dist/utils/produce.js +2 -0
- package/dist/utils/recordingFiles.js +32 -0
- package/dist/utils/replay.js +16 -23
- package/dist/utils/sessions.js +25 -0
- package/dist/utils/sheet.js +25 -2
- package/dist/utils/toolSpec.js +6 -0
- package/dist/utils/toolsets.js +1 -0
- package/dist/utils/waitLoop.js +50 -0
- package/dist/utils/zoom.js +18 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
**An MCP server that lets an agent record the screen, _watch_ the footage, and make minimal ffmpeg edits — over stdio, on Windows.**
|
|
6
6
|
|
|
7
|
-
Capture the desktop, a monitor, a window, or a region; sample a recording into frames the agent can actually look at; trim, crop, redact, annotate, zoom toward clicks, and export for GitHub or social. No cloud service, no telemetry: ffmpeg and ffprobe behind <!--tool-count-->
|
|
7
|
+
Capture the desktop, a monitor, a window, or a region; sample a recording into frames the agent can actually look at; trim, crop, redact, annotate, zoom toward clicks, and export for GitHub or social. No cloud service, no telemetry: ffmpeg and ffprobe behind <!--tool-count-->59<!--/tool-count--> typed tools.
|
|
8
8
|
|
|
9
9
|
**For developers who want their coding agent to see and prove UI changes on Windows**: bug repros, UI verification, and demo clips the agent records, checks, and edits itself. Capture is Windows-only; the watch and edit tools work on any OS with ffmpeg. Free for non-commercial use ([CC BY-NC-ND 4.0](#license)); [why not OBS, Playwright, or a screenshot MCP?](#why-not-just)
|
|
10
10
|
|
|
@@ -75,7 +75,7 @@ The core is the **watch loop**: the agent records, samples the footage into fram
|
|
|
75
75
|
## Tools
|
|
76
76
|
|
|
77
77
|
<!-- tools:start -->
|
|
78
|
-
|
|
78
|
+
59 tools in 6 toolsets, generated from the server's own schemas by `npm run docs` (do not edit between the markers). Each name links to its reference page with every parameter, an example call, and what it returns; [`mcp-tools.json`](mcp-tools.json) is the same list as JSON, and [`llms-full.txt`](https://tmhsdigital.github.io/screencast-mcp/llms-full.txt) all of it in one file.
|
|
79
79
|
|
|
80
80
|
### Core
|
|
81
81
|
|
|
@@ -94,6 +94,7 @@ Record or screenshot the desktop, a monitor, a window, or a region. Every captur
|
|
|
94
94
|
| --- | --- |
|
|
95
95
|
| [`start_recording`](https://tmhsdigital.github.io/screencast-mcp/tools/start_recording.html) | Start a background screen recording. Returns a session id; finalize it with stop_recording. Never auto-starts. |
|
|
96
96
|
| [`stop_recording`](https://tmhsdigital.github.io/screencast-mcp/tools/stop_recording.html) | Stop a recording gracefully so the file is finalized; returns the path and duration. |
|
|
97
|
+
| [`delete_recording`](https://tmhsdigital.github.io/screencast-mcp/tools/delete_recording.html) | Delete a finished recording with its sidecars (event log, webcam, transcript, index, markers, pause parts) and registry entries; reports bytes freed. Asks the user first when the client supports it. Edits made from it are kept. |
|
|
97
98
|
| [`pause_recording`](https://tmhsdigital.github.io/screencast-mcp/tools/pause_recording.html) | Pause a recording; until resume_recording nothing is captured, and the gap is left out of the file, events, and markers. |
|
|
98
99
|
| [`resume_recording`](https://tmhsdigital.github.io/screencast-mcp/tools/resume_recording.html) | Resume a paused recording (same target and settings). |
|
|
99
100
|
| [`save_replay`](https://tmhsdigital.github.io/screencast-mcp/tools/save_replay.html) | Save the last N seconds of a replay buffer (start_recording replayBufferSec) to an mp4; the buffer keeps running. |
|
|
@@ -139,7 +140,7 @@ Cut, convert, compress, and redact. A tool that writes a file refuses to replace
|
|
|
139
140
|
| [`clip`](https://tmhsdigital.github.io/screencast-mcp/tools/clip.html) | Extract several frame-exact segments, each to its own file. For one segment, trim does the same. |
|
|
140
141
|
| [`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. |
|
|
141
142
|
| [`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. |
|
|
142
|
-
| [`redact_region`](https://tmhsdigital.github.io/screencast-mcp/tools/redact_region.html) | Cover given rectangles in a video (e.g. secrets on screen). Not automatic detection: find them with find_text redact: true. Off-frame regions are rejected. |
|
|
143
|
+
| [`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. |
|
|
143
144
|
| [`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, 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. |
|
|
144
145
|
|
|
145
146
|
### Produce
|
|
@@ -149,7 +150,7 @@ Annotate, frame, and assemble a finished piece. Tools that combine clips normali
|
|
|
149
150
|
| Tool | What it does |
|
|
150
151
|
| --- | --- |
|
|
151
152
|
| [`overlay`](https://tmhsdigital.github.io/screencast-mcp/tools/overlay.html) | Composite an image or video (logo, watermark, picture-in-picture) onto a video at a pixel position, optionally scaled and time-limited; keeps the base's audio and length. |
|
|
152
|
-
| [`callout`](https://tmhsdigital.github.io/screencast-mcp/tools/callout.html) | Annotate a video with timed boxes, text labels, and arrows. Fallback fonts used are listed in fallbackFonts; characters no font covers are reported in warnings. |
|
|
153
|
+
| [`callout`](https://tmhsdigital.github.io/screencast-mcp/tools/callout.html) | Annotate a video or screenshot with timed boxes, text labels, and arrows. Fallback fonts used are listed in fallbackFonts; characters no font covers are reported in warnings. |
|
|
153
154
|
| [`keystroke_overlay`](https://tmhsdigital.github.io/screencast-mcp/tools/keystroke_overlay.html) | Burn keycast-style badges for shortcuts, clicks, and typing from the recording's input event log (start_recording events: true). Never shows typed text: the log has none. |
|
|
154
155
|
| [`cursor`](https://tmhsdigital.github.io/screencast-mcp/tools/cursor.html) | Draw a smoothed, scaled cursor that hides when idle from the event log of a start_recording cursor: "events" recording (no OS cursor in the video), with click ripples and an optional spotlight. |
|
|
155
156
|
| [`backdrop`](https://tmhsdigital.github.io/screencast-mcp/tools/backdrop.html) | Frame a video or screenshot on a gradient, color, or wallpaper with padding, rounded corners, and a drop shadow, optionally on a 16:9/1:1/9:16/4:5 canvas. |
|
|
@@ -203,7 +204,7 @@ Every capture tool takes one `target` string: `full`, `monitor:<index>`, `window
|
|
|
203
204
|
<!-- toolsets:start -->
|
|
204
205
|
| Toolset | Tools |
|
|
205
206
|
| --- | --- |
|
|
206
|
-
| `capture` | `start_recording`, `stop_recording`, `pause_recording`, `resume_recording`, `save_replay`, `list_sessions`, `get_session`, `read_events`, `add_marker`, `screenshot`, `list_audio_devices`, `list_video_devices`, `list_targets` |
|
|
207
|
+
| `capture` | `start_recording`, `stop_recording`, `delete_recording`, `pause_recording`, `resume_recording`, `save_replay`, `list_sessions`, `get_session`, `read_events`, `add_marker`, `screenshot`, `list_audio_devices`, `list_video_devices`, `list_targets` |
|
|
207
208
|
| `watch` | `review_recording`, `player_frames`, `sample_frames`, `contact_sheet`, `screen_diff`, `wait_for_change`, `find_text`, `index_recording`, `search_recording` |
|
|
208
209
|
| `edit` | `trim`, `concat`, `convert`, `export_gif`, `crop`, `scale`, `speed`, `compress`, `clip`, `cut_idle`, `cut_by_transcript`, `redact_region`, `pipeline` |
|
|
209
210
|
| `produce` | `overlay`, `callout`, `keystroke_overlay`, `cursor`, `backdrop`, `burn_subtitles`, `chapters`, `xfade_transition`, `assemble_highlights`, `title_card`, `reframe`, `zoom`, `export_preset`, `bug_report`, `step_guide` |
|
|
@@ -221,7 +222,7 @@ Every capture tool takes one `target` string: `full`, `monitor:<index>`, `window
|
|
|
221
222
|
with:
|
|
222
223
|
command: npm run test:e2e
|
|
223
224
|
```
|
|
224
|
-
- **Prompts and resources:** the server also ships MCP prompts that clients show as slash commands (`bug-repro-clip`, `file-bug-report`, `document-steps`, `demo-gif`, `verify-ui-change`, `review-recording`) and `screencast://sessions` resources for attaching recordings without a filesystem tool.
|
|
225
|
+
- **Prompts and resources:** the server also ships MCP prompts that clients show as slash commands (`bug-repro-clip`, `file-bug-report`, `document-steps`, `demo-gif`, `verify-ui-change`, `review-recording`) and `screencast://sessions` resources for attaching recordings without a filesystem tool. A client can subscribe to the list or one session and is notified when it changes, such as a recording that stopped at its cap.
|
|
225
226
|
- **Threat model and Windows notes:** what capture can expose, and how window, monitor, WGC, and system-audio capture behave, are on the [docs home page](https://tmhsdigital.github.io/screencast-mcp/#threat-model).
|
|
226
227
|
|
|
227
228
|
## Privacy
|
|
@@ -230,7 +231,7 @@ Every capture tool takes one `target` string: `full`, `monitor:<index>`, `window
|
|
|
230
231
|
- **What a tool returns goes to your model provider.** Inline frames, OCR text, and event summaries reach your agent like any tool result; files on disk stay on disk unless a tool returns them or you share them.
|
|
231
232
|
- **Everything is stored under `SCREENCAST_HOME`** (`recordings/`, `screenshots/`, `frames/`, `edits/`, `sessions.json`) unless a call names another path. `find_text` and `wait_for_change` delete their captures after the call by default (`keep: true` keeps them); `screen_diff` compares existing images and captures nothing.
|
|
232
233
|
- **The event log never records typed text.** Only with `start_recording` `events: true` (or `cursor: "events"`), and only while that recording runs: clicks, scrolls, and cursor positions system-wide, and typing as bursts on a 0.5 s grid with no key names (`keys: "shortcuts"` also names Ctrl/Alt/Win chords). There is no microphone capture; system audio only with `audio.source` = `system`.
|
|
233
|
-
- **Deleting data.**
|
|
234
|
+
- **Deleting data.** `delete_recording` removes a recording with its sidecars (event log, webcam, transcript, index with its screen text, markers) and registry entry, asking you first when the client supports it. Otherwise delete files under `SCREENCAST_HOME`, or set `SCREENCAST_RETENTION_DAYS`; recordings and edits are never deleted automatically.
|
|
234
235
|
|
|
235
236
|
## Contributing
|
|
236
237
|
|
package/dist/resources.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, rmSync } from "node:fs";
|
|
2
2
|
import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { SubscribeRequestSchema, UnsubscribeRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
3
4
|
import { getStore, isShuttingDown } from "./context.js";
|
|
4
5
|
import { ScreencastError } from "./utils/errors.js";
|
|
5
6
|
import { runFfmpeg, probeMedia } from "./utils/ffmpeg.js";
|
|
@@ -55,6 +56,16 @@ export function registerResources(server) {
|
|
|
55
56
|
rmSync(frame, { force: true });
|
|
56
57
|
}
|
|
57
58
|
});
|
|
59
|
+
const subscribed = new Map();
|
|
60
|
+
server.server.registerCapabilities({ resources: { subscribe: true } });
|
|
61
|
+
server.server.setRequestHandler(SubscribeRequestSchema, (req) => {
|
|
62
|
+
subscribed.set(req.params.uri, resourceSnapshot(req.params.uri));
|
|
63
|
+
return {};
|
|
64
|
+
});
|
|
65
|
+
server.server.setRequestHandler(UnsubscribeRequestSchema, (req) => {
|
|
66
|
+
subscribed.delete(req.params.uri);
|
|
67
|
+
return {};
|
|
68
|
+
});
|
|
58
69
|
getStore().onChange(() => {
|
|
59
70
|
if (isShuttingDown() || !server.isConnected())
|
|
60
71
|
return;
|
|
@@ -63,5 +74,20 @@ export function registerResources(server) {
|
|
|
63
74
|
}
|
|
64
75
|
catch {
|
|
65
76
|
}
|
|
77
|
+
for (const [uri, before] of subscribed) {
|
|
78
|
+
const now = resourceSnapshot(uri);
|
|
79
|
+
if (now === before)
|
|
80
|
+
continue;
|
|
81
|
+
subscribed.set(uri, now);
|
|
82
|
+
server.server.sendResourceUpdated({ uri }).catch(() => {
|
|
83
|
+
});
|
|
84
|
+
}
|
|
66
85
|
});
|
|
67
86
|
}
|
|
87
|
+
export function resourceSnapshot(uri) {
|
|
88
|
+
if (uri === "screencast://sessions")
|
|
89
|
+
return JSON.stringify(getStore().list());
|
|
90
|
+
const m = /^screencast:\/\/sessions\/([^/]+)$/.exec(uri);
|
|
91
|
+
const s = m ? getStore().get(decodeURIComponent(m[1])) : undefined;
|
|
92
|
+
return s ? JSON.stringify(s) : null;
|
|
93
|
+
}
|
package/dist/server.js
CHANGED
|
@@ -3,6 +3,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
3
3
|
import { parseToolsets, serverInstructions, SELECTABLE_TOOLSETS, toolsetOf, } from "./utils/toolsets.js";
|
|
4
4
|
import { register as registerStartRecording } from "./tools/startRecording.js";
|
|
5
5
|
import { register as registerStopRecording } from "./tools/stopRecording.js";
|
|
6
|
+
import { register as registerDeleteRecording } from "./tools/deleteRecording.js";
|
|
6
7
|
import { register as registerSaveReplay } from "./tools/saveReplay.js";
|
|
7
8
|
import { register as registerPauseRecording } from "./tools/pauseRecording.js";
|
|
8
9
|
import { register as registerResumeRecording } from "./tools/resumeRecording.js";
|
|
@@ -79,6 +80,7 @@ export function createServer(options = {}) {
|
|
|
79
80
|
const tools = captureRegisteredTools(server);
|
|
80
81
|
registerStartRecording(server);
|
|
81
82
|
registerStopRecording(server);
|
|
83
|
+
registerDeleteRecording(server);
|
|
82
84
|
registerPauseRecording(server);
|
|
83
85
|
registerResumeRecording(server);
|
|
84
86
|
registerSaveReplay(server);
|
package/dist/tools/backdrop.js
CHANGED
|
@@ -5,20 +5,10 @@ import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
|
5
5
|
import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
|
|
6
6
|
import { requireFfmpeg, probeMedia } from "../utils/ffmpeg.js";
|
|
7
7
|
import { runEditJob } from "../utils/jobs.js";
|
|
8
|
-
import { buildBackdropArgs,
|
|
8
|
+
import { buildBackdropArgs, backdropOptionsSchema } from "../utils/backdrop.js";
|
|
9
9
|
import { editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
10
10
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
11
11
|
const STILL = /\.(png|jpe?g|bmp|tiff?|webp)$/i;
|
|
12
|
-
export const backdropOptionsSchema = {
|
|
13
|
-
preset: z.enum(BACKDROP_PRESET_NAMES).optional(),
|
|
14
|
-
colors: z.array(z.string()).min(1).max(MAX_BACKDROP_COLORS).optional(),
|
|
15
|
-
image: z.string().min(1).optional(),
|
|
16
|
-
padding: z.number().int().nonnegative().max(2000).optional(),
|
|
17
|
-
radius: z.number().int().nonnegative().max(1000).optional(),
|
|
18
|
-
shadow: z.number().int().nonnegative().max(200).optional(),
|
|
19
|
-
shadowOpacity: z.number().min(0).max(1).optional(),
|
|
20
|
-
aspect: z.enum(["16:9", "9:16", "1:1", "4:5"]).optional(),
|
|
21
|
-
};
|
|
22
12
|
const o = backdropOptionsSchema;
|
|
23
13
|
const inputSchema = {
|
|
24
14
|
input: z.string().min(1).describe("Path to the source video or image (png/jpg)."),
|
package/dist/tools/bugReport.js
CHANGED
|
@@ -10,18 +10,15 @@ import { runEditJob } from "../utils/jobs.js";
|
|
|
10
10
|
import { planPipeline } from "../utils/pipeline.js";
|
|
11
11
|
import { exportAnimation } from "../utils/animExport.js";
|
|
12
12
|
import { DEFAULT_MAX_BYTES } from "../utils/anim.js";
|
|
13
|
-
import { evenTimes, DEFAULT_SHEET_COUNT, DEFAULT_TILE_WIDTH } from "../utils/sheet.js";
|
|
14
|
-
import { scanVideoFrames, scanMatches } from "../utils/ocrScan.js";
|
|
15
|
-
import {
|
|
13
|
+
import { evenTimes, DEFAULT_SHEET_COUNT, DEFAULT_TILE_WIDTH, renderContactSheet } from "../utils/sheet.js";
|
|
14
|
+
import { scanVideoFrames, scanMatches, DEFAULT_SCAN_FRAMES, MAX_SCAN_FRAMES } from "../utils/ocrScan.js";
|
|
15
|
+
import { parseEventsJsonl } from "../utils/events.js";
|
|
16
16
|
import { ocrStatus, parseFfmpegVersion, versionText } from "../utils/capabilities.js";
|
|
17
17
|
import { getMonitors } from "../utils/monitors.js";
|
|
18
18
|
import { resolveOutputDir, subdir, stamp, rand } from "../utils/paths.js";
|
|
19
19
|
import { encodeInlineImages, DEFAULT_MAX_IMAGE_WIDTH } from "../utils/images.js";
|
|
20
|
-
import {
|
|
21
|
-
import { redactRegionSchema } from "
|
|
22
|
-
import { renderContactSheet } from "./contactSheet.js";
|
|
23
|
-
import { DEFAULT_SCAN_FRAMES, MAX_SCAN_FRAMES } from "./findText.js";
|
|
24
|
-
import { DEFAULT_CLIP_SEC, DEFAULT_ERROR_PATTERN, DEFAULT_SCAN_EVERY_SEC, DEFAULT_SECRET_PATTERN, MAX_CLIP_SEC, MAX_STEPS, REPORT_FILES, buildReportMarkdown, clipWindow, errorFindings, maskSecrets, mergeRedactions, reconstructSteps, } from "../utils/bugReport.js";
|
|
20
|
+
import { DEFAULT_CLIP_SEC, DEFAULT_ERROR_PATTERN, DEFAULT_SCAN_EVERY_SEC, DEFAULT_SECRET_PATTERN, MAX_CLIP_SEC, MAX_STEPS, REPORT_FILES, buildReportMarkdown, clipWindow, errorFindings, maskSecrets, mergeRedactions, reconstructSteps, resolveSource, } from "../utils/bugReport.js";
|
|
21
|
+
import { redactRegionSchema } from "../utils/media.js";
|
|
25
22
|
const { version: serverVersion } = createRequire(import.meta.url)("../../package.json");
|
|
26
23
|
const inputSchema = {
|
|
27
24
|
input: z.string().min(1).optional().describe("Recording path (uses its .events.jsonl)."),
|
|
@@ -44,26 +41,6 @@ const inputSchema = {
|
|
|
44
41
|
overwrite: z.boolean().optional().describe("Replace a report already in outputDir."),
|
|
45
42
|
};
|
|
46
43
|
const r3 = (n) => Math.round(n * 1000) / 1000;
|
|
47
|
-
export async function resolveSource(args) {
|
|
48
|
-
if (args.sessionId !== undefined) {
|
|
49
|
-
const record = getStore().get(args.sessionId);
|
|
50
|
-
if (!record)
|
|
51
|
-
throw new ScreencastError(`No session with id "${args.sessionId}".`);
|
|
52
|
-
if (record.status === "recording" || record.status === "paused") {
|
|
53
|
-
throw new ScreencastError("The recording is still running; stop_recording it first.");
|
|
54
|
-
}
|
|
55
|
-
await whenFinalized(record.id);
|
|
56
|
-
if (!existsSync(record.outputPath))
|
|
57
|
-
throw new ScreencastError(`The session's recording is missing: ${record.outputPath}`);
|
|
58
|
-
const events = record.events?.path;
|
|
59
|
-
return { path: record.outputPath, eventsPath: events && existsSync(events) ? events : null, record };
|
|
60
|
-
}
|
|
61
|
-
const path = args.input;
|
|
62
|
-
if (!existsSync(path))
|
|
63
|
-
throw new ScreencastError(`Input file not found: ${path}`);
|
|
64
|
-
const { jsonl } = eventPaths(path);
|
|
65
|
-
return { path, eventsPath: existsSync(jsonl) ? jsonl : null };
|
|
66
|
-
}
|
|
67
44
|
async function displayRows() {
|
|
68
45
|
if (process.platform !== "win32")
|
|
69
46
|
return null;
|
|
@@ -5,7 +5,7 @@ import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
|
5
5
|
import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
|
|
6
6
|
import { requireFfmpeg, probeMedia, hasFilter } from "../utils/ffmpeg.js";
|
|
7
7
|
import { runEditJob } from "../utils/jobs.js";
|
|
8
|
-
import { buildBurnSubtitlesArgs } from "../utils/captions.js";
|
|
8
|
+
import { buildBurnSubtitlesArgs, CAPTION_STYLE_NAMES } from "../utils/captions.js";
|
|
9
9
|
import { bundledFontPath } from "../utils/fonts.js";
|
|
10
10
|
import { editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
11
11
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
@@ -13,7 +13,7 @@ const inputSchema = {
|
|
|
13
13
|
input: z.string().min(1).describe("Path to the source video."),
|
|
14
14
|
subtitles: z.string().min(1).describe("Path to an .srt (e.g. from transcribe) or .ass subtitle file."),
|
|
15
15
|
style: z
|
|
16
|
-
.enum(
|
|
16
|
+
.enum(CAPTION_STYLE_NAMES)
|
|
17
17
|
.optional()
|
|
18
18
|
.describe("clean (default for .srt): outlined line. social: big bold text on a dark box. .ass keeps its own " +
|
|
19
19
|
"styling unless set."),
|
package/dist/tools/callout.js
CHANGED
|
@@ -6,53 +6,12 @@ import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
|
6
6
|
import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
|
|
7
7
|
import { requireFfmpeg } from "../utils/ffmpeg.js";
|
|
8
8
|
import { runEditJob, probeDuration } from "../utils/jobs.js";
|
|
9
|
-
import { buildCalloutArgs } from "../utils/callout.js";
|
|
9
|
+
import { buildCalloutArgs, calloutItemSchema, fontFileSchema } from "../utils/callout.js";
|
|
10
10
|
import { prepareCalloutAssets } from "../utils/calloutAssets.js";
|
|
11
|
-
import {
|
|
11
|
+
import { stillEdit } from "../utils/media.js";
|
|
12
12
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
13
|
-
const timing = {
|
|
14
|
-
from: z.number().nonnegative().optional(),
|
|
15
|
-
to: z.number().positive().optional(),
|
|
16
|
-
color: z.string().optional(),
|
|
17
|
-
};
|
|
18
|
-
export const fontFileSchema = z
|
|
19
|
-
.string()
|
|
20
|
-
.min(1)
|
|
21
|
-
.optional()
|
|
22
|
-
.describe("Font: a .ttf/.otf/.ttc path or a C:\\Windows\\Fonts file name. Default: bundled Inter, with a " +
|
|
23
|
-
"covering system font for scripts it lacks (CJK, emoji, Arabic, ...).");
|
|
24
|
-
export const calloutItemSchema = z.discriminatedUnion("type", [
|
|
25
|
-
z.object({
|
|
26
|
-
type: z.literal("box"),
|
|
27
|
-
x: z.number(),
|
|
28
|
-
y: z.number(),
|
|
29
|
-
width: z.number().positive(),
|
|
30
|
-
height: z.number().positive(),
|
|
31
|
-
thickness: z.number().positive().optional().describe("Outline px (default 4)."),
|
|
32
|
-
fill: z.boolean().optional().describe("Fill instead of outline."),
|
|
33
|
-
...timing,
|
|
34
|
-
}),
|
|
35
|
-
z.object({
|
|
36
|
-
type: z.literal("text"),
|
|
37
|
-
x: z.number(),
|
|
38
|
-
y: z.number(),
|
|
39
|
-
text: z.string().min(1),
|
|
40
|
-
size: z.number().positive().optional().describe("Font size px (default 32)."),
|
|
41
|
-
background: z.boolean().optional().describe("Dark panel behind the text (default true)."),
|
|
42
|
-
...timing,
|
|
43
|
-
}),
|
|
44
|
-
z.object({
|
|
45
|
-
type: z.literal("arrow"),
|
|
46
|
-
x1: z.number(),
|
|
47
|
-
y1: z.number(),
|
|
48
|
-
x2: z.number().describe("Head (x2,y2) is the point the arrow points at."),
|
|
49
|
-
y2: z.number(),
|
|
50
|
-
thickness: z.number().positive().optional().describe("Shaft px (default 8)."),
|
|
51
|
-
...timing,
|
|
52
|
-
}),
|
|
53
|
-
]);
|
|
54
13
|
const inputSchema = {
|
|
55
|
-
input: z.string().min(1).describe("Path to the source video."),
|
|
14
|
+
input: z.string().min(1).describe("Path to the source video or image (png/jpg; from/to are ignored for an image)."),
|
|
56
15
|
items: z
|
|
57
16
|
.array(calloutItemSchema)
|
|
58
17
|
.min(1)
|
|
@@ -66,7 +25,7 @@ const inputSchema = {
|
|
|
66
25
|
export function register(server) {
|
|
67
26
|
server.registerTool("callout", {
|
|
68
27
|
title: "Add Callouts",
|
|
69
|
-
description: "Annotate a video with timed boxes, text labels, and arrows. Fallback fonts used are listed in " +
|
|
28
|
+
description: "Annotate a video or screenshot with timed boxes, text labels, and arrows. Fallback fonts used are listed in " +
|
|
70
29
|
"fallbackFonts; characters no font covers are reported in warnings.",
|
|
71
30
|
inputSchema,
|
|
72
31
|
outputSchema: OUTPUT_PATH,
|
|
@@ -78,14 +37,13 @@ export function register(server) {
|
|
|
78
37
|
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
79
38
|
}
|
|
80
39
|
const items = args.items;
|
|
81
|
-
|
|
82
|
-
const ext = editOutputExt(args.input);
|
|
40
|
+
const { still, ext } = stillEdit(args.input, args.output);
|
|
83
41
|
const output = resolveOutput(args.output, subdir("edits"), `callout-${stamp()}-${rand()}${ext}`, args.overwrite);
|
|
84
42
|
const work = mkdtempSync(join(tmpdir(), "screencast-callout-"));
|
|
85
43
|
try {
|
|
86
44
|
const assets = await prepareCalloutAssets(items, work, "", args.fontFile);
|
|
87
|
-
const ffArgs = buildCalloutArgs(args.input, output, items, assets);
|
|
88
|
-
await runEditJob(ffArgs, { output, durationSec: await probeDuration(args.input), extra });
|
|
45
|
+
const ffArgs = buildCalloutArgs(args.input, output, items, assets, undefined, still);
|
|
46
|
+
await runEditJob(ffArgs, { output, durationSec: still ? null : await probeDuration(args.input), extra });
|
|
89
47
|
return okResponse({
|
|
90
48
|
outputPath: output,
|
|
91
49
|
callouts: items.length,
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
import { existsSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
-
import { tmpdir } from "node:os";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
5
3
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
6
4
|
import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
|
|
7
5
|
import { requireFfmpeg, runFfmpeg, runCapture, probeMedia } from "../utils/ffmpeg.js";
|
|
8
6
|
import { jobTimeoutMs } from "../utils/jobs.js";
|
|
9
7
|
import { buildSceneScanArgs, parseSceneScan, pickSceneFrames, DEFAULT_SCENE_THRESHOLD, } from "../utils/media.js";
|
|
10
|
-
import { evenTimes,
|
|
11
|
-
import {
|
|
12
|
-
import { resolveOutput, subdir, stamp, rand, sequencePattern } from "../utils/paths.js";
|
|
8
|
+
import { evenTimes, buildPosterArgs, DEFAULT_SHEET_COUNT, MAX_SHEET_COUNT, DEFAULT_TILE_WIDTH, renderContactSheet, } from "../utils/sheet.js";
|
|
9
|
+
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
13
10
|
import { encodeInlineImages, DEFAULT_MAX_IMAGE_WIDTH } from "../utils/images.js";
|
|
14
11
|
const inputSchema = {
|
|
15
12
|
input: z.string().min(1).describe("Path to the source video."),
|
|
@@ -55,24 +52,6 @@ const inputSchema = {
|
|
|
55
52
|
.optional()
|
|
56
53
|
.describe(`Max inline image width (default ${DEFAULT_MAX_IMAGE_WIDTH}).`),
|
|
57
54
|
};
|
|
58
|
-
export async function renderContactSheet(input, times, output, opts, signal) {
|
|
59
|
-
const grid = sheetGrid(times.length, opts.columns);
|
|
60
|
-
const work = mkdtempSync(join(tmpdir(), "screencast-sheet-"));
|
|
61
|
-
try {
|
|
62
|
-
const font = bundledFontPath("bold");
|
|
63
|
-
for (const [i, t] of times.entries()) {
|
|
64
|
-
const labelFile = join(work, `label_${i}.txt`);
|
|
65
|
-
writeFileSync(labelFile, formatTimecode(t));
|
|
66
|
-
const tile = join(work, `tile_${String(i).padStart(3, "0")}.png`);
|
|
67
|
-
await runFfmpeg(buildTileArgs(input, t, tile, opts.tileWidth, font, labelFile), 60_000, { signal });
|
|
68
|
-
}
|
|
69
|
-
await runFfmpeg(buildSheetArgs(sequencePattern(work, "tile_%03d.png"), grid, output), 60_000, { signal });
|
|
70
|
-
}
|
|
71
|
-
finally {
|
|
72
|
-
rmSync(work, { recursive: true, force: true });
|
|
73
|
-
}
|
|
74
|
-
return grid;
|
|
75
|
-
}
|
|
76
55
|
export function register(server) {
|
|
77
56
|
server.registerTool("contact_sheet", {
|
|
78
57
|
title: "Contact Sheet",
|
package/dist/tools/cursor.js
CHANGED
|
@@ -1,35 +1,15 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { existsSync, mkdtempSync,
|
|
3
|
+
import { existsSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
6
6
|
import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
|
|
7
7
|
import { requireFfmpeg, probeMedia } from "../utils/ffmpeg.js";
|
|
8
8
|
import { runEditJob } from "../utils/jobs.js";
|
|
9
|
-
import {
|
|
10
|
-
import { buildCursorArgs, cursorSpritePath, planCursor, transformCursor, DEFAULT_CURSOR_SIZE, DEFAULT_HIDE_AFTER_SEC, } from "../utils/cursor.js";
|
|
9
|
+
import { buildCursorArgs, cursorSpritePath, transformCursor, DEFAULT_CURSOR_SIZE, DEFAULT_HIDE_AFTER_SEC, cursorOptionsSchema, loadCursor, } from "../utils/cursor.js";
|
|
11
10
|
import { editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
12
11
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
13
|
-
export const cursorOptionsSchema = {
|
|
14
|
-
events: z.string().optional(),
|
|
15
|
-
size: z.number().min(0.25).max(8).optional(),
|
|
16
|
-
smoothing: z.number().min(0).max(1).optional(),
|
|
17
|
-
hideAfterSec: z.number().min(0).max(600).optional(),
|
|
18
|
-
clicks: z.boolean().optional(),
|
|
19
|
-
spotlight: z.boolean().optional(),
|
|
20
|
-
};
|
|
21
12
|
const o = cursorOptionsSchema;
|
|
22
|
-
export function loadCursor(input, events, opts, endSec) {
|
|
23
|
-
const path = events ?? eventPaths(input).jsonl;
|
|
24
|
-
if (!existsSync(path)) {
|
|
25
|
-
throw new ScreencastError(`No event log for ${input} (looked for ${path}). Record with start_recording cursor: "events" ` +
|
|
26
|
-
"(no OS cursor in the video, events logged), or pass events: <path to .events.jsonl>.");
|
|
27
|
-
}
|
|
28
|
-
const plan = planCursor(parseEventsJsonl(readFileSync(path, "utf8")), opts, endSec);
|
|
29
|
-
if (plan.path.length === 0)
|
|
30
|
-
throw new ScreencastError(`The event log ${path} has no cursor positions to draw.`);
|
|
31
|
-
return plan;
|
|
32
|
-
}
|
|
33
13
|
const inputSchema = {
|
|
34
14
|
input: z.string().min(1).describe("Path to the recording."),
|
|
35
15
|
events: o.events.describe("Event log (default: the input's .events.jsonl)."),
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { existsSync, readdirSync, rmSync, statSync } from "node:fs";
|
|
3
|
+
import { dirname, resolve } from "node:path";
|
|
4
|
+
import { errorMessage, errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
5
|
+
import { DELETES_FILE, looseOutput } from "../utils/toolSpec.js";
|
|
6
|
+
import { getStore } from "../context.js";
|
|
7
|
+
import { isLive } from "../utils/sessions.js";
|
|
8
|
+
import { samePath } from "../utils/recordingIndex.js";
|
|
9
|
+
import { assertDeleteAllowed, recordingSidecars } from "../utils/recordingFiles.js";
|
|
10
|
+
import { subdir } from "../utils/paths.js";
|
|
11
|
+
import { CONFIRM_TIMEOUT_MS, confirmCaptureEnabled, CONFIRM_CAPTURE_ENV } from "../utils/consent.js";
|
|
12
|
+
const inputSchema = {
|
|
13
|
+
sessionId: z.string().min(1).optional().describe("Session id of the recording to delete."),
|
|
14
|
+
input: z.string().min(1).optional().describe("Or the recording's path."),
|
|
15
|
+
};
|
|
16
|
+
function sizeOf(path) {
|
|
17
|
+
try {
|
|
18
|
+
const st = statSync(path);
|
|
19
|
+
if (!st.isDirectory())
|
|
20
|
+
return st.size;
|
|
21
|
+
return readdirSync(path).reduce((n, name) => n + sizeOf(resolve(path, name)), 0);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function confirmDelete(server, message, signal) {
|
|
28
|
+
if (!server.server.getClientCapabilities()?.elicitation?.form) {
|
|
29
|
+
if (confirmCaptureEnabled()) {
|
|
30
|
+
throw new ScreencastError(`Not deleted: ${CONFIRM_CAPTURE_ENV} requires the user to confirm, but this client does not support MCP elicitation.`);
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
let action;
|
|
35
|
+
try {
|
|
36
|
+
({ action } = await server.server.elicitInput({ message, requestedSchema: { type: "object", properties: {} } }, { signal, timeout: CONFIRM_TIMEOUT_MS }));
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
throw new ScreencastError(`Not deleted: the confirmation request failed (${errorMessage(err)}).`);
|
|
40
|
+
}
|
|
41
|
+
if (action !== "accept")
|
|
42
|
+
throw new ScreencastError(`Not deleted: ${action === "decline" ? "declined" : "cancelled"} by the user.`);
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
export function register(server) {
|
|
46
|
+
server.registerTool("delete_recording", {
|
|
47
|
+
title: "Delete Recording",
|
|
48
|
+
description: "Delete a finished recording with its sidecars (event log, webcam, transcript, index, markers, pause parts) " +
|
|
49
|
+
"and registry entries; reports bytes freed. Asks the user first when the client supports it. Edits made from it are kept.",
|
|
50
|
+
inputSchema,
|
|
51
|
+
outputSchema: looseOutput({
|
|
52
|
+
outputPath: z.string(),
|
|
53
|
+
deleted: z.array(z.string()),
|
|
54
|
+
bytesFreed: z.number(),
|
|
55
|
+
sessionsRemoved: z.array(z.string()),
|
|
56
|
+
}),
|
|
57
|
+
annotations: DELETES_FILE,
|
|
58
|
+
}, async (args, extra) => {
|
|
59
|
+
try {
|
|
60
|
+
if (!!args.sessionId === !!args.input)
|
|
61
|
+
throw new ScreencastError("Give exactly one of sessionId or input.");
|
|
62
|
+
const store = getStore();
|
|
63
|
+
let video;
|
|
64
|
+
if (args.sessionId) {
|
|
65
|
+
const record = store.get(args.sessionId);
|
|
66
|
+
if (!record)
|
|
67
|
+
throw new ScreencastError(`No session with id "${args.sessionId}".`);
|
|
68
|
+
video = record.outputPath;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
video = resolve(args.input);
|
|
72
|
+
}
|
|
73
|
+
assertDeleteAllowed(video);
|
|
74
|
+
const sessions = store.list().filter((r) => samePath(r.outputPath, video));
|
|
75
|
+
const live = sessions.find((r) => isLive(r.status));
|
|
76
|
+
if (live)
|
|
77
|
+
throw new ScreencastError(`Recording ${live.id} is still ${live.status}; stop it first.`);
|
|
78
|
+
let siblings = [];
|
|
79
|
+
try {
|
|
80
|
+
siblings = readdirSync(dirname(video));
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
}
|
|
84
|
+
const side = recordingSidecars(video, siblings, subdir("edits"));
|
|
85
|
+
const targets = [video, ...side.files, ...side.dirs].filter((p) => existsSync(p));
|
|
86
|
+
if (targets.length === 0 && sessions.length === 0)
|
|
87
|
+
throw new ScreencastError(`Nothing to delete: ${video} does not exist.`);
|
|
88
|
+
const asked = await confirmDelete(server, `Delete ${video} and ${targets.length - (existsSync(video) ? 1 : 0)} sidecar file(s)? This cannot be undone.`, extra.signal);
|
|
89
|
+
let bytesFreed = 0;
|
|
90
|
+
const deleted = [];
|
|
91
|
+
const failed = [];
|
|
92
|
+
for (const p of targets) {
|
|
93
|
+
const size = sizeOf(p);
|
|
94
|
+
try {
|
|
95
|
+
rmSync(p, { recursive: true, force: true });
|
|
96
|
+
deleted.push(p);
|
|
97
|
+
bytesFreed += size;
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
failed.push(`${p}: ${errorMessage(err)}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const removedIds = existsSync(video) ? [] : sessions.map((r) => r.id);
|
|
104
|
+
if (removedIds.length > 0)
|
|
105
|
+
store.remove(removedIds);
|
|
106
|
+
return okResponse({
|
|
107
|
+
outputPath: video,
|
|
108
|
+
deleted,
|
|
109
|
+
bytesFreed,
|
|
110
|
+
sessionsRemoved: removedIds,
|
|
111
|
+
confirmedByUser: asked,
|
|
112
|
+
...(failed.length > 0 ? { failed, note: "Some files could not be deleted (in use?); the registry entry was kept if the recording remains." } : {}),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
return errorResponse(error);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
package/dist/tools/denoise.js
CHANGED
|
@@ -4,13 +4,13 @@ import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
|
4
4
|
import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
|
|
5
5
|
import { requireFfmpeg, runCapture, probeMedia } from "../utils/ffmpeg.js";
|
|
6
6
|
import { runEditJob, jobTimeoutMs } from "../utils/jobs.js";
|
|
7
|
-
import { buildDenoiseArgs, buildNoiseFloorArgs, parseNoiseFloor } from "../utils/audio.js";
|
|
7
|
+
import { buildDenoiseArgs, buildNoiseFloorArgs, parseNoiseFloor, DENOISE_STRENGTHS } from "../utils/audio.js";
|
|
8
8
|
import { editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
9
9
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
10
10
|
const inputSchema = {
|
|
11
11
|
input: z.string().min(1).describe("Path to the source video or audio file."),
|
|
12
12
|
strength: z
|
|
13
|
-
.enum(
|
|
13
|
+
.enum(DENOISE_STRENGTHS)
|
|
14
14
|
.optional()
|
|
15
15
|
.describe("How hard to reduce noise: light (6 dB), medium (12 dB, default), strong (20 dB)."),
|
|
16
16
|
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
package/dist/tools/findText.js
CHANGED
|
@@ -9,15 +9,13 @@ import { resolveCaptureTarget } from "../utils/resolveTarget.js";
|
|
|
9
9
|
import { captureStill } from "../utils/still.js";
|
|
10
10
|
import { buildHighlightArgs, targetSize } from "../utils/diff.js";
|
|
11
11
|
import { findMatches, redactionRects } from "../utils/ocr.js";
|
|
12
|
-
import { readFrames, scanVideoFrames, scanMatches } from "../utils/ocrScan.js";
|
|
12
|
+
import { readFrames, scanVideoFrames, scanMatches, DEFAULT_SCAN_FRAMES, MAX_SCAN_FRAMES } from "../utils/ocrScan.js";
|
|
13
13
|
import { windowMatchReport } from "../utils/windows.js";
|
|
14
14
|
import { confirmCapture, describeTarget } from "../utils/consent.js";
|
|
15
15
|
import { subdir, stamp, rand, stillOutput } from "../utils/paths.js";
|
|
16
16
|
import { encodeInlineImages, DEFAULT_MAX_IMAGE_WIDTH } from "../utils/images.js";
|
|
17
17
|
const IMAGE_EXTENSIONS = new Set([".png", ".jpg", ".jpeg", ".bmp", ".gif", ".webp", ".tif", ".tiff"]);
|
|
18
18
|
const MAX_LINES = 300;
|
|
19
|
-
export const DEFAULT_SCAN_FRAMES = 30;
|
|
20
|
-
export const MAX_SCAN_FRAMES = 120;
|
|
21
19
|
const inputSchema = {
|
|
22
20
|
target: z
|
|
23
21
|
.string()
|
|
@@ -13,6 +13,7 @@ import { parseEventsJsonl } from "../utils/events.js";
|
|
|
13
13
|
import { resolveWhisperModel, buildTranscribeArgs, parseSrt, normalizeCues } from "../utils/captions.js";
|
|
14
14
|
import { subdir, tempPath } from "../utils/paths.js";
|
|
15
15
|
import { DEFAULT_INDEX_FRAMES, DEFAULT_INDEX_THRESHOLD, INDEX_VERSION, MAX_INDEX_FRAMES, attach, canReuseIndex, cueTexts, defaultTranscriptPath, eventTexts, fingerprintFile, findIndex, indexMatchesVideo, indexWritePath, keyframeTime, legacyIndexSidecarPath, markerTexts, maskSegmentText, mergeSegments, planKeyframes, readIndex, resolveRecording, segmentsFrom, writeIndex, } from "../utils/recordingIndex.js";
|
|
16
|
+
import { mapPool } from "../utils/pool.js";
|
|
16
17
|
const OCR_BATCH = 8;
|
|
17
18
|
const inputSchema = {
|
|
18
19
|
input: z.string().optional().describe("Recording path."),
|
|
@@ -79,14 +80,13 @@ export function register(server) {
|
|
|
79
80
|
for (let b = 0; b < spans.length; b += OCR_BATCH) {
|
|
80
81
|
extra.signal.throwIfAborted();
|
|
81
82
|
const batch = spans.slice(b, b + OCR_BATCH);
|
|
82
|
-
const
|
|
83
|
-
for (const [i, span] of batch.entries()) {
|
|
83
|
+
const grabbed = await mapPool(batch, async (span, i) => {
|
|
84
84
|
const out = join(work, `key_${b + i}.png`);
|
|
85
85
|
await runFfmpeg(buildSampleAtTimestampArgs(source.path, keyframeTime(span), out), 60_000, { signal: extra.signal });
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const read = frames.length > 0 ? await readFrames(frames.map((f) => f.path), work, extra.signal) : [];
|
|
86
|
+
return { at: b + i, path: out };
|
|
87
|
+
});
|
|
88
|
+
const frames = grabbed.filter((f) => existsSync(f.path));
|
|
89
|
+
const read = frames.length > 0 ? await readFrames(frames.map((f) => f.path), work, extra.signal, { sameSize: true }) : [];
|
|
90
90
|
read.forEach((f, i) => (texts[frames[i].at] = f.lines.map((l) => l.text)));
|
|
91
91
|
framesRead += read.length;
|
|
92
92
|
report?.(0.1 + (0.85 * Math.min(spans.length, b + OCR_BATCH)) / spans.length);
|