@tmhs/screencast-mcp 0.39.0 → 0.44.2
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 +58 -14
- package/assets/icon.png +0 -0
- package/assets/ui/player.html +38 -302
- package/assets/ui/player.js +382 -0
- package/dist/context.js +0 -5
- package/dist/index.js +5 -21
- package/dist/prompts.js +0 -7
- package/dist/resources.js +2 -14
- package/dist/server.js +37 -11
- package/dist/tools/assembleHighlights.js +12 -7
- package/dist/tools/burnSubtitles.js +12 -6
- package/dist/tools/callout.js +32 -16
- package/dist/tools/clip.js +12 -9
- package/dist/tools/compress.js +10 -5
- package/dist/tools/concat.js +16 -15
- package/dist/tools/contactSheet.js +26 -22
- package/dist/tools/convert.js +12 -6
- package/dist/tools/crop.js +12 -7
- package/dist/tools/cutIdle.js +15 -9
- package/dist/tools/denoise.js +12 -6
- package/dist/tools/doctor.js +133 -0
- package/dist/tools/exportGif.js +14 -10
- package/dist/tools/exportPreset.js +11 -8
- package/dist/tools/extractAudio.js +10 -8
- package/dist/tools/findText.js +69 -65
- package/dist/tools/getMediaInfo.js +17 -3
- package/dist/tools/getSession.js +15 -3
- package/dist/tools/listAudioDevices.js +14 -7
- package/dist/tools/listSessions.js +13 -3
- package/dist/tools/listTargets.js +76 -0
- package/dist/tools/musicBed.js +14 -10
- package/dist/tools/normalizeAudio.js +12 -8
- package/dist/tools/overlay.js +16 -12
- package/dist/tools/pipeline.js +31 -22
- package/dist/tools/readEvents.js +21 -12
- package/dist/tools/redactRegion.js +19 -17
- package/dist/tools/reframe.js +9 -5
- package/dist/tools/reviewRecording.js +63 -22
- package/dist/tools/sampleFrames.js +33 -40
- package/dist/tools/scale.js +9 -3
- package/dist/tools/screenDiff.js +23 -17
- package/dist/tools/screenshot.js +21 -17
- package/dist/tools/speed.js +15 -4
- package/dist/tools/startRecording.js +48 -52
- package/dist/tools/stopRecording.js +10 -9
- package/dist/tools/titleCard.js +19 -11
- package/dist/tools/transcribe.js +13 -7
- package/dist/tools/trim.js +11 -10
- package/dist/tools/waitForChange.js +37 -22
- package/dist/tools/xfadeTransition.js +12 -8
- package/dist/tools/zoom.js +26 -29
- package/dist/utils/anim.js +1 -21
- package/dist/utils/animExport.js +5 -10
- package/dist/utils/audio.js +4 -33
- package/dist/utils/audioDevices.js +1 -48
- package/dist/utils/callout.js +1 -19
- package/dist/utils/calloutAssets.js +21 -11
- package/dist/utils/capabilities.js +95 -0
- package/dist/utils/captions.js +9 -26
- package/dist/utils/consent.js +29 -0
- package/dist/utils/diff.js +0 -46
- package/dist/utils/errors.js +5 -13
- package/dist/utils/events.js +21 -77
- package/dist/utils/expr.js +11 -0
- package/dist/utils/ffmpeg.js +119 -48
- package/dist/utils/fontCoverage.js +177 -0
- package/dist/utils/fonts.js +139 -23
- package/dist/utils/idle.js +12 -24
- package/dist/utils/images.js +0 -17
- package/dist/utils/jobs.js +42 -41
- package/dist/utils/lifecycle.js +0 -29
- package/dist/utils/logging.js +75 -0
- package/dist/utils/media.js +11 -122
- package/dist/utils/monitors.js +7 -43
- package/dist/utils/ocr.js +53 -71
- package/dist/utils/paths.js +68 -31
- package/dist/utils/pipeline.js +0 -23
- package/dist/utils/player.js +50 -27
- package/dist/utils/produce.js +6 -66
- package/dist/utils/resolveTarget.js +0 -19
- package/dist/utils/retention.js +1 -15
- package/dist/utils/roots.js +42 -0
- package/dist/utils/sessions.js +195 -160
- package/dist/utils/sheet.js +0 -19
- package/dist/utils/still.js +0 -15
- package/dist/utils/targetList.js +63 -0
- package/dist/utils/targets.js +5 -70
- package/dist/utils/toolSpec.js +25 -0
- package/dist/utils/toolsets.js +102 -0
- package/dist/utils/validate.js +0 -22
- package/dist/utils/wgc.js +0 -46
- package/dist/utils/windows.js +5 -50
- package/dist/utils/zoom.js +55 -85
- package/dist/wgcRecorder.js +1 -30
- package/package.json +7 -3
- package/dist/context.d.ts +0 -9
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/prompts.d.ts +0 -10
- package/dist/prompts.d.ts.map +0 -1
- package/dist/prompts.js.map +0 -1
- package/dist/resources.d.ts +0 -3
- package/dist/resources.d.ts.map +0 -1
- package/dist/resources.js.map +0 -1
- package/dist/server.d.ts +0 -3
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/tools/assembleHighlights.d.ts +0 -3
- package/dist/tools/assembleHighlights.d.ts.map +0 -1
- package/dist/tools/assembleHighlights.js.map +0 -1
- package/dist/tools/burnSubtitles.d.ts +0 -3
- package/dist/tools/burnSubtitles.d.ts.map +0 -1
- package/dist/tools/burnSubtitles.js.map +0 -1
- package/dist/tools/callout.d.ts +0 -37
- package/dist/tools/callout.d.ts.map +0 -1
- package/dist/tools/callout.js.map +0 -1
- package/dist/tools/clip.d.ts +0 -3
- package/dist/tools/clip.d.ts.map +0 -1
- package/dist/tools/clip.js.map +0 -1
- package/dist/tools/compress.d.ts +0 -3
- package/dist/tools/compress.d.ts.map +0 -1
- package/dist/tools/compress.js.map +0 -1
- package/dist/tools/concat.d.ts +0 -3
- package/dist/tools/concat.d.ts.map +0 -1
- package/dist/tools/concat.js.map +0 -1
- package/dist/tools/contactSheet.d.ts +0 -3
- package/dist/tools/contactSheet.d.ts.map +0 -1
- package/dist/tools/contactSheet.js.map +0 -1
- package/dist/tools/convert.d.ts +0 -3
- package/dist/tools/convert.d.ts.map +0 -1
- package/dist/tools/convert.js.map +0 -1
- package/dist/tools/crop.d.ts +0 -3
- package/dist/tools/crop.d.ts.map +0 -1
- package/dist/tools/crop.js.map +0 -1
- package/dist/tools/cutIdle.d.ts +0 -3
- package/dist/tools/cutIdle.d.ts.map +0 -1
- package/dist/tools/cutIdle.js.map +0 -1
- package/dist/tools/denoise.d.ts +0 -3
- package/dist/tools/denoise.d.ts.map +0 -1
- package/dist/tools/denoise.js.map +0 -1
- package/dist/tools/exportGif.d.ts +0 -3
- package/dist/tools/exportGif.d.ts.map +0 -1
- package/dist/tools/exportGif.js.map +0 -1
- package/dist/tools/exportPreset.d.ts +0 -3
- package/dist/tools/exportPreset.d.ts.map +0 -1
- package/dist/tools/exportPreset.js.map +0 -1
- package/dist/tools/extractAudio.d.ts +0 -3
- package/dist/tools/extractAudio.d.ts.map +0 -1
- package/dist/tools/extractAudio.js.map +0 -1
- package/dist/tools/findText.d.ts +0 -6
- package/dist/tools/findText.d.ts.map +0 -1
- package/dist/tools/findText.js.map +0 -1
- package/dist/tools/getMediaInfo.d.ts +0 -3
- package/dist/tools/getMediaInfo.d.ts.map +0 -1
- package/dist/tools/getMediaInfo.js.map +0 -1
- package/dist/tools/getSession.d.ts +0 -3
- package/dist/tools/getSession.d.ts.map +0 -1
- package/dist/tools/getSession.js.map +0 -1
- package/dist/tools/listAudioDevices.d.ts +0 -3
- package/dist/tools/listAudioDevices.d.ts.map +0 -1
- package/dist/tools/listAudioDevices.js.map +0 -1
- package/dist/tools/listSessions.d.ts +0 -3
- package/dist/tools/listSessions.d.ts.map +0 -1
- package/dist/tools/listSessions.js.map +0 -1
- package/dist/tools/musicBed.d.ts +0 -3
- package/dist/tools/musicBed.d.ts.map +0 -1
- package/dist/tools/musicBed.js.map +0 -1
- package/dist/tools/normalizeAudio.d.ts +0 -3
- package/dist/tools/normalizeAudio.d.ts.map +0 -1
- package/dist/tools/normalizeAudio.js.map +0 -1
- package/dist/tools/overlay.d.ts +0 -3
- package/dist/tools/overlay.d.ts.map +0 -1
- package/dist/tools/overlay.js.map +0 -1
- package/dist/tools/pipeline.d.ts +0 -3
- package/dist/tools/pipeline.d.ts.map +0 -1
- package/dist/tools/pipeline.js.map +0 -1
- package/dist/tools/readEvents.d.ts +0 -6
- package/dist/tools/readEvents.d.ts.map +0 -1
- package/dist/tools/readEvents.js.map +0 -1
- package/dist/tools/redactRegion.d.ts +0 -13
- package/dist/tools/redactRegion.d.ts.map +0 -1
- package/dist/tools/redactRegion.js.map +0 -1
- package/dist/tools/reframe.d.ts +0 -3
- package/dist/tools/reframe.d.ts.map +0 -1
- package/dist/tools/reframe.js.map +0 -1
- package/dist/tools/reviewRecording.d.ts +0 -5
- package/dist/tools/reviewRecording.d.ts.map +0 -1
- package/dist/tools/reviewRecording.js.map +0 -1
- package/dist/tools/sampleFrames.d.ts +0 -3
- package/dist/tools/sampleFrames.d.ts.map +0 -1
- package/dist/tools/sampleFrames.js.map +0 -1
- package/dist/tools/scale.d.ts +0 -3
- package/dist/tools/scale.d.ts.map +0 -1
- package/dist/tools/scale.js.map +0 -1
- package/dist/tools/screenDiff.d.ts +0 -3
- package/dist/tools/screenDiff.d.ts.map +0 -1
- package/dist/tools/screenDiff.js.map +0 -1
- package/dist/tools/screenshot.d.ts +0 -3
- package/dist/tools/screenshot.d.ts.map +0 -1
- package/dist/tools/screenshot.js.map +0 -1
- package/dist/tools/speed.d.ts +0 -3
- package/dist/tools/speed.d.ts.map +0 -1
- package/dist/tools/speed.js.map +0 -1
- package/dist/tools/startRecording.d.ts +0 -3
- package/dist/tools/startRecording.d.ts.map +0 -1
- package/dist/tools/startRecording.js.map +0 -1
- package/dist/tools/stopRecording.d.ts +0 -3
- package/dist/tools/stopRecording.d.ts.map +0 -1
- package/dist/tools/stopRecording.js.map +0 -1
- package/dist/tools/titleCard.d.ts +0 -3
- package/dist/tools/titleCard.d.ts.map +0 -1
- package/dist/tools/titleCard.js.map +0 -1
- package/dist/tools/transcribe.d.ts +0 -3
- package/dist/tools/transcribe.d.ts.map +0 -1
- package/dist/tools/transcribe.js.map +0 -1
- package/dist/tools/trim.d.ts +0 -3
- package/dist/tools/trim.d.ts.map +0 -1
- package/dist/tools/trim.js.map +0 -1
- package/dist/tools/waitForChange.d.ts +0 -3
- package/dist/tools/waitForChange.d.ts.map +0 -1
- package/dist/tools/waitForChange.js.map +0 -1
- package/dist/tools/xfadeTransition.d.ts +0 -3
- package/dist/tools/xfadeTransition.d.ts.map +0 -1
- package/dist/tools/xfadeTransition.js.map +0 -1
- package/dist/tools/zoom.d.ts +0 -15
- package/dist/tools/zoom.d.ts.map +0 -1
- package/dist/tools/zoom.js.map +0 -1
- package/dist/utils/anim.d.ts +0 -33
- package/dist/utils/anim.d.ts.map +0 -1
- package/dist/utils/anim.js.map +0 -1
- package/dist/utils/animExport.d.ts +0 -27
- package/dist/utils/animExport.d.ts.map +0 -1
- package/dist/utils/animExport.js.map +0 -1
- package/dist/utils/audio.d.ts +0 -49
- package/dist/utils/audio.d.ts.map +0 -1
- package/dist/utils/audio.js.map +0 -1
- package/dist/utils/audioDevices.d.ts +0 -33
- package/dist/utils/audioDevices.d.ts.map +0 -1
- package/dist/utils/audioDevices.js.map +0 -1
- package/dist/utils/callout.d.ts +0 -72
- package/dist/utils/callout.d.ts.map +0 -1
- package/dist/utils/callout.js.map +0 -1
- package/dist/utils/calloutAssets.d.ts +0 -3
- package/dist/utils/calloutAssets.d.ts.map +0 -1
- package/dist/utils/calloutAssets.js.map +0 -1
- package/dist/utils/captions.d.ts +0 -26
- package/dist/utils/captions.d.ts.map +0 -1
- package/dist/utils/captions.js.map +0 -1
- package/dist/utils/diff.d.ts +0 -112
- package/dist/utils/diff.d.ts.map +0 -1
- package/dist/utils/diff.js.map +0 -1
- package/dist/utils/errors.d.ts +0 -33
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/events.d.ts +0 -143
- package/dist/utils/events.d.ts.map +0 -1
- package/dist/utils/events.js.map +0 -1
- package/dist/utils/ffmpeg.d.ts +0 -50
- package/dist/utils/ffmpeg.d.ts.map +0 -1
- package/dist/utils/ffmpeg.js.map +0 -1
- package/dist/utils/fonts.d.ts +0 -17
- package/dist/utils/fonts.d.ts.map +0 -1
- package/dist/utils/fonts.js.map +0 -1
- package/dist/utils/idle.d.ts +0 -23
- package/dist/utils/idle.d.ts.map +0 -1
- package/dist/utils/idle.js.map +0 -1
- package/dist/utils/images.d.ts +0 -21
- package/dist/utils/images.d.ts.map +0 -1
- package/dist/utils/images.js.map +0 -1
- package/dist/utils/jobs.d.ts +0 -44
- package/dist/utils/jobs.d.ts.map +0 -1
- package/dist/utils/jobs.js.map +0 -1
- package/dist/utils/lifecycle.d.ts +0 -29
- package/dist/utils/lifecycle.d.ts.map +0 -1
- package/dist/utils/lifecycle.js.map +0 -1
- package/dist/utils/media.d.ts +0 -272
- package/dist/utils/media.d.ts.map +0 -1
- package/dist/utils/media.js.map +0 -1
- package/dist/utils/monitors.d.ts +0 -47
- package/dist/utils/monitors.d.ts.map +0 -1
- package/dist/utils/monitors.js.map +0 -1
- package/dist/utils/ocr.d.ts +0 -50
- package/dist/utils/ocr.d.ts.map +0 -1
- package/dist/utils/ocr.js.map +0 -1
- package/dist/utils/paths.d.ts +0 -28
- package/dist/utils/paths.d.ts.map +0 -1
- package/dist/utils/paths.js.map +0 -1
- package/dist/utils/pipeline.d.ts +0 -69
- package/dist/utils/pipeline.d.ts.map +0 -1
- package/dist/utils/pipeline.js.map +0 -1
- package/dist/utils/player.d.ts +0 -30
- package/dist/utils/player.d.ts.map +0 -1
- package/dist/utils/player.js.map +0 -1
- package/dist/utils/produce.d.ts +0 -126
- package/dist/utils/produce.d.ts.map +0 -1
- package/dist/utils/produce.js.map +0 -1
- package/dist/utils/resolveTarget.d.ts +0 -32
- package/dist/utils/resolveTarget.d.ts.map +0 -1
- package/dist/utils/resolveTarget.js.map +0 -1
- package/dist/utils/retention.d.ts +0 -10
- package/dist/utils/retention.d.ts.map +0 -1
- package/dist/utils/retention.js.map +0 -1
- package/dist/utils/sessions.d.ts +0 -154
- package/dist/utils/sessions.d.ts.map +0 -1
- package/dist/utils/sessions.js.map +0 -1
- package/dist/utils/sheet.d.ts +0 -26
- package/dist/utils/sheet.d.ts.map +0 -1
- package/dist/utils/sheet.js.map +0 -1
- package/dist/utils/still.d.ts +0 -7
- package/dist/utils/still.d.ts.map +0 -1
- package/dist/utils/still.js.map +0 -1
- package/dist/utils/targets.d.ts +0 -113
- package/dist/utils/targets.d.ts.map +0 -1
- package/dist/utils/targets.js.map +0 -1
- package/dist/utils/validate.d.ts +0 -15
- package/dist/utils/validate.d.ts.map +0 -1
- package/dist/utils/validate.js.map +0 -1
- package/dist/utils/wgc.d.ts +0 -46
- package/dist/utils/wgc.d.ts.map +0 -1
- package/dist/utils/wgc.js.map +0 -1
- package/dist/utils/windows.d.ts +0 -94
- package/dist/utils/windows.d.ts.map +0 -1
- package/dist/utils/windows.js.map +0 -1
- package/dist/utils/zoom.d.ts +0 -95
- package/dist/utils/zoom.d.ts.map +0 -1
- package/dist/utils/zoom.js.map +0 -1
- package/dist/wgcRecorder.d.ts +0 -2
- package/dist/wgcRecorder.d.ts.map +0 -1
- package/dist/wgcRecorder.js.map +0 -1
package/dist/tools/denoise.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
+
import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
|
|
4
5
|
import { requireFfmpeg, runCapture, probeMedia } from "../utils/ffmpeg.js";
|
|
5
6
|
import { runEditJob, jobTimeoutMs } from "../utils/jobs.js";
|
|
6
7
|
import { buildDenoiseArgs, buildNoiseFloorArgs, parseNoiseFloor } from "../utils/audio.js";
|
|
@@ -16,8 +17,14 @@ const inputSchema = {
|
|
|
16
17
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
17
18
|
};
|
|
18
19
|
export function register(server) {
|
|
19
|
-
server.
|
|
20
|
-
"
|
|
20
|
+
server.registerTool("denoise", {
|
|
21
|
+
title: "Denoise Audio",
|
|
22
|
+
description: "Reduce steady background noise (fan, hum, hiss) in a recording's audio with an " +
|
|
23
|
+
"adaptive FFT denoiser. Video is copied untouched. Returns the output path.",
|
|
24
|
+
inputSchema,
|
|
25
|
+
outputSchema: OUTPUT_PATH,
|
|
26
|
+
annotations: WRITES_FILE,
|
|
27
|
+
}, async (args, extra) => {
|
|
21
28
|
try {
|
|
22
29
|
requireFfmpeg();
|
|
23
30
|
if (!existsSync(args.input)) {
|
|
@@ -30,9 +37,9 @@ export function register(server) {
|
|
|
30
37
|
assertEditContainer(args.output);
|
|
31
38
|
const ext = editOutputExt(args.input, { audio: true });
|
|
32
39
|
const output = resolveOutput(args.output, subdir("edits"), `denoise-${stamp()}-${rand()}${ext}`, args.overwrite);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
40
|
+
const scan = await runCapture(requireFfmpeg().ffmpeg, buildNoiseFloorArgs(args.input), jobTimeoutMs(info.durationSec), {
|
|
41
|
+
signal: extra.signal,
|
|
42
|
+
});
|
|
36
43
|
const floor = parseNoiseFloor(scan.stdout);
|
|
37
44
|
await runEditJob(buildDenoiseArgs(args.input, output, strength, floor), {
|
|
38
45
|
output,
|
|
@@ -51,4 +58,3 @@ export function register(server) {
|
|
|
51
58
|
}
|
|
52
59
|
});
|
|
53
60
|
}
|
|
54
|
-
//# sourceMappingURL=denoise.js.map
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { errorResponse, okResponse } from "../utils/errors.js";
|
|
6
|
+
import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
|
|
7
|
+
import { detectFfmpeg, hasFilter, wgcAvailable } from "../utils/ffmpeg.js";
|
|
8
|
+
import { allowedOutputDirs, envAllowedDirs, homeRoot } from "../utils/paths.js";
|
|
9
|
+
import { FFMPEG_FEATURE_MAJOR, KEY_FILTERS, devicesText, envSettings, locate, ocrStatus, parseDevices, parseFfmpegVersion, versionText, } from "../utils/capabilities.js";
|
|
10
|
+
import { parseToolsets, SELECTABLE_TOOLSETS } from "../utils/toolsets.js";
|
|
11
|
+
const { version: serverVersion } = createRequire(import.meta.url)("../../package.json");
|
|
12
|
+
const binary = z.looseObject({
|
|
13
|
+
found: z.boolean(),
|
|
14
|
+
path: z.string().nullable(),
|
|
15
|
+
version: z.string().nullable(),
|
|
16
|
+
major: z.number().nullable(),
|
|
17
|
+
});
|
|
18
|
+
const outputSchema = looseOutput({
|
|
19
|
+
ok: z.boolean(),
|
|
20
|
+
problems: z.array(z.string()),
|
|
21
|
+
server: z.looseObject({ version: z.string(), node: z.string(), platform: z.string(), arch: z.string() }),
|
|
22
|
+
ffmpeg: binary.extend({ meetsFfmpeg8: z.boolean().nullable() }),
|
|
23
|
+
ffprobe: binary,
|
|
24
|
+
filters: z.record(z.string(), z.boolean()),
|
|
25
|
+
devices: z.looseObject({ gdigrab: z.boolean(), dshow: z.boolean() }),
|
|
26
|
+
wgc: z.looseObject({ available: z.boolean() }),
|
|
27
|
+
ocr: z.looseObject({ available: z.boolean(), language: z.string().nullable(), languages: z.array(z.string()) }),
|
|
28
|
+
storage: z.looseObject({ home: z.string(), homeExists: z.boolean() }),
|
|
29
|
+
env: z.record(z.string(), z.string().nullable()),
|
|
30
|
+
});
|
|
31
|
+
function errorText(err) {
|
|
32
|
+
const first = errorResponse(err).content[0];
|
|
33
|
+
return first?.type === "text" ? first.text.replace(/\s*\n+\s*/g, " ") : String(err);
|
|
34
|
+
}
|
|
35
|
+
function describeBinary(bin) {
|
|
36
|
+
const text = versionText(bin);
|
|
37
|
+
const parsed = parseFfmpegVersion(text ?? "");
|
|
38
|
+
return {
|
|
39
|
+
found: text !== null,
|
|
40
|
+
path: text !== null ? locate(bin) : null,
|
|
41
|
+
version: parsed.version,
|
|
42
|
+
major: parsed.major,
|
|
43
|
+
...(parsed.inferred ? { majorInferred: true } : {}),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export function register(server) {
|
|
47
|
+
server.registerTool("doctor", {
|
|
48
|
+
title: "Check Setup",
|
|
49
|
+
description: `Check the setup: ffmpeg/ffprobe (FFmpeg ${FFMPEG_FEATURE_MAJOR}+?), optional filters, capture ` +
|
|
50
|
+
"devices, Windows OCR, settings, and enabled toolsets; `problems` says what is missing and how to " +
|
|
51
|
+
"fix it. Call on first use or when a tool reports a missing feature.",
|
|
52
|
+
inputSchema: {},
|
|
53
|
+
outputSchema,
|
|
54
|
+
annotations: READ_ONLY,
|
|
55
|
+
}, async () => {
|
|
56
|
+
try {
|
|
57
|
+
const problems = [];
|
|
58
|
+
let tools = null;
|
|
59
|
+
try {
|
|
60
|
+
tools = detectFfmpeg();
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
problems.push(errorText(err));
|
|
64
|
+
}
|
|
65
|
+
const ffmpeg = describeBinary(tools?.ffmpeg ?? (process.env.FFMPEG_PATH?.trim() || "ffmpeg"));
|
|
66
|
+
const ffprobe = describeBinary(tools?.ffprobe ?? (process.env.FFPROBE_PATH?.trim() || "ffprobe"));
|
|
67
|
+
const meetsFfmpeg8 = ffmpeg.major === null ? null : ffmpeg.major >= FFMPEG_FEATURE_MAJOR;
|
|
68
|
+
if (tools && meetsFfmpeg8 === false) {
|
|
69
|
+
problems.push(`FFmpeg ${ffmpeg.version} is older than ${FFMPEG_FEATURE_MAJOR}: transcribe and backend "wgc" need FFmpeg ${FFMPEG_FEATURE_MAJOR}+. ` +
|
|
70
|
+
"Windows: `winget install Gyan.FFmpeg`.");
|
|
71
|
+
}
|
|
72
|
+
const filters = {};
|
|
73
|
+
let devices = { gdigrab: false, dshow: false };
|
|
74
|
+
if (tools) {
|
|
75
|
+
for (const f of KEY_FILTERS) {
|
|
76
|
+
filters[f.filter] = f.filter === "gfxcapture" ? wgcAvailable() : hasFilter(f.filter);
|
|
77
|
+
if (!filters[f.filter] && !(f.filter === "gfxcapture" && process.platform !== "win32")) {
|
|
78
|
+
problems.push(`No ${f.filter} filter: ${f.tools} unavailable (needs ${f.why}).`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const names = parseDevices(devicesText(tools.ffmpeg) ?? "");
|
|
82
|
+
devices = { gdigrab: names.includes("gdigrab"), dshow: names.includes("dshow") };
|
|
83
|
+
if (process.platform === "win32" && !devices.gdigrab) {
|
|
84
|
+
problems.push("This ffmpeg has no gdigrab device: screenshot and start_recording cannot capture the screen.");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (process.platform !== "win32") {
|
|
88
|
+
problems.push("Not Windows: capture (screenshot, start_recording, list_targets) and OCR are unavailable; the watch and edit tools work.");
|
|
89
|
+
}
|
|
90
|
+
const ocr = await ocrStatus();
|
|
91
|
+
if (process.platform === "win32" && !ocr.available) {
|
|
92
|
+
problems.push(`Windows OCR unavailable: find_text cannot read the screen. ${ocr.error ?? "Install an OCR language (Settings > Time & language > Language)."}`);
|
|
93
|
+
}
|
|
94
|
+
const env = envSettings();
|
|
95
|
+
const model = env.SCREENCAST_WHISPER_MODEL;
|
|
96
|
+
if (model && !existsSync(model))
|
|
97
|
+
problems.push(`SCREENCAST_WHISPER_MODEL points at a missing file: ${model}`);
|
|
98
|
+
const home = homeRoot();
|
|
99
|
+
for (const dir of envAllowedDirs()) {
|
|
100
|
+
if (!existsSync(dir))
|
|
101
|
+
problems.push(`SCREENCAST_ALLOWED_DIRS names a missing folder: ${dir}`);
|
|
102
|
+
}
|
|
103
|
+
const toolsets = parseToolsets(env.SCREENCAST_TOOLSETS ?? undefined);
|
|
104
|
+
if (toolsets.unknown.length > 0) {
|
|
105
|
+
problems.push(`SCREENCAST_TOOLSETS names unknown toolsets (ignored): ${toolsets.unknown.join(", ")}.`);
|
|
106
|
+
}
|
|
107
|
+
return okResponse({
|
|
108
|
+
ok: problems.length === 0,
|
|
109
|
+
problems,
|
|
110
|
+
server: { version: serverVersion, node: process.version, platform: process.platform, arch: process.arch },
|
|
111
|
+
ffmpeg: { ...ffmpeg, meetsFfmpeg8 },
|
|
112
|
+
ffprobe,
|
|
113
|
+
filters,
|
|
114
|
+
devices,
|
|
115
|
+
wgc: { available: filters.gfxcapture === true },
|
|
116
|
+
ocr,
|
|
117
|
+
storage: {
|
|
118
|
+
home,
|
|
119
|
+
homeExists: existsSync(home),
|
|
120
|
+
recordings: join(home, "recordings"),
|
|
121
|
+
screenshots: join(home, "screenshots"),
|
|
122
|
+
edits: join(home, "edits"),
|
|
123
|
+
allowedOutputDirs: allowedOutputDirs(),
|
|
124
|
+
},
|
|
125
|
+
env,
|
|
126
|
+
toolsets: { enabled: toolsets.enabled, available: ["all", ...SELECTABLE_TOOLSETS] },
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
return errorResponse(error);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
package/dist/tools/exportGif.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
+
import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
|
|
4
5
|
import { requireFfmpeg } from "../utils/ffmpeg.js";
|
|
5
6
|
import { DEFAULT_ANIM_FPS, DEFAULT_ANIM_WIDTH, DEFAULT_MAX_BYTES } from "../utils/anim.js";
|
|
6
7
|
import { exportAnimation } from "../utils/animExport.js";
|
|
@@ -10,14 +11,13 @@ const inputSchema = {
|
|
|
10
11
|
format: z
|
|
11
12
|
.enum(["gif", "webp"])
|
|
12
13
|
.optional()
|
|
13
|
-
.describe("gif (
|
|
14
|
+
.describe("gif (default) or webp (usually much smaller)."),
|
|
14
15
|
maxBytes: z
|
|
15
16
|
.number()
|
|
16
17
|
.int()
|
|
17
18
|
.min(10_000)
|
|
18
19
|
.optional()
|
|
19
|
-
.describe(`
|
|
20
|
-
"for images). Quality steps down until the file fits."),
|
|
20
|
+
.describe(`Size budget in bytes (default ${DEFAULT_MAX_BYTES}, under GitHub's 10 MB image limit).`),
|
|
21
21
|
fps: z.number().positive().max(30).optional().describe(`Starting frame rate (default ${DEFAULT_ANIM_FPS}).`),
|
|
22
22
|
width: z
|
|
23
23
|
.number()
|
|
@@ -25,16 +25,21 @@ const inputSchema = {
|
|
|
25
25
|
.min(64)
|
|
26
26
|
.max(1920)
|
|
27
27
|
.optional()
|
|
28
|
-
.describe(`Starting width in px (default ${DEFAULT_ANIM_WIDTH})
|
|
29
|
-
start: z.number().nonnegative().optional().describe("Start
|
|
30
|
-
duration: z.number().positive().optional().describe("
|
|
28
|
+
.describe(`Starting width in px (default ${DEFAULT_ANIM_WIDTH}).`),
|
|
29
|
+
start: z.number().nonnegative().optional().describe("Start second."),
|
|
30
|
+
duration: z.number().positive().optional().describe("Seconds to export (default: to the end)."),
|
|
31
31
|
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
32
32
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
33
33
|
};
|
|
34
34
|
export function register(server) {
|
|
35
|
-
server.
|
|
36
|
-
|
|
37
|
-
"
|
|
35
|
+
server.registerTool("export_gif", {
|
|
36
|
+
title: "Export GIF or WebP",
|
|
37
|
+
description: "Export an animated GIF or WebP that fits a size budget (for PRs, issues, READMEs), stepping " +
|
|
38
|
+
"fps, width, and quality down until it fits.",
|
|
39
|
+
inputSchema,
|
|
40
|
+
outputSchema: OUTPUT_PATH,
|
|
41
|
+
annotations: WRITES_FILE,
|
|
42
|
+
}, async (args, extra) => {
|
|
38
43
|
try {
|
|
39
44
|
requireFfmpeg();
|
|
40
45
|
if (!existsSync(args.input)) {
|
|
@@ -50,4 +55,3 @@ export function register(server) {
|
|
|
50
55
|
}
|
|
51
56
|
});
|
|
52
57
|
}
|
|
53
|
-
//# sourceMappingURL=exportGif.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
+
import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
|
|
4
5
|
import { requireFfmpeg } from "../utils/ffmpeg.js";
|
|
5
6
|
import { runEditJob, probeDuration } from "../utils/jobs.js";
|
|
6
7
|
import { buildExportPresetArgs, PLATFORM_PRESETS, PLATFORMS, } from "../utils/produce.js";
|
|
@@ -9,20 +10,23 @@ const inputSchema = {
|
|
|
9
10
|
input: z.string().min(1).describe("Path to the source video."),
|
|
10
11
|
platform: z
|
|
11
12
|
.enum(PLATFORMS)
|
|
12
|
-
.describe("
|
|
13
|
-
"
|
|
14
|
-
"footage centred over a blurred copy of itself, audio at -14 LUFS (fit is ignored)."),
|
|
13
|
+
.describe("Sets aspect, size, fps, bitrate. steam_trailer: 1080p 5.5 Mbps CBR, -14 LUFS. vertical_reel: " +
|
|
14
|
+
"1080x1920 over a blurred copy of itself, -14 LUFS (ignores fit)."),
|
|
15
15
|
fit: z
|
|
16
16
|
.enum(["pad", "crop"])
|
|
17
17
|
.optional()
|
|
18
|
-
.describe("
|
|
18
|
+
.describe("Fit to the platform aspect: pad (default) or crop."),
|
|
19
19
|
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
20
20
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
21
21
|
};
|
|
22
22
|
export function register(server) {
|
|
23
|
-
server.
|
|
24
|
-
"
|
|
25
|
-
"
|
|
23
|
+
server.registerTool("export_preset", {
|
|
24
|
+
title: "Export for Platform",
|
|
25
|
+
description: "Encode a platform-ready H.264 file (aspect, fps, bitrate, faststart) for a named platform.",
|
|
26
|
+
inputSchema,
|
|
27
|
+
outputSchema: OUTPUT_PATH,
|
|
28
|
+
annotations: WRITES_FILE,
|
|
29
|
+
}, async (args, extra) => {
|
|
26
30
|
try {
|
|
27
31
|
requireFfmpeg();
|
|
28
32
|
if (!existsSync(args.input)) {
|
|
@@ -40,4 +44,3 @@ export function register(server) {
|
|
|
40
44
|
}
|
|
41
45
|
});
|
|
42
46
|
}
|
|
43
|
-
//# sourceMappingURL=exportPreset.js.map
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
+
import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
|
|
4
5
|
import { requireFfmpeg, runCapture } from "../utils/ffmpeg.js";
|
|
5
6
|
import { runEditJob, probeDuration } from "../utils/jobs.js";
|
|
6
7
|
import { buildExtractAudioArgs, buildProbeArgs, parseMediaInfo, copyAudioExtension, } from "../utils/media.js";
|
|
7
8
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
8
|
-
// Re-encode formats have a fixed container. `copy` keeps the source codec, so
|
|
9
|
-
// its container must match that codec (probed per call, see below) - a blanket
|
|
10
|
-
// .m4a writes a broken file for opus/vorbis/etc (#36).
|
|
11
9
|
const EXTENSION = {
|
|
12
10
|
mp3: "mp3",
|
|
13
11
|
aac: "m4a",
|
|
@@ -22,8 +20,14 @@ const inputSchema = {
|
|
|
22
20
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
23
21
|
};
|
|
24
22
|
export function register(server) {
|
|
25
|
-
server.
|
|
26
|
-
"
|
|
23
|
+
server.registerTool("extract_audio", {
|
|
24
|
+
title: "Extract Audio",
|
|
25
|
+
description: "Extract the audio track of a media file to its own file (mp3, aac, wav, " +
|
|
26
|
+
"or copy). Returns the output path.",
|
|
27
|
+
inputSchema,
|
|
28
|
+
outputSchema: OUTPUT_PATH,
|
|
29
|
+
annotations: WRITES_FILE,
|
|
30
|
+
}, async (args, extra) => {
|
|
27
31
|
try {
|
|
28
32
|
const { ffprobe } = requireFfmpeg();
|
|
29
33
|
if (!existsSync(args.input)) {
|
|
@@ -33,8 +37,7 @@ export function register(server) {
|
|
|
33
37
|
let audioCodec = null;
|
|
34
38
|
let ext;
|
|
35
39
|
if (format === "copy") {
|
|
36
|
-
|
|
37
|
-
const res = await runCapture(ffprobe, buildProbeArgs(args.input), 30_000);
|
|
40
|
+
const res = await runCapture(ffprobe, buildProbeArgs(args.input), 30_000, { signal: extra.signal });
|
|
38
41
|
if (res.code !== 0) {
|
|
39
42
|
throw new ScreencastError(`ffprobe failed (exit ${res.code}): ${res.stderr.trim().slice(-400)}`);
|
|
40
43
|
}
|
|
@@ -60,4 +63,3 @@ export function register(server) {
|
|
|
60
63
|
}
|
|
61
64
|
});
|
|
62
65
|
}
|
|
63
|
-
//# sourceMappingURL=extractAudio.js.map
|
package/dist/tools/findText.js
CHANGED
|
@@ -3,101 +3,105 @@ import { extname, join } from "node:path";
|
|
|
3
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
|
+
import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
|
|
6
7
|
import { requireFfmpeg, runFfmpeg, probeMedia } from "../utils/ffmpeg.js";
|
|
8
|
+
import { jobTimeoutMs } from "../utils/jobs.js";
|
|
7
9
|
import { resolveCaptureTarget } from "../utils/resolveTarget.js";
|
|
8
10
|
import { captureStill } from "../utils/still.js";
|
|
9
11
|
import { buildHighlightArgs, targetSize } from "../utils/diff.js";
|
|
10
12
|
import { recognize, mergePasses, findMatches, redactionRects, passScales } from "../utils/ocr.js";
|
|
11
13
|
import { buildSampleByFpsArgs, planFpsSampling } from "../utils/media.js";
|
|
12
14
|
import { windowMatchReport } from "../utils/windows.js";
|
|
15
|
+
import { confirmCapture, describeTarget } from "../utils/consent.js";
|
|
13
16
|
import { subdir, stamp, rand, stillOutput } from "../utils/paths.js";
|
|
14
17
|
import { encodeInlineImages, DEFAULT_MAX_IMAGE_WIDTH } from "../utils/images.js";
|
|
15
18
|
const IMAGE_EXTENSIONS = new Set([".png", ".jpg", ".jpeg", ".bmp", ".gif", ".webp", ".tif", ".tiff"]);
|
|
16
19
|
const MAX_LINES = 300;
|
|
17
|
-
/** Default and largest frame count for a whole-clip scan (#204). */
|
|
18
20
|
export const DEFAULT_SCAN_FRAMES = 30;
|
|
19
21
|
export const MAX_SCAN_FRAMES = 120;
|
|
20
22
|
const inputSchema = {
|
|
21
23
|
target: z
|
|
22
24
|
.string()
|
|
23
25
|
.optional()
|
|
24
|
-
.describe("
|
|
25
|
-
input: z.string().optional().describe("
|
|
26
|
-
timestamp: z.number().nonnegative().optional().describe("
|
|
26
|
+
.describe("Live screen target (full | monitor:<i> | window:... | region:...), or pass input."),
|
|
27
|
+
input: z.string().optional().describe("Image or video file to read instead of a live target."),
|
|
28
|
+
timestamp: z.number().nonnegative().optional().describe("Video input: second to read (default 0)."),
|
|
27
29
|
scanEverySec: z
|
|
28
30
|
.number()
|
|
29
31
|
.positive()
|
|
30
32
|
.optional()
|
|
31
|
-
.describe("
|
|
32
|
-
"
|
|
33
|
-
"gets its time, and redactRegions get start/end. The interval widens to stay within maxFrames."),
|
|
33
|
+
.describe("Video input: scan a frame every N s across the clip (e.g. for secrets before sharing); matches " +
|
|
34
|
+
"and redactRegions get times. Widens to stay within maxFrames."),
|
|
34
35
|
maxFrames: z
|
|
35
36
|
.number()
|
|
36
37
|
.int()
|
|
37
38
|
.min(1)
|
|
38
39
|
.max(MAX_SCAN_FRAMES)
|
|
39
40
|
.optional()
|
|
40
|
-
.describe(`
|
|
41
|
-
exactTitle: z.boolean().optional().describe("
|
|
41
|
+
.describe(`scanEverySec frame cap (default ${DEFAULT_SCAN_FRAMES}; ~1 s each).`),
|
|
42
|
+
exactTitle: z.boolean().optional().describe("window: targets match the whole title only (default false)."),
|
|
42
43
|
backend: z
|
|
43
44
|
.enum(["gdigrab", "wgc"])
|
|
44
45
|
.optional()
|
|
45
|
-
.describe("
|
|
46
|
-
"reads the window's own surface even when other windows cover it."),
|
|
46
|
+
.describe("Live target: gdigrab (default) = what is visible; wgc (window:, FFmpeg 8+) = the window even if covered."),
|
|
47
47
|
query: z
|
|
48
48
|
.string()
|
|
49
49
|
.optional()
|
|
50
|
-
.describe("Text to
|
|
51
|
-
"O vs 0; regexes get the _ vs - tolerance). Without a query, all recognised text is returned."),
|
|
50
|
+
.describe("Text to find (case-insensitive, tolerates OCR misreads like I/l, O/0, _/-). Omit to return all text."),
|
|
52
51
|
regex: z.boolean().optional().describe("Treat query as a regular expression (case-insensitive)."),
|
|
53
52
|
redact: z
|
|
54
53
|
.boolean()
|
|
55
54
|
.optional()
|
|
56
|
-
.describe("Also return padded rectangles
|
|
57
|
-
"(regions) to cover them. Detection is best-effort: review the result."),
|
|
55
|
+
.describe("Also return padded match rectangles ready for redact_region's regions."),
|
|
58
56
|
keep: z
|
|
59
57
|
.boolean()
|
|
60
58
|
.optional()
|
|
61
|
-
.describe("
|
|
62
|
-
"deleted after reading, since it may show the secrets being looked for)."),
|
|
59
|
+
.describe("Live target: keep the capture and return its path (default false: deleted after reading)."),
|
|
63
60
|
returnImage: z
|
|
64
61
|
.boolean()
|
|
65
62
|
.optional()
|
|
66
|
-
.describe("Return the image
|
|
63
|
+
.describe("Return the image with matches outlined (default: true with a query)."),
|
|
67
64
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
async function readFrames(sources, work, signal) {
|
|
66
|
+
const sized = await Promise.all(sources.map(async (source) => {
|
|
67
|
+
const { width, height } = await probeMedia(source);
|
|
68
|
+
if (!width || !height)
|
|
69
|
+
throw new ScreencastError("Could not read the image size.");
|
|
70
|
+
return { source, width, height };
|
|
71
|
+
}));
|
|
72
72
|
const passes = [];
|
|
73
73
|
const passScaleList = [];
|
|
74
74
|
const owner = [];
|
|
75
|
-
for (
|
|
76
|
-
const { width, height } = sized[f];
|
|
77
|
-
if (!width || !height)
|
|
78
|
-
throw new ScreencastError("Could not read the image size.");
|
|
75
|
+
for (const [f, { source, width, height }] of sized.entries()) {
|
|
79
76
|
for (const [i, scale] of passScales(width, height).entries()) {
|
|
80
77
|
const out = join(work, `pass${f}-${i}.png`);
|
|
81
|
-
await runFfmpeg(["-y", "-v", "error", "-i",
|
|
78
|
+
await runFfmpeg(["-y", "-v", "error", "-i", source, "-vf", `scale=iw*${scale}:ih*${scale}:flags=lanczos`, out], 60_000, {
|
|
79
|
+
signal,
|
|
80
|
+
});
|
|
82
81
|
passes.push(out);
|
|
83
82
|
passScaleList.push(scale);
|
|
84
83
|
owner.push(f);
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
86
|
const results = await recognize(passes, passScaleList);
|
|
88
|
-
return
|
|
87
|
+
return sized.map(({ width, height }, f) => ({
|
|
89
88
|
lines: mergePasses(results.filter((_r, i) => owner[i] === f)),
|
|
90
|
-
width
|
|
91
|
-
height
|
|
89
|
+
width,
|
|
90
|
+
height,
|
|
92
91
|
}));
|
|
93
92
|
}
|
|
94
93
|
export function register(server) {
|
|
95
|
-
server.
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
94
|
+
server.registerTool("find_text", {
|
|
95
|
+
title: "Find Text (OCR)",
|
|
96
|
+
description: "OCR (built into Windows) on the screen, an image, or video frames, with line and match boxes " +
|
|
97
|
+
"in image pixels (add `origin` for desktop coordinates). Locate UI text or secrets (e.g. regex " +
|
|
98
|
+
"'sk-|ghp_|api.?key') to redact. Best-effort: review results.",
|
|
99
|
+
inputSchema,
|
|
100
|
+
outputSchema: looseOutput({
|
|
101
|
+
imageSize: looseOutput({ width: z.number(), height: z.number() }),
|
|
102
|
+
}),
|
|
103
|
+
annotations: READ_ONLY,
|
|
104
|
+
}, async (args, extra) => {
|
|
101
105
|
try {
|
|
102
106
|
requireFfmpeg();
|
|
103
107
|
if ((args.target === undefined) === (args.input === undefined)) {
|
|
@@ -106,21 +110,18 @@ export function register(server) {
|
|
|
106
110
|
const work = mkdtempSync(join(tmpdir(), "screencast-ocr-"));
|
|
107
111
|
try {
|
|
108
112
|
if (args.scanEverySec !== undefined)
|
|
109
|
-
return await scanClip(args, work);
|
|
110
|
-
// 1. Get the source as one PNG frame.
|
|
113
|
+
return await scanClip(args, work, extra.signal);
|
|
111
114
|
let source;
|
|
112
115
|
let windowReport = {};
|
|
113
116
|
let origin;
|
|
114
117
|
if (args.target !== undefined) {
|
|
115
118
|
const resolved = await resolveCaptureTarget(args.target, { exactTitle: args.exactTitle, backend: args.backend });
|
|
116
|
-
// Captures go to the work dir and vanish with it unless kept (#209).
|
|
117
119
|
source = args.keep ? join(subdir("screenshots"), `ocr-${stamp()}-${rand()}.png`) : join(work, "capture.png");
|
|
118
120
|
const backend = args.backend ?? "gdigrab";
|
|
121
|
+
await confirmCapture(server, `Capture ${describeTarget(args.target, resolved.window)} once to read the text on it?`, extra.signal);
|
|
119
122
|
await captureStill(resolved, source, backend);
|
|
120
123
|
if (resolved.window)
|
|
121
124
|
windowReport = windowMatchReport(resolved.window);
|
|
122
|
-
// Where the image sits on the desktop: boxes are image pixels (#233).
|
|
123
|
-
// A WGC still is the window's client area.
|
|
124
125
|
const area = targetSize(resolved.target, resolved.monitors);
|
|
125
126
|
origin = backend === "wgc" && resolved.window?.client ? resolved.window.client : { x: area.x, y: area.y };
|
|
126
127
|
}
|
|
@@ -129,17 +130,18 @@ export function register(server) {
|
|
|
129
130
|
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
130
131
|
const isImage = IMAGE_EXTENSIONS.has(extname(args.input).toLowerCase());
|
|
131
132
|
source = join(work, "frame.png");
|
|
132
|
-
await runFfmpeg(["-y", "-v", "error", ...(isImage ? [] : ["-ss", String(args.timestamp ?? 0)]), "-i", args.input, "-frames:v", "1", ...stillOutput(source)], 60_000);
|
|
133
|
+
await runFfmpeg(["-y", "-v", "error", ...(isImage ? [] : ["-ss", String(args.timestamp ?? 0)]), "-i", args.input, "-frames:v", "1", ...stillOutput(source)], 60_000, { signal: extra.signal });
|
|
133
134
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
const [frame] = await readFrames([source], work, extra.signal);
|
|
136
|
+
if (!frame)
|
|
137
|
+
throw new ScreencastError("Could not read the frame.");
|
|
138
|
+
const { lines, width, height } = frame;
|
|
137
139
|
const matches = args.query ? findMatches(lines, args.query, args.regex === true) : [];
|
|
138
140
|
const images = [];
|
|
139
141
|
const wantImage = args.returnImage ?? Boolean(args.query);
|
|
140
142
|
if (wantImage) {
|
|
141
143
|
const shown = join(work, "shown.png");
|
|
142
|
-
await runFfmpeg(buildHighlightArgs(source, matches, shown), 30_000);
|
|
144
|
+
await runFfmpeg(buildHighlightArgs(source, matches, shown), 30_000, { signal: extra.signal });
|
|
143
145
|
images.push(...(await encodeInlineImages([shown], DEFAULT_MAX_IMAGE_WIDTH, 1)).images);
|
|
144
146
|
}
|
|
145
147
|
return okResponse({
|
|
@@ -170,11 +172,7 @@ export function register(server) {
|
|
|
170
172
|
}
|
|
171
173
|
});
|
|
172
174
|
}
|
|
173
|
-
|
|
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) {
|
|
175
|
+
async function scanClip(args, work, signal) {
|
|
178
176
|
if (args.input === undefined)
|
|
179
177
|
throw new ScreencastError("scanEverySec reads a video file: pass input, not target.");
|
|
180
178
|
if (!existsSync(args.input))
|
|
@@ -185,14 +183,17 @@ async function scanClip(args, work) {
|
|
|
185
183
|
const info = await probeMedia(args.input);
|
|
186
184
|
const maxFrames = args.maxFrames ?? DEFAULT_SCAN_FRAMES;
|
|
187
185
|
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),
|
|
186
|
+
await runFfmpeg(buildSampleByFpsArgs(args.input, plan.fps, join(work, "scan_%05d.png"), maxFrames), jobTimeoutMs(info.durationSec), { signal });
|
|
189
187
|
const frames = readdirSync(work).filter((f) => f.startsWith("scan_")).sort().map((f) => join(work, f));
|
|
190
188
|
if (frames.length === 0)
|
|
191
189
|
throw new ScreencastError("Could not read any frames from the video.");
|
|
192
190
|
const step = 1 / plan.fps;
|
|
193
|
-
const
|
|
194
|
-
const end = info.videoDurationSec ?? info.durationSec ??
|
|
195
|
-
const read = await readFrames(frames, work);
|
|
191
|
+
const timeAt = (i) => Math.round(i * step * 1000) / 1000;
|
|
192
|
+
const end = info.videoDurationSec ?? info.durationSec ?? timeAt(frames.length - 1) + step;
|
|
193
|
+
const read = await readFrames(frames, work, signal);
|
|
194
|
+
const [size] = read;
|
|
195
|
+
if (!size)
|
|
196
|
+
throw new ScreencastError("Could not read any frames from the video.");
|
|
196
197
|
const matches = [];
|
|
197
198
|
const redactRegions = [];
|
|
198
199
|
const seenLines = new Set();
|
|
@@ -202,25 +203,29 @@ async function scanClip(args, work) {
|
|
|
202
203
|
if (!args.query)
|
|
203
204
|
return;
|
|
204
205
|
const hits = findMatches(frame.lines, args.query, args.regex === true);
|
|
205
|
-
const
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
206
|
+
const t = timeAt(i);
|
|
207
|
+
const start = Math.max(0, Math.round((t - step) * 1000) / 1000);
|
|
208
|
+
const stop = Math.min(end, Math.round((t + step) * 1000) / 1000);
|
|
209
|
+
const rects = redactionRects(hits, frame);
|
|
210
|
+
for (const [k, hit] of hits.entries()) {
|
|
211
|
+
matches.push({ t, ...hit });
|
|
212
|
+
const rect = rects[k];
|
|
213
|
+
if (rect)
|
|
214
|
+
redactRegions.push({ ...rect, start, end: stop });
|
|
210
215
|
}
|
|
211
216
|
});
|
|
212
217
|
const images = [];
|
|
213
218
|
const first = matches[0];
|
|
214
|
-
|
|
215
|
-
|
|
219
|
+
const firstFrame = first && frames.find((_, i) => timeAt(i) === first.t);
|
|
220
|
+
if ((args.returnImage ?? Boolean(args.query)) && first && firstFrame) {
|
|
216
221
|
const shown = join(work, "shown.png");
|
|
217
|
-
await runFfmpeg(buildHighlightArgs(
|
|
222
|
+
await runFfmpeg(buildHighlightArgs(firstFrame, matches.filter((m) => m.t === first.t), shown), 30_000, { signal });
|
|
218
223
|
images.push(...(await encodeInlineImages([shown], DEFAULT_MAX_IMAGE_WIDTH, 1)).images);
|
|
219
224
|
}
|
|
220
225
|
const text = [...seenLines].join("\n");
|
|
221
226
|
return okResponse({
|
|
222
227
|
input: args.input,
|
|
223
|
-
imageSize: { width:
|
|
228
|
+
imageSize: { width: size.width, height: size.height },
|
|
224
229
|
scan: {
|
|
225
230
|
everySec: Math.round(step * 1000) / 1000,
|
|
226
231
|
framesScanned: frames.length,
|
|
@@ -239,4 +244,3 @@ async function scanClip(args, work) {
|
|
|
239
244
|
"or stylised text, can be missed. Review before sharing, especially for redaction.",
|
|
240
245
|
}, images);
|
|
241
246
|
}
|
|
242
|
-
//# sourceMappingURL=findText.js.map
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
+
import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
|
|
4
5
|
import { probeMedia } from "../utils/ffmpeg.js";
|
|
5
6
|
const inputSchema = {
|
|
6
7
|
input: z.string().min(1).describe("Path to the media file to probe."),
|
|
7
8
|
};
|
|
8
9
|
export function register(server) {
|
|
9
|
-
server.
|
|
10
|
-
"
|
|
10
|
+
server.registerTool("get_media_info", {
|
|
11
|
+
title: "Get Media Info",
|
|
12
|
+
description: "Probe a media file with ffprobe and return duration, resolution, frame " +
|
|
13
|
+
"rate, codecs, container format, and size.",
|
|
14
|
+
inputSchema,
|
|
15
|
+
outputSchema: looseOutput({
|
|
16
|
+
input: z.string(),
|
|
17
|
+
durationSec: z.number().nullable(),
|
|
18
|
+
width: z.number().nullable(),
|
|
19
|
+
height: z.number().nullable(),
|
|
20
|
+
fps: z.number().nullable(),
|
|
21
|
+
videoCodec: z.string().nullable(),
|
|
22
|
+
audioCodec: z.string().nullable(),
|
|
23
|
+
}),
|
|
24
|
+
annotations: READ_ONLY,
|
|
25
|
+
}, async (args) => {
|
|
11
26
|
try {
|
|
12
27
|
if (!existsSync(args.input)) {
|
|
13
28
|
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
@@ -19,4 +34,3 @@ export function register(server) {
|
|
|
19
34
|
}
|
|
20
35
|
});
|
|
21
36
|
}
|
|
22
|
-
//# sourceMappingURL=getMediaInfo.js.map
|