@tmhs/screencast-mcp 0.37.0 → 0.39.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 +26 -7
- package/dist/index.js +10 -94
- package/dist/index.js.map +1 -1
- package/dist/prompts.js +1 -1
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +103 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/findText.d.ts +3 -0
- package/dist/tools/findText.d.ts.map +1 -1
- package/dist/tools/findText.js +130 -16
- package/dist/tools/findText.js.map +1 -1
- package/dist/tools/readEvents.d.ts.map +1 -1
- package/dist/tools/readEvents.js +13 -3
- package/dist/tools/readEvents.js.map +1 -1
- package/dist/tools/screenDiff.d.ts.map +1 -1
- package/dist/tools/screenDiff.js +12 -5
- package/dist/tools/screenDiff.js.map +1 -1
- package/dist/tools/startRecording.js +4 -4
- package/dist/tools/startRecording.js.map +1 -1
- package/dist/tools/waitForChange.d.ts.map +1 -1
- package/dist/tools/waitForChange.js +20 -4
- package/dist/tools/waitForChange.js.map +1 -1
- package/dist/utils/events.d.ts +41 -7
- package/dist/utils/events.d.ts.map +1 -1
- package/dist/utils/events.js +143 -23
- package/dist/utils/events.js.map +1 -1
- package/dist/utils/media.d.ts +29 -3
- package/dist/utils/media.d.ts.map +1 -1
- package/dist/utils/media.js +37 -8
- package/dist/utils/media.js.map +1 -1
- package/dist/utils/ocr.d.ts +2 -0
- package/dist/utils/ocr.d.ts.map +1 -1
- package/dist/utils/ocr.js +19 -5
- package/dist/utils/ocr.js.map +1 -1
- package/dist/utils/pipeline.d.ts.map +1 -1
- package/dist/utils/pipeline.js +12 -2
- package/dist/utils/pipeline.js.map +1 -1
- package/dist/utils/retention.d.ts +10 -0
- package/dist/utils/retention.d.ts.map +1 -0
- package/dist/utils/retention.js +59 -0
- package/dist/utils/retention.js.map +1 -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, no
|
|
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 41 typed tools.
|
|
8
8
|
|
|
9
9
|
<br />
|
|
10
10
|
|
|
@@ -30,6 +30,8 @@ Capture the desktop, a monitor, a window, or a region; sample a recording into f
|
|
|
30
30
|
|
|
31
31
|
<sub>Made with the tool: <code>start_recording</code> with <code>events: true</code>, one click, then <code>zoom { highlightClicks: true }</code> and <code>export_gif</code>. <a href="https://tmhsdigital.github.io/screencast-mcp/workflows/zoom-clicks.html">How it was made</a> · <a href="https://tmhsdigital.github.io/screencast-mcp/workflows/">more workflows</a></sub>
|
|
32
32
|
|
|
33
|
+
[Quick start](#quick-start) · [Tools](#tools) · [Configuration](#configuration) · [Usage](#usage) · [Privacy](#privacy) · [Threat model](#threat-model)
|
|
34
|
+
|
|
33
35
|
</div>
|
|
34
36
|
|
|
35
37
|
## Quick start
|
|
@@ -92,7 +94,7 @@ What it can do beyond record-and-look:
|
|
|
92
94
|
| `get_session` | Inspect a single session by id. |
|
|
93
95
|
| `review_recording` | **Review player** in clients that support MCP Apps: an inline player where a person scrubs the recording, drags trim handles, and draws redaction boxes, then exports a trimmed, redacted copy (one `pipeline` call). `stop_recording` results open it too. Elsewhere it returns the video's details. |
|
|
94
96
|
| `player_frames` | Preview JPEG frames for the review player; called by the player (app-only), not by agents. |
|
|
95
|
-
| `read_events` | Read a recording's input event log (clicks, scroll, cursor,
|
|
97
|
+
| `read_events` | Read a recording's input event log (clicks, scroll, cursor, shortcuts, typing bursts) on the video's clock. Opt in with `start_recording` `events: true`. |
|
|
96
98
|
| `screenshot` | Capture a single PNG of a `target`, and return it inline as an image the model can view. |
|
|
97
99
|
| `list_audio_devices` | List the DirectShow audio devices ffmpeg can see and flag a likely system-audio loopback device for `start_recording`. |
|
|
98
100
|
|
|
@@ -104,7 +106,7 @@ What it can do beyond record-and-look:
|
|
|
104
106
|
| `contact_sheet` | Tile timestamped frames into **one** image (evenly spaced, or at the scene changes) so the agent sees a whole recording in a single look; returned inline. `poster: true` writes one representative frame instead. |
|
|
105
107
|
| `screen_diff` | Compare two screenshots/frames: SSIM score, share changed, and **bounding boxes of what changed**, with the changes outlined in an inline image. Verify a UI change happened, and only where expected. |
|
|
106
108
|
| `wait_for_change` | Watch a target and return when it **changes** (a dialog opened) or **settles** (a build or page finished), instead of guessing a sleep. Reports elapsed time, changed regions, and the final state inline. |
|
|
107
|
-
| `find_text` | **Read text** on screen or in a frame with the OCR engine built into Windows (no install): every line and match with its bounding box. Locate a button by its label, check what the screen says, or find secrets (`regex: "sk-|ghp_"`) and get `redact_region` rectangles with `redact: true
|
|
109
|
+
| `find_text` | **Read text** on screen or in a frame with the OCR engine built into Windows (no install): every line and match with its bounding box. Locate a button by its label, check what the screen says, or find secrets (`regex: "sk-|ghp_"`) and get `redact_region` rectangles with `redact: true`; `scanEverySec` checks a whole video, with a time window per match. Best-effort; review before relying on it. |
|
|
108
110
|
| `get_media_info` | ffprobe wrapper: duration, resolution, fps, codecs, container format, and size. |
|
|
109
111
|
|
|
110
112
|
### Minimal edit
|
|
@@ -143,7 +145,7 @@ These tools re-encode (a filter rewrites pixels, so stream copy does not apply).
|
|
|
143
145
|
| `redact_region` | Cover declared rectangles in a video. `style` is `box` (default, a solid irreversible fill), `blur`, or `pixelate`; each region may be limited to a `start`/`end` window and expanded with `pad`. |
|
|
144
146
|
|
|
145
147
|
> [!IMPORTANT]
|
|
146
|
-
> `redact_region` covers the regions **you** declare. It is not automatic secret detection, so it cannot find a secret you did not point it at. The default `box` style is a solid fill, which is irreversible; `blur` and `pixelate` are softer but can be partially recovered, so prefer `box` for real secrets. A region that falls outside the frame is rejected rather than silently doing nothing.
|
|
148
|
+
> `redact_region` covers the regions **you** declare. It is not automatic secret detection, so it cannot find a secret you did not point it at. The default `box` style is a solid fill, which is irreversible; `blur` and `pixelate` are softer but can be partially recovered, so prefer `box` for real secrets. They have minimum strengths: blur uses a radius of at least 8 px (or half the region's smaller side) applied three times, and pixelate uses blocks of at least 16 px. Coordinates are in the displayed frame, after any rotation the file carries, and `pipeline` refuses a `redact` placed after `zoom`. A region that falls outside the frame is rejected rather than silently doing nothing.
|
|
147
149
|
|
|
148
150
|
### Produce
|
|
149
151
|
|
|
@@ -189,6 +191,7 @@ Edit and produce tools write to a `<name>.partial.<ext>` file next to the output
|
|
|
189
191
|
| `SCREENCAST_MAX_RECORDING_SEC` | `3600` | Default recording cap (`0` disables it) |
|
|
190
192
|
| `SCREENCAST_JOB_TIMEOUT_MS` | scales with length | Override the edit job timeout |
|
|
191
193
|
| `SCREENCAST_WHISPER_MODEL` | none | whisper.cpp model for `transcribe` |
|
|
194
|
+
| `SCREENCAST_RETENTION_DAYS` | off | Delete screenshots, frames, and leftover raw event logs older than this many days at startup (never recordings or edits) |
|
|
192
195
|
| `SCREENCAST_PS_TIMEOUT_MS` | 20000 (OCR 60000) | Limit for the PowerShell helpers that list monitors and windows and run OCR |
|
|
193
196
|
| `FFMPEG_PATH` / `FFPROBE_PATH` | `PATH` lookup | Explicit ffmpeg / ffprobe binaries |
|
|
194
197
|
|
|
@@ -242,17 +245,33 @@ It also offers **resources**, so a client can list and attach recordings without
|
|
|
242
245
|
- **Fullscreen-exclusive apps** often produce black frames under `gdigrab`; run the source in borderless-windowed mode for reliable capture.
|
|
243
246
|
- **System audio needs a loopback device.** `gdigrab` is video-only, so `start_recording` with `audio.source` = `system` captures from a separate dshow input. Windows has no native loopback, so this needs a virtual-audio device (enable Stereo Mix, or install a driver such as screen-capture-recorder's `virtual-audio-capturer` or VB-CABLE). Run `list_audio_devices` to find it. Microphone capture is intentionally not supported.
|
|
244
247
|
|
|
248
|
+
## Privacy
|
|
249
|
+
|
|
250
|
+
- **The server makes no network requests and has no telemetry.** It runs ffmpeg, ffprobe, and PowerShell on your machine and talks to your MCP client over stdio.
|
|
251
|
+
- **What a tool returns goes to your model provider.** Inline screenshots and frames, OCR text, event summaries, and every other tool result reach your agent, and your client sends them to the model like any other tool result. Files on disk stay on disk unless a tool returns them or you share them.
|
|
252
|
+
- **What is stored, and where.** Everything goes under `SCREENCAST_HOME` (default `<homedir>/.screencast-mcp`) unless a call names another path:
|
|
253
|
+
- `recordings/`: recordings, plus each one's `.events.jsonl` when the event log is on
|
|
254
|
+
- `screenshots/`: `screenshot` output, and `find_text` / `wait_for_change` captures only with `keep: true`
|
|
255
|
+
- `frames/`: `sample_frames` and `contact_sheet` output
|
|
256
|
+
- `edits/`: edit and produce output
|
|
257
|
+
- `sessions.json`: the session registry (ids, targets, paths, times)
|
|
258
|
+
|
|
259
|
+
`find_text`, `wait_for_change`, and `screen_diff` delete their captures after the call by default, since a secret scan's screenshot shows the secret.
|
|
260
|
+
- **What the event log records.** Only with `start_recording` `events: true`, and only while that recording runs. Mouse input is recorded system-wide, not only over the recorded window: clicks, scrolls, and the cursor position (sampled about 30 times a second), each with its time. Typing is recorded only as bursts, a start time and a length on a 0.5 s grid, with no key names and no per-key times: `masked` (default) records nothing more. `shortcuts` also records chords made with Ctrl, Alt, or Win by name (`Ctrl+S`), with their times; Ctrl+Alt+key that types a character on AltGr layouts stays typing. No mode records typed text. If the log has gaps (Windows removed the hook, input went to an elevated window or the lock screen, or the helper stopped), `read_events` reports `truncated: true` and lists them.
|
|
261
|
+
- **Microphone capture is not supported.** System audio is recorded only with `audio.source` = `system`.
|
|
262
|
+
- **Deleting stored data.** Delete files under `SCREENCAST_HOME`, or the whole folder while nothing is recording. Set `SCREENCAST_RETENTION_DAYS` to delete screenshots, frames, and leftover raw event logs older than that each time the server starts. Recordings and edits are never deleted automatically.
|
|
263
|
+
|
|
245
264
|
## Threat model
|
|
246
265
|
|
|
247
266
|
> [!WARNING]
|
|
248
267
|
> Screen capture can record **anything** on screen at the moment of capture — passwords, tokens, private messages, and other secrets. `window:` captures the screen rectangle a window occupies, so overlays, notifications, or another window drawn over it are captured too. Treat recordings, screenshots, and sampled frames as sensitive by default.
|
|
249
268
|
|
|
250
269
|
- **Capture is always explicit.** Nothing auto-fires; capture is gated behind an explicit tool call.
|
|
251
|
-
- **
|
|
270
|
+
- **The server makes no network requests.** Files are written to the local filesystem only. What a tool returns to your agent (frames, OCR text, event summaries) is sent to your model provider like any other tool result; see [Privacy](#privacy).
|
|
252
271
|
- **Public repo, private captures.** The `.gitignore` blocks recordings, frames, screenshots, and common video/image output so test media cannot be committed by accident.
|
|
253
272
|
- **Review before sharing.** Sample frames or inspect a recording before handing a file to another tool or person, so you know what it contains. In clients that support MCP Apps, `stop_recording` and `review_recording` open an inline player where a person can scrub the whole recording and draw redaction boxes before anything leaves the machine. The player gets frames through the MCP connection; no local web server is started.
|
|
254
|
-
- **Redaction covers what you declare.** `redact_region` covers only the rectangles you specify. `find_text` can help find them: OCR with a query such as `regex: "sk-|ghp_|api.?key"` and `redact: true` returns ready-made rectangles. But OCR is best-effort; it can miss small or stylised text, so treat it as an aid, not a guarantee. Use the default `box` style for a solid irreversible fill, and still review the output before sharing.
|
|
255
|
-
- **The input event log never records what you type.** `start_recording` `events: true` hooks mouse and keyboard input for that recording only, in a helper that exits with it (or with the server).
|
|
273
|
+
- **Redaction covers what you declare.** `redact_region` covers only the rectangles you specify. `find_text` can help find them: OCR with a query such as `regex: "sk-|ghp_|api.?key"` and `redact: true` returns ready-made rectangles, and `scanEverySec` checks a whole video rather than one frame. But OCR is best-effort; it can miss small or stylised text, so treat it as an aid, not a guarantee. Use the default `box` style for a solid irreversible fill, and still review the output before sharing.
|
|
274
|
+
- **The input event log never records what you type.** `start_recording` `events: true` hooks mouse and keyboard input system-wide for that recording only, in a helper that exits with it (or with the server). Typing is logged only as bursts on a 0.5 s grid, never key by key, so the log does not reveal which keys were pressed, how many, or their timing. `keys: "shortcuts"` also names chords held with Ctrl, Alt, or Win (`Ctrl+S`). Cursor positions and clicks still reveal what you pointed at, so treat `.events.jsonl` like the recording beside it. See [Privacy](#privacy) for exactly what each mode records.
|
|
256
275
|
- **System audio is sensitive too.** When `audio.source` = `system`, the recording captures everything playing on the machine (call audio, notifications, media). Treat audio-bearing recordings with the same care as the video.
|
|
257
276
|
|
|
258
277
|
## Project structure
|
package/dist/index.js
CHANGED
|
@@ -8,104 +8,13 @@
|
|
|
8
8
|
* can contain anything on screen, including secrets. See the README threat
|
|
9
9
|
* model.
|
|
10
10
|
*/
|
|
11
|
-
import { createRequire } from "node:module";
|
|
12
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
13
11
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
14
12
|
import { getStore, isShuttingDown, markShuttingDown } from "./context.js";
|
|
15
13
|
import { requireFfmpeg } from "./utils/ffmpeg.js";
|
|
16
14
|
import { probeDuration, stopAll } from "./utils/lifecycle.js";
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
import { register as registerGetSession } from "./tools/getSession.js";
|
|
21
|
-
import { register as registerReadEvents } from "./tools/readEvents.js";
|
|
22
|
-
import { register as registerReviewRecording } from "./tools/reviewRecording.js";
|
|
23
|
-
import { register as registerScreenshot } from "./tools/screenshot.js";
|
|
24
|
-
import { register as registerSampleFrames } from "./tools/sampleFrames.js";
|
|
25
|
-
import { register as registerContactSheet } from "./tools/contactSheet.js";
|
|
26
|
-
import { register as registerScreenDiff } from "./tools/screenDiff.js";
|
|
27
|
-
import { register as registerWaitForChange } from "./tools/waitForChange.js";
|
|
28
|
-
import { register as registerFindText } from "./tools/findText.js";
|
|
29
|
-
import { register as registerGetMediaInfo } from "./tools/getMediaInfo.js";
|
|
30
|
-
import { register as registerTrim } from "./tools/trim.js";
|
|
31
|
-
import { register as registerConcat } from "./tools/concat.js";
|
|
32
|
-
import { register as registerConvert } from "./tools/convert.js";
|
|
33
|
-
import { register as registerExportGif } from "./tools/exportGif.js";
|
|
34
|
-
import { register as registerCrop } from "./tools/crop.js";
|
|
35
|
-
import { register as registerScale } from "./tools/scale.js";
|
|
36
|
-
import { register as registerSpeed } from "./tools/speed.js";
|
|
37
|
-
import { register as registerOverlay } from "./tools/overlay.js";
|
|
38
|
-
import { register as registerCallout } from "./tools/callout.js";
|
|
39
|
-
import { register as registerCompress } from "./tools/compress.js";
|
|
40
|
-
import { register as registerExtractAudio } from "./tools/extractAudio.js";
|
|
41
|
-
import { register as registerNormalizeAudio } from "./tools/normalizeAudio.js";
|
|
42
|
-
import { register as registerDenoise } from "./tools/denoise.js";
|
|
43
|
-
import { register as registerTranscribe } from "./tools/transcribe.js";
|
|
44
|
-
import { register as registerBurnSubtitles } from "./tools/burnSubtitles.js";
|
|
45
|
-
import { register as registerClip } from "./tools/clip.js";
|
|
46
|
-
import { register as registerCutIdle } from "./tools/cutIdle.js";
|
|
47
|
-
import { register as registerRedactRegion } from "./tools/redactRegion.js";
|
|
48
|
-
import { register as registerListAudioDevices } from "./tools/listAudioDevices.js";
|
|
49
|
-
import { register as registerXfadeTransition } from "./tools/xfadeTransition.js";
|
|
50
|
-
import { register as registerAssembleHighlights } from "./tools/assembleHighlights.js";
|
|
51
|
-
import { register as registerTitleCard } from "./tools/titleCard.js";
|
|
52
|
-
import { register as registerMusicBed } from "./tools/musicBed.js";
|
|
53
|
-
import { register as registerReframe } from "./tools/reframe.js";
|
|
54
|
-
import { register as registerZoom } from "./tools/zoom.js";
|
|
55
|
-
import { register as registerPipeline } from "./tools/pipeline.js";
|
|
56
|
-
import { register as registerExportPreset } from "./tools/exportPreset.js";
|
|
57
|
-
import { registerResources } from "./resources.js";
|
|
58
|
-
import { registerPrompts } from "./prompts.js";
|
|
59
|
-
// Resolves from src/ in dev and dist/ in the published package alike; keeps
|
|
60
|
-
// the advertised version from drifting from package.json (the hardcoded
|
|
61
|
-
// string here had already fallen behind twice).
|
|
62
|
-
const { version } = createRequire(import.meta.url)("../package.json");
|
|
63
|
-
const server = new McpServer({
|
|
64
|
-
name: "screencast-mcp",
|
|
65
|
-
version,
|
|
66
|
-
});
|
|
67
|
-
registerStartRecording(server);
|
|
68
|
-
registerStopRecording(server);
|
|
69
|
-
registerListSessions(server);
|
|
70
|
-
registerGetSession(server);
|
|
71
|
-
registerReadEvents(server);
|
|
72
|
-
registerReviewRecording(server);
|
|
73
|
-
registerScreenshot(server);
|
|
74
|
-
registerSampleFrames(server);
|
|
75
|
-
registerContactSheet(server);
|
|
76
|
-
registerScreenDiff(server);
|
|
77
|
-
registerWaitForChange(server);
|
|
78
|
-
registerFindText(server);
|
|
79
|
-
registerGetMediaInfo(server);
|
|
80
|
-
registerTrim(server);
|
|
81
|
-
registerConcat(server);
|
|
82
|
-
registerConvert(server);
|
|
83
|
-
registerExportGif(server);
|
|
84
|
-
registerCrop(server);
|
|
85
|
-
registerScale(server);
|
|
86
|
-
registerSpeed(server);
|
|
87
|
-
registerOverlay(server);
|
|
88
|
-
registerCallout(server);
|
|
89
|
-
registerCompress(server);
|
|
90
|
-
registerExtractAudio(server);
|
|
91
|
-
registerNormalizeAudio(server);
|
|
92
|
-
registerDenoise(server);
|
|
93
|
-
registerTranscribe(server);
|
|
94
|
-
registerBurnSubtitles(server);
|
|
95
|
-
registerClip(server);
|
|
96
|
-
registerCutIdle(server);
|
|
97
|
-
registerRedactRegion(server);
|
|
98
|
-
registerListAudioDevices(server);
|
|
99
|
-
registerXfadeTransition(server);
|
|
100
|
-
registerAssembleHighlights(server);
|
|
101
|
-
registerTitleCard(server);
|
|
102
|
-
registerMusicBed(server);
|
|
103
|
-
registerReframe(server);
|
|
104
|
-
registerZoom(server);
|
|
105
|
-
registerPipeline(server);
|
|
106
|
-
registerExportPreset(server);
|
|
107
|
-
registerResources(server);
|
|
108
|
-
registerPrompts(server);
|
|
15
|
+
import { createServer } from "./server.js";
|
|
16
|
+
import { pruneCaptures, retentionDays, RETENTION_ENV } from "./utils/retention.js";
|
|
17
|
+
const server = createServer();
|
|
109
18
|
async function main() {
|
|
110
19
|
// Reconcile any sessions interrupted by a previous crash and kill ffmpeg
|
|
111
20
|
// children that outlived the last run, so no zombie capture survives.
|
|
@@ -118,6 +27,13 @@ async function main() {
|
|
|
118
27
|
catch (err) {
|
|
119
28
|
process.stderr.write(`Orphan reaping skipped: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
120
29
|
}
|
|
30
|
+
const days = retentionDays();
|
|
31
|
+
if (days !== null) {
|
|
32
|
+
const pruned = pruneCaptures(days);
|
|
33
|
+
if (pruned.removed > 0) {
|
|
34
|
+
process.stderr.write(`Deleted ${pruned.removed} capture file(s) older than ${days} day(s) (${RETENTION_ENV}).\n`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
121
37
|
const transport = new StdioServerTransport();
|
|
122
38
|
await server.connect(transport);
|
|
123
39
|
// Without this, a client that disconnects mid-recording leaves the server
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG;AACH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa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AC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAC3E,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/prompts.js
CHANGED
|
@@ -11,7 +11,7 @@ export const PROMPT_TEXT = {
|
|
|
11
11
|
|
|
12
12
|
1. start_recording { target: "${target}", quality: "standard" }, then tell me to reproduce the bug (or reproduce it yourself if you can drive the app), and stop_recording when done.
|
|
13
13
|
2. sample_frames { input: <recording>, mode: "scenes" } to see what happened, and describe the moment the bug appears.
|
|
14
|
-
3. find_text { input: <recording>,
|
|
14
|
+
3. find_text { input: <recording>, scanEverySec: 1, query: "sk-|ghp_|api.?key|token|password", regex: true, redact: true } to check the whole clip, not one frame. If anything sensitive shows up, redact_region its redactRegions (each has its own start/end) with style "box" before sharing. OCR can miss text, so also look at the frames yourself.
|
|
15
15
|
4. trim (or clip) to the few seconds around the bug, and callout to box or point at it.
|
|
16
16
|
5. export_gif { input: <clip>, maxBytes: 10000000 } so it can be pasted into an issue or PR.
|
|
17
17
|
Report the final file path, what the clip shows, and anything you redacted.`,
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAoDpE,wBAAgB,YAAY,IAAI,SAAS,CAkDxC"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the MCP server with every tool, resource, and prompt registered, but
|
|
3
|
+
* no transport: index.ts connects it over stdio, and the tool-layer tests
|
|
4
|
+
* connect it in memory (#192).
|
|
5
|
+
*/
|
|
6
|
+
import { createRequire } from "node:module";
|
|
7
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
+
import { register as registerStartRecording } from "./tools/startRecording.js";
|
|
9
|
+
import { register as registerStopRecording } from "./tools/stopRecording.js";
|
|
10
|
+
import { register as registerListSessions } from "./tools/listSessions.js";
|
|
11
|
+
import { register as registerGetSession } from "./tools/getSession.js";
|
|
12
|
+
import { register as registerReadEvents } from "./tools/readEvents.js";
|
|
13
|
+
import { register as registerReviewRecording } from "./tools/reviewRecording.js";
|
|
14
|
+
import { register as registerScreenshot } from "./tools/screenshot.js";
|
|
15
|
+
import { register as registerSampleFrames } from "./tools/sampleFrames.js";
|
|
16
|
+
import { register as registerContactSheet } from "./tools/contactSheet.js";
|
|
17
|
+
import { register as registerScreenDiff } from "./tools/screenDiff.js";
|
|
18
|
+
import { register as registerWaitForChange } from "./tools/waitForChange.js";
|
|
19
|
+
import { register as registerFindText } from "./tools/findText.js";
|
|
20
|
+
import { register as registerGetMediaInfo } from "./tools/getMediaInfo.js";
|
|
21
|
+
import { register as registerTrim } from "./tools/trim.js";
|
|
22
|
+
import { register as registerConcat } from "./tools/concat.js";
|
|
23
|
+
import { register as registerConvert } from "./tools/convert.js";
|
|
24
|
+
import { register as registerExportGif } from "./tools/exportGif.js";
|
|
25
|
+
import { register as registerCrop } from "./tools/crop.js";
|
|
26
|
+
import { register as registerScale } from "./tools/scale.js";
|
|
27
|
+
import { register as registerSpeed } from "./tools/speed.js";
|
|
28
|
+
import { register as registerOverlay } from "./tools/overlay.js";
|
|
29
|
+
import { register as registerCallout } from "./tools/callout.js";
|
|
30
|
+
import { register as registerCompress } from "./tools/compress.js";
|
|
31
|
+
import { register as registerExtractAudio } from "./tools/extractAudio.js";
|
|
32
|
+
import { register as registerNormalizeAudio } from "./tools/normalizeAudio.js";
|
|
33
|
+
import { register as registerDenoise } from "./tools/denoise.js";
|
|
34
|
+
import { register as registerTranscribe } from "./tools/transcribe.js";
|
|
35
|
+
import { register as registerBurnSubtitles } from "./tools/burnSubtitles.js";
|
|
36
|
+
import { register as registerClip } from "./tools/clip.js";
|
|
37
|
+
import { register as registerCutIdle } from "./tools/cutIdle.js";
|
|
38
|
+
import { register as registerRedactRegion } from "./tools/redactRegion.js";
|
|
39
|
+
import { register as registerListAudioDevices } from "./tools/listAudioDevices.js";
|
|
40
|
+
import { register as registerXfadeTransition } from "./tools/xfadeTransition.js";
|
|
41
|
+
import { register as registerAssembleHighlights } from "./tools/assembleHighlights.js";
|
|
42
|
+
import { register as registerTitleCard } from "./tools/titleCard.js";
|
|
43
|
+
import { register as registerMusicBed } from "./tools/musicBed.js";
|
|
44
|
+
import { register as registerReframe } from "./tools/reframe.js";
|
|
45
|
+
import { register as registerZoom } from "./tools/zoom.js";
|
|
46
|
+
import { register as registerPipeline } from "./tools/pipeline.js";
|
|
47
|
+
import { register as registerExportPreset } from "./tools/exportPreset.js";
|
|
48
|
+
import { registerResources } from "./resources.js";
|
|
49
|
+
import { registerPrompts } from "./prompts.js";
|
|
50
|
+
// Resolves from src/ in dev and dist/ in the published package alike; keeps
|
|
51
|
+
// the advertised version from drifting from package.json (the hardcoded
|
|
52
|
+
// string here had already fallen behind twice).
|
|
53
|
+
const { version } = createRequire(import.meta.url)("../package.json");
|
|
54
|
+
export function createServer() {
|
|
55
|
+
const server = new McpServer({
|
|
56
|
+
name: "screencast-mcp",
|
|
57
|
+
version,
|
|
58
|
+
});
|
|
59
|
+
registerStartRecording(server);
|
|
60
|
+
registerStopRecording(server);
|
|
61
|
+
registerListSessions(server);
|
|
62
|
+
registerGetSession(server);
|
|
63
|
+
registerReadEvents(server);
|
|
64
|
+
registerReviewRecording(server);
|
|
65
|
+
registerScreenshot(server);
|
|
66
|
+
registerSampleFrames(server);
|
|
67
|
+
registerContactSheet(server);
|
|
68
|
+
registerScreenDiff(server);
|
|
69
|
+
registerWaitForChange(server);
|
|
70
|
+
registerFindText(server);
|
|
71
|
+
registerGetMediaInfo(server);
|
|
72
|
+
registerTrim(server);
|
|
73
|
+
registerConcat(server);
|
|
74
|
+
registerConvert(server);
|
|
75
|
+
registerExportGif(server);
|
|
76
|
+
registerCrop(server);
|
|
77
|
+
registerScale(server);
|
|
78
|
+
registerSpeed(server);
|
|
79
|
+
registerOverlay(server);
|
|
80
|
+
registerCallout(server);
|
|
81
|
+
registerCompress(server);
|
|
82
|
+
registerExtractAudio(server);
|
|
83
|
+
registerNormalizeAudio(server);
|
|
84
|
+
registerDenoise(server);
|
|
85
|
+
registerTranscribe(server);
|
|
86
|
+
registerBurnSubtitles(server);
|
|
87
|
+
registerClip(server);
|
|
88
|
+
registerCutIdle(server);
|
|
89
|
+
registerRedactRegion(server);
|
|
90
|
+
registerListAudioDevices(server);
|
|
91
|
+
registerXfadeTransition(server);
|
|
92
|
+
registerAssembleHighlights(server);
|
|
93
|
+
registerTitleCard(server);
|
|
94
|
+
registerMusicBed(server);
|
|
95
|
+
registerReframe(server);
|
|
96
|
+
registerZoom(server);
|
|
97
|
+
registerPipeline(server);
|
|
98
|
+
registerExportPreset(server);
|
|
99
|
+
registerResources(server);
|
|
100
|
+
registerPrompts(server);
|
|
101
|
+
return server;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,QAAQ,IAAI,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,QAAQ,IAAI,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,QAAQ,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,QAAQ,IAAI,uBA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AAqB,CAAC,MAAM,CAAC,CAAC;IAC9B,YAAY,CAAC,MAAM,CAAC,CAAC;IACrB,eAAe,CAAC,MAAM,CAAC,CAAC;IACxB,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC7B,wBAAwB,CAAC,MAAM,CAAC,CAAC;IACjC,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAChC,0BAA0B,CAAC,MAAM,CAAC,CAAC;IACnC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC1B,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACzB,eAAe,CAAC,MAAM,CAAC,CAAC;IACxB,YAAY,CAAC,MAAM,CAAC,CAAC;IACrB,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACzB,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC7B,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC1B,eAAe,CAAC,MAAM,CAAC,CAAC;IAExB,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/tools/findText.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
/** Default and largest frame count for a whole-clip scan (#204). */
|
|
3
|
+
export declare const DEFAULT_SCAN_FRAMES = 30;
|
|
4
|
+
export declare const MAX_SCAN_FRAMES = 120;
|
|
2
5
|
export declare function register(server: McpServer): void;
|
|
3
6
|
//# sourceMappingURL=findText.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findText.d.ts","sourceRoot":"","sources":["../../src/tools/findText.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"findText.d.ts","sourceRoot":"","sources":["../../src/tools/findText.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAczE,oEAAoE;AACpE,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO,MAAM,eAAe,MAAM,CAAC;AAuFnC,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAsFhD"}
|
package/dist/tools/findText.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { extname, join } from "node:path";
|
|
3
|
-
import { existsSync, mkdtempSync, rmSync } from "node:fs";
|
|
3
|
+
import { existsSync, mkdtempSync, readdirSync, rmSync } from "node:fs";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
6
6
|
import { requireFfmpeg, runFfmpeg, probeMedia } from "../utils/ffmpeg.js";
|
|
@@ -8,18 +8,36 @@ import { resolveCaptureTarget } from "../utils/resolveTarget.js";
|
|
|
8
8
|
import { captureStill } from "../utils/still.js";
|
|
9
9
|
import { buildHighlightArgs, targetSize } from "../utils/diff.js";
|
|
10
10
|
import { recognize, mergePasses, findMatches, redactionRects, passScales } from "../utils/ocr.js";
|
|
11
|
+
import { buildSampleByFpsArgs, planFpsSampling } from "../utils/media.js";
|
|
11
12
|
import { windowMatchReport } from "../utils/windows.js";
|
|
12
13
|
import { subdir, stamp, rand, stillOutput } from "../utils/paths.js";
|
|
13
14
|
import { encodeInlineImages, DEFAULT_MAX_IMAGE_WIDTH } from "../utils/images.js";
|
|
14
15
|
const IMAGE_EXTENSIONS = new Set([".png", ".jpg", ".jpeg", ".bmp", ".gif", ".webp", ".tif", ".tiff"]);
|
|
15
16
|
const MAX_LINES = 300;
|
|
17
|
+
/** Default and largest frame count for a whole-clip scan (#204). */
|
|
18
|
+
export const DEFAULT_SCAN_FRAMES = 30;
|
|
19
|
+
export const MAX_SCAN_FRAMES = 120;
|
|
16
20
|
const inputSchema = {
|
|
17
21
|
target: z
|
|
18
22
|
.string()
|
|
19
23
|
.optional()
|
|
20
24
|
.describe("Read text live from the screen: 'full' | 'monitor:<index>' | 'window:<title>' (or window:exe=<app.exe> / window:hwnd=<handle>) | 'region:...'."),
|
|
21
25
|
input: z.string().optional().describe("Or read text from an image or video file (one of target / input)."),
|
|
22
|
-
timestamp: z.number().nonnegative().optional().describe("For a video input: the second to read (default 0)."),
|
|
26
|
+
timestamp: z.number().nonnegative().optional().describe("For a video input: the second to read (default 0). Ignored with scanEverySec."),
|
|
27
|
+
scanEverySec: z
|
|
28
|
+
.number()
|
|
29
|
+
.positive()
|
|
30
|
+
.optional()
|
|
31
|
+
.describe("For a video input: read a frame every N seconds across the whole clip instead of one frame, so " +
|
|
32
|
+
"text shown at any moment is found (use it to check a clip for secrets before sharing). Each match " +
|
|
33
|
+
"gets its time, and redactRegions get start/end. The interval widens to stay within maxFrames."),
|
|
34
|
+
maxFrames: z
|
|
35
|
+
.number()
|
|
36
|
+
.int()
|
|
37
|
+
.min(1)
|
|
38
|
+
.max(MAX_SCAN_FRAMES)
|
|
39
|
+
.optional()
|
|
40
|
+
.describe(`With scanEverySec: most frames to read (default ${DEFAULT_SCAN_FRAMES}); each takes about a second.`),
|
|
23
41
|
exactTitle: z.boolean().optional().describe("For window: targets, match the title exactly (default false)."),
|
|
24
42
|
backend: z
|
|
25
43
|
.enum(["gdigrab", "wgc"])
|
|
@@ -30,24 +48,56 @@ const inputSchema = {
|
|
|
30
48
|
.string()
|
|
31
49
|
.optional()
|
|
32
50
|
.describe("Text to look for. Case-insensitive, and tolerant of common OCR misreads (_ vs -, I vs l, " +
|
|
33
|
-
"O vs 0). Without a query, all recognised text is returned."),
|
|
51
|
+
"O vs 0; regexes get the _ vs - tolerance). Without a query, all recognised text is returned."),
|
|
34
52
|
regex: z.boolean().optional().describe("Treat query as a regular expression (case-insensitive)."),
|
|
35
53
|
redact: z
|
|
36
54
|
.boolean()
|
|
37
55
|
.optional()
|
|
38
56
|
.describe("Also return padded rectangles around each match, ready to pass to redact_region " +
|
|
39
57
|
"(regions) to cover them. Detection is best-effort: review the result."),
|
|
58
|
+
keep: z
|
|
59
|
+
.boolean()
|
|
60
|
+
.optional()
|
|
61
|
+
.describe("For a live target: keep the captured screenshot and return its path (default false: it is " +
|
|
62
|
+
"deleted after reading, since it may show the secrets being looked for)."),
|
|
40
63
|
returnImage: z
|
|
41
64
|
.boolean()
|
|
42
65
|
.optional()
|
|
43
66
|
.describe("Return the image inline with matches outlined in red (default true when there is a query)."),
|
|
44
67
|
};
|
|
68
|
+
/** OCR several frames in one PowerShell run: each frame is upscaled for every
|
|
69
|
+
* pass (passScales), and the passes are merged back per frame. */
|
|
70
|
+
async function readFrames(sources, work) {
|
|
71
|
+
const sized = await Promise.all(sources.map((s) => probeMedia(s)));
|
|
72
|
+
const passes = [];
|
|
73
|
+
const passScaleList = [];
|
|
74
|
+
const owner = [];
|
|
75
|
+
for (let f = 0; f < sources.length; f++) {
|
|
76
|
+
const { width, height } = sized[f];
|
|
77
|
+
if (!width || !height)
|
|
78
|
+
throw new ScreencastError("Could not read the image size.");
|
|
79
|
+
for (const [i, scale] of passScales(width, height).entries()) {
|
|
80
|
+
const out = join(work, `pass${f}-${i}.png`);
|
|
81
|
+
await runFfmpeg(["-y", "-v", "error", "-i", sources[f], "-vf", `scale=iw*${scale}:ih*${scale}:flags=lanczos`, out], 60_000);
|
|
82
|
+
passes.push(out);
|
|
83
|
+
passScaleList.push(scale);
|
|
84
|
+
owner.push(f);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const results = await recognize(passes, passScaleList);
|
|
88
|
+
return sources.map((_, f) => ({
|
|
89
|
+
lines: mergePasses(results.filter((_r, i) => owner[i] === f)),
|
|
90
|
+
width: sized[f].width,
|
|
91
|
+
height: sized[f].height,
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
45
94
|
export function register(server) {
|
|
46
95
|
server.tool("find_text", "Read text on screen or in an image/video frame with the OCR engine built into Windows " +
|
|
47
96
|
"(no install), with each line's and match's bounding box. Find where a label or button " +
|
|
48
97
|
"is, check what the screen says, or locate secrets (e.g. regex 'sk-|ghp_|api.?key') and get " +
|
|
49
|
-
"redact_region rectangles for them
|
|
50
|
-
"`origin` for desktop coordinates. Best-effort
|
|
98
|
+
"redact_region rectangles for them; for a video, scanEverySec checks the whole clip. Boxes are " +
|
|
99
|
+
"in the image's pixels; for a live target, add `origin` for desktop coordinates. Best-effort " +
|
|
100
|
+
"detection: always review.", inputSchema, async (args) => {
|
|
51
101
|
try {
|
|
52
102
|
requireFfmpeg();
|
|
53
103
|
if ((args.target === undefined) === (args.input === undefined)) {
|
|
@@ -55,13 +105,16 @@ export function register(server) {
|
|
|
55
105
|
}
|
|
56
106
|
const work = mkdtempSync(join(tmpdir(), "screencast-ocr-"));
|
|
57
107
|
try {
|
|
108
|
+
if (args.scanEverySec !== undefined)
|
|
109
|
+
return await scanClip(args, work);
|
|
58
110
|
// 1. Get the source as one PNG frame.
|
|
59
111
|
let source;
|
|
60
112
|
let windowReport = {};
|
|
61
113
|
let origin;
|
|
62
114
|
if (args.target !== undefined) {
|
|
63
115
|
const resolved = await resolveCaptureTarget(args.target, { exactTitle: args.exactTitle, backend: args.backend });
|
|
64
|
-
|
|
116
|
+
// Captures go to the work dir and vanish with it unless kept (#209).
|
|
117
|
+
source = args.keep ? join(subdir("screenshots"), `ocr-${stamp()}-${rand()}.png`) : join(work, "capture.png");
|
|
65
118
|
const backend = args.backend ?? "gdigrab";
|
|
66
119
|
await captureStill(resolved, source, backend);
|
|
67
120
|
if (resolved.window)
|
|
@@ -78,16 +131,8 @@ export function register(server) {
|
|
|
78
131
|
source = join(work, "frame.png");
|
|
79
132
|
await runFfmpeg(["-y", "-v", "error", ...(isImage ? [] : ["-ss", String(args.timestamp ?? 0)]), "-i", args.input, "-frames:v", "1", ...stillOutput(source)], 60_000);
|
|
80
133
|
}
|
|
81
|
-
const { width, height } = await probeMedia(source);
|
|
82
|
-
if (!width || !height)
|
|
83
|
-
throw new ScreencastError("Could not read the image size.");
|
|
84
134
|
// 2. Upscaled copies for each recognition pass, then OCR them in one run.
|
|
85
|
-
const
|
|
86
|
-
const passes = scales.map((s, i) => join(work, `pass${i}.png`));
|
|
87
|
-
for (let i = 0; i < scales.length; i++) {
|
|
88
|
-
await runFfmpeg(["-y", "-v", "error", "-i", source, "-vf", `scale=iw*${scales[i]}:ih*${scales[i]}:flags=lanczos`, passes[i]], 60_000);
|
|
89
|
-
}
|
|
90
|
-
const lines = mergePasses(await recognize(passes, scales));
|
|
135
|
+
const [{ lines, width, height }] = await readFrames([source], work);
|
|
91
136
|
// 3. Match, and optionally outline / suggest redactions.
|
|
92
137
|
const matches = args.query ? findMatches(lines, args.query, args.regex === true) : [];
|
|
93
138
|
const images = [];
|
|
@@ -98,7 +143,7 @@ export function register(server) {
|
|
|
98
143
|
images.push(...(await encodeInlineImages([shown], DEFAULT_MAX_IMAGE_WIDTH, 1)).images);
|
|
99
144
|
}
|
|
100
145
|
return okResponse({
|
|
101
|
-
...(args.target !== undefined ? { screenshotPath: source } : { input: args.input }),
|
|
146
|
+
...(args.target !== undefined ? (args.keep ? { screenshotPath: source } : {}) : { input: args.input }),
|
|
102
147
|
imageSize: { width, height },
|
|
103
148
|
...(origin ? { origin } : {}),
|
|
104
149
|
...(args.query
|
|
@@ -125,4 +170,73 @@ export function register(server) {
|
|
|
125
170
|
}
|
|
126
171
|
});
|
|
127
172
|
}
|
|
173
|
+
/** Whole-clip scan (#204): OCR a frame every scanEverySec seconds (widened to
|
|
174
|
+
* fit maxFrames) and report each match with its time. A redaction window runs
|
|
175
|
+
* from the previous sample to the next, since the text may be on screen for
|
|
176
|
+
* any part of the time between two samples. */
|
|
177
|
+
async function scanClip(args, work) {
|
|
178
|
+
if (args.input === undefined)
|
|
179
|
+
throw new ScreencastError("scanEverySec reads a video file: pass input, not target.");
|
|
180
|
+
if (!existsSync(args.input))
|
|
181
|
+
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
182
|
+
if (IMAGE_EXTENSIONS.has(extname(args.input).toLowerCase())) {
|
|
183
|
+
throw new ScreencastError("scanEverySec is for a video input; an image has one frame, so drop scanEverySec.");
|
|
184
|
+
}
|
|
185
|
+
const info = await probeMedia(args.input);
|
|
186
|
+
const maxFrames = args.maxFrames ?? DEFAULT_SCAN_FRAMES;
|
|
187
|
+
const plan = planFpsSampling(info.videoDurationSec ?? info.durationSec, 1 / args.scanEverySec, maxFrames);
|
|
188
|
+
await runFfmpeg(buildSampleByFpsArgs(args.input, plan.fps, join(work, "scan_%05d.png"), maxFrames), 10 * 60_000);
|
|
189
|
+
const frames = readdirSync(work).filter((f) => f.startsWith("scan_")).sort().map((f) => join(work, f));
|
|
190
|
+
if (frames.length === 0)
|
|
191
|
+
throw new ScreencastError("Could not read any frames from the video.");
|
|
192
|
+
const step = 1 / plan.fps;
|
|
193
|
+
const times = frames.map((_, i) => Math.round(i * step * 1000) / 1000);
|
|
194
|
+
const end = info.videoDurationSec ?? info.durationSec ?? times[times.length - 1] + step;
|
|
195
|
+
const read = await readFrames(frames, work);
|
|
196
|
+
const matches = [];
|
|
197
|
+
const redactRegions = [];
|
|
198
|
+
const seenLines = new Set();
|
|
199
|
+
read.forEach((frame, i) => {
|
|
200
|
+
for (const l of frame.lines)
|
|
201
|
+
seenLines.add(l.text);
|
|
202
|
+
if (!args.query)
|
|
203
|
+
return;
|
|
204
|
+
const hits = findMatches(frame.lines, args.query, args.regex === true);
|
|
205
|
+
const start = Math.max(0, Math.round((times[i] - step) * 1000) / 1000);
|
|
206
|
+
const stop = Math.min(end, Math.round((times[i] + step) * 1000) / 1000);
|
|
207
|
+
for (const [k, rect] of redactionRects(hits, frame).entries()) {
|
|
208
|
+
matches.push({ t: times[i], ...hits[k] });
|
|
209
|
+
redactRegions.push({ ...rect, start, end: stop });
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
const images = [];
|
|
213
|
+
const first = matches[0];
|
|
214
|
+
if ((args.returnImage ?? Boolean(args.query)) && first) {
|
|
215
|
+
const i = times.indexOf(first.t);
|
|
216
|
+
const shown = join(work, "shown.png");
|
|
217
|
+
await runFfmpeg(buildHighlightArgs(frames[i], matches.filter((m) => m.t === first.t), shown), 30_000);
|
|
218
|
+
images.push(...(await encodeInlineImages([shown], DEFAULT_MAX_IMAGE_WIDTH, 1)).images);
|
|
219
|
+
}
|
|
220
|
+
const text = [...seenLines].join("\n");
|
|
221
|
+
return okResponse({
|
|
222
|
+
input: args.input,
|
|
223
|
+
imageSize: { width: read[0].width, height: read[0].height },
|
|
224
|
+
scan: {
|
|
225
|
+
everySec: Math.round(step * 1000) / 1000,
|
|
226
|
+
framesScanned: frames.length,
|
|
227
|
+
...(plan.clamped ? { note: `Widened from ${args.scanEverySec} s to fit maxFrames ${maxFrames}.` } : {}),
|
|
228
|
+
},
|
|
229
|
+
...(args.query
|
|
230
|
+
? {
|
|
231
|
+
query: args.query,
|
|
232
|
+
matchCount: matches.length,
|
|
233
|
+
matches: matches.slice(0, MAX_LINES),
|
|
234
|
+
...(args.redact ? { redactRegions } : {}),
|
|
235
|
+
}
|
|
236
|
+
: {}),
|
|
237
|
+
text: text.length > 20_000 ? `${text.slice(0, 20_000)}...` : text,
|
|
238
|
+
note: "OCR is best-effort and reads only the sampled frames: text shown briefly between samples, or small " +
|
|
239
|
+
"or stylised text, can be missed. Review before sharing, especially for redaction.",
|
|
240
|
+
}, images);
|
|
241
|
+
}
|
|
128
242
|
//# sourceMappingURL=findText.js.map
|