@tmhs/screencast-mcp 0.48.2 → 0.49.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/dist/resources.js +26 -0
- package/dist/server.js +2 -0
- package/dist/tools/backdrop.js +1 -11
- package/dist/tools/bugReport.js +5 -28
- package/dist/tools/burnSubtitles.js +2 -2
- package/dist/tools/callout.js +7 -49
- package/dist/tools/contactSheet.js +3 -24
- package/dist/tools/cursor.js +2 -22
- package/dist/tools/deleteRecording.js +119 -0
- package/dist/tools/denoise.js +2 -2
- package/dist/tools/findText.js +1 -3
- package/dist/tools/indexRecording.js +6 -6
- package/dist/tools/keystrokeOverlay.js +3 -44
- package/dist/tools/normalizeAudio.js +3 -4
- package/dist/tools/pipeline.js +16 -19
- package/dist/tools/redactRegion.js +7 -16
- package/dist/tools/reframe.js +3 -3
- package/dist/tools/sampleFrames.js +6 -2
- package/dist/tools/stepGuide.js +13 -10
- package/dist/tools/titleCard.js +1 -1
- package/dist/tools/waitForChange.js +28 -46
- package/dist/tools/zoom.js +3 -18
- package/dist/utils/audio.js +4 -0
- package/dist/utils/backdrop.js +12 -1
- package/dist/utils/bugReport.js +23 -0
- package/dist/utils/callout.js +48 -2
- package/dist/utils/captions.js +1 -0
- package/dist/utils/cursor.js +22 -1
- package/dist/utils/diff.js +6 -4
- package/dist/utils/frameQueue.js +50 -0
- package/dist/utils/images.js +4 -4
- package/dist/utils/keystrokes.js +44 -1
- package/dist/utils/media.js +27 -3
- package/dist/utils/ocrScan.js +35 -19
- package/dist/utils/paths.js +3 -0
- package/dist/utils/pool.js +29 -0
- package/dist/utils/produce.js +2 -0
- package/dist/utils/recordingFiles.js +32 -0
- package/dist/utils/replay.js +16 -23
- package/dist/utils/sessions.js +25 -0
- package/dist/utils/sheet.js +25 -2
- package/dist/utils/toolSpec.js +6 -0
- package/dist/utils/toolsets.js +1 -0
- package/dist/utils/waitLoop.js +50 -0
- package/dist/utils/zoom.js +18 -0
- package/package.json +1 -1
|
@@ -1,57 +1,16 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { existsSync, mkdtempSync,
|
|
3
|
+
import { existsSync, mkdtempSync, rmSync } from "node:fs";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
6
6
|
import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
|
|
7
7
|
import { requireFfmpeg, probeMedia } from "../utils/ffmpeg.js";
|
|
8
8
|
import { runEditJob } from "../utils/jobs.js";
|
|
9
|
-
import {
|
|
10
|
-
import { resolveTextFont } from "../utils/fonts.js";
|
|
11
|
-
import { planBadges, groupBadges, buildKeystrokeArgs, BADGE_POSITIONS, DEFAULT_LINGER_SEC, } from "../utils/keystrokes.js";
|
|
9
|
+
import { groupBadges, buildKeystrokeArgs, DEFAULT_LINGER_SEC, keystrokeOptionsSchema, loadBadges, prepareKeystrokeAssets, } from "../utils/keystrokes.js";
|
|
12
10
|
import { editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
13
11
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
14
|
-
import { fontFileSchema } from "
|
|
15
|
-
export const keystrokeOptionsSchema = {
|
|
16
|
-
events: z.string().optional(),
|
|
17
|
-
clicks: z.boolean().optional(),
|
|
18
|
-
typing: z.boolean().optional(),
|
|
19
|
-
keys: z.enum(["shortcuts", "masked"]).optional(),
|
|
20
|
-
lingerSec: z.number().positive().max(10).optional(),
|
|
21
|
-
position: z.enum(BADGE_POSITIONS).optional(),
|
|
22
|
-
size: z.number().min(8).max(400).optional(),
|
|
23
|
-
color: z.string().optional(),
|
|
24
|
-
fontFile: z.string().min(1).optional(),
|
|
25
|
-
};
|
|
12
|
+
import { fontFileSchema } from "../utils/callout.js";
|
|
26
13
|
const o = keystrokeOptionsSchema;
|
|
27
|
-
export function loadBadges(input, events, opts) {
|
|
28
|
-
const path = events ?? eventPaths(input).jsonl;
|
|
29
|
-
if (!existsSync(path)) {
|
|
30
|
-
throw new ScreencastError(`No event log for ${input} (looked for ${path}). Record with start_recording events: true ` +
|
|
31
|
-
'(keys: "shortcuts" to name shortcuts), or pass events: <path to .events.jsonl>.');
|
|
32
|
-
}
|
|
33
|
-
const log = parseEventsJsonl(readFileSync(path, "utf8"));
|
|
34
|
-
return { badges: planBadges(log, opts), shortcutsLogged: log.filter((e) => e.type === "key").length, path };
|
|
35
|
-
}
|
|
36
|
-
export function prepareKeystrokeAssets(labels, workDir, tag = "", fontFile) {
|
|
37
|
-
const font = resolveTextFont(labels.join(" "), { weight: "bold", fontFile });
|
|
38
|
-
const textFiles = {};
|
|
39
|
-
labels.forEach((label, i) => {
|
|
40
|
-
if (workDir === null) {
|
|
41
|
-
textFiles[label] = `<badge ${i}>`;
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const f = join(workDir, `${tag}badge_${i}.txt`);
|
|
45
|
-
writeFileSync(f, label);
|
|
46
|
-
textFiles[label] = f;
|
|
47
|
-
});
|
|
48
|
-
return {
|
|
49
|
-
fontFile: font.fontFile,
|
|
50
|
-
textFiles,
|
|
51
|
-
...(font.fallback && { fallbackFont: font.fontFile }),
|
|
52
|
-
warnings: font.warning ? [font.warning] : [],
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
14
|
const inputSchema = {
|
|
56
15
|
input: z.string().min(1).describe("Path to the recording."),
|
|
57
16
|
events: o.events.describe("Event log (default: the input's .events.jsonl)."),
|
|
@@ -4,15 +4,14 @@ import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
|
4
4
|
import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
|
|
5
5
|
import { requireFfmpeg, runCapture, probeMedia } from "../utils/ffmpeg.js";
|
|
6
6
|
import { runEditJob, jobTimeoutMs } from "../utils/jobs.js";
|
|
7
|
-
import { loudnessTarget, buildLoudnessMeasureArgs, buildLoudnessApplyArgs, parseLoudnorm, } from "../utils/audio.js";
|
|
7
|
+
import { loudnessTarget, buildLoudnessMeasureArgs, buildLoudnessApplyArgs, parseLoudnorm, loudnessTargetSchema, } from "../utils/audio.js";
|
|
8
8
|
import { editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
9
9
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
10
10
|
const inputSchema = {
|
|
11
11
|
input: z.string().min(1).describe("Path to the source video or audio file."),
|
|
12
|
-
target:
|
|
13
|
-
.union([z.enum(["youtube", "podcast", "broadcast"]), z.number()])
|
|
12
|
+
target: loudnessTargetSchema
|
|
14
13
|
.optional()
|
|
15
|
-
.describe("youtube (-14 LUFS, default), podcast (-16), broadcast (-23), or a LUFS number."),
|
|
14
|
+
.describe("youtube (-14 LUFS, default), podcast (-16), broadcast (-23), or a LUFS number (-70 to -5)."),
|
|
16
15
|
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
17
16
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
18
17
|
};
|
package/dist/tools/pipeline.js
CHANGED
|
@@ -9,25 +9,22 @@ import { jobTimeoutMs, runEditJob } from "../utils/jobs.js";
|
|
|
9
9
|
import { planPipeline, probeArgs, sidecarCues, MAX_PIPELINE_STEPS } from "../utils/pipeline.js";
|
|
10
10
|
import { calloutFonts, prepareCalloutAssets } from "../utils/calloutAssets.js";
|
|
11
11
|
import { exportAnimation } from "../utils/animExport.js";
|
|
12
|
-
import {
|
|
13
|
-
import { assertEditContainer } from "../utils/media.js";
|
|
14
|
-
import { readClicks, zoomKeyframeSchema } from "./zoom.js";
|
|
15
|
-
import { redactRegionSchema } from "./redactRegion.js";
|
|
12
|
+
import { assertEditContainer, redactRegionSchema, REDACT_STYLES } from "../utils/media.js";
|
|
16
13
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
17
|
-
import { PLATFORMS } from "../utils/produce.js";
|
|
14
|
+
import { PLATFORMS, ASPECTS, REFRAME_FITS } from "../utils/produce.js";
|
|
18
15
|
import { buildChapters, ffmetadata, markerPoints, markersOrChapters, retimeMarkers, writeMarkers } from "../utils/chapters.js";
|
|
19
|
-
import { cursorOptionsSchema, loadCursor } from "
|
|
20
|
-
import {
|
|
21
|
-
import { backdropOptionsSchema } from "./backdrop.js";
|
|
22
|
-
import { keystrokeOptionsSchema, loadBadges, prepareKeystrokeAssets } from "./keystrokeOverlay.js";
|
|
23
|
-
import { MAX_ZOOM } from "../utils/zoom.js";
|
|
16
|
+
import { cursorSpritePath, cursorOptionsSchema, loadCursor } from "../utils/cursor.js";
|
|
17
|
+
import { MAX_ZOOM, readClicks, zoomKeyframeSchema } from "../utils/zoom.js";
|
|
24
18
|
import { buildIdleScanArgs, intersect, parseFreezes, parseSilences, DEFAULT_MIN_IDLE_SEC } from "../utils/idle.js";
|
|
25
|
-
import { buildLoudnessMeasureArgs, buildNoiseFloorArgs, loudnessTarget, parseLoudnorm, parseNoiseFloor } from "../utils/audio.js";
|
|
26
|
-
import { buildTranscribeArgs, formatSrt, normalizeCues, parseSrt, resolveWhisperModel } from "../utils/captions.js";
|
|
19
|
+
import { buildLoudnessMeasureArgs, buildNoiseFloorArgs, loudnessTarget, parseLoudnorm, parseNoiseFloor, DENOISE_STRENGTHS, loudnessTargetSchema } from "../utils/audio.js";
|
|
20
|
+
import { buildTranscribeArgs, formatSrt, normalizeCues, parseSrt, resolveWhisperModel, CAPTION_STYLE_NAMES } from "../utils/captions.js";
|
|
27
21
|
import { eventPaths } from "../utils/events.js";
|
|
28
22
|
import { bundledFontPath } from "../utils/fonts.js";
|
|
29
23
|
import { retimeAss, retimeCues } from "../utils/timeline.js";
|
|
30
24
|
import { applyOverrides, recipeSteps, RECIPES } from "../utils/recipes.js";
|
|
25
|
+
import { calloutItemSchema, fontFileSchema } from "../utils/callout.js";
|
|
26
|
+
import { backdropOptionsSchema } from "../utils/backdrop.js";
|
|
27
|
+
import { keystrokeOptionsSchema, loadBadges, prepareKeystrokeAssets } from "../utils/keystrokes.js";
|
|
31
28
|
function transcribeBlocker() {
|
|
32
29
|
if (!hasFilter("whisper"))
|
|
33
30
|
return "this ffmpeg has no whisper filter (FFmpeg 8 with whisper.cpp).";
|
|
@@ -39,8 +36,8 @@ function transcribeBlocker() {
|
|
|
39
36
|
return "no whisper model (set SCREENCAST_WHISPER_MODEL).";
|
|
40
37
|
}
|
|
41
38
|
}
|
|
42
|
-
const aspect = z.enum(
|
|
43
|
-
const fit = z.enum(
|
|
39
|
+
const aspect = z.enum(ASPECTS);
|
|
40
|
+
const fit = z.enum(REFRAME_FITS).optional();
|
|
44
41
|
const step = z.discriminatedUnion("op", [
|
|
45
42
|
z.object({
|
|
46
43
|
op: z.literal("trim"),
|
|
@@ -60,7 +57,7 @@ const step = z.discriminatedUnion("op", [
|
|
|
60
57
|
z.object({
|
|
61
58
|
op: z.literal("redact"),
|
|
62
59
|
regions: z.array(redactRegionSchema).min(1),
|
|
63
|
-
style: z.enum(
|
|
60
|
+
style: z.enum(REDACT_STYLES).optional(),
|
|
64
61
|
pad: z.number().int().nonnegative().optional(),
|
|
65
62
|
color: z.string().optional(),
|
|
66
63
|
}),
|
|
@@ -77,14 +74,14 @@ const step = z.discriminatedUnion("op", [
|
|
|
77
74
|
z.object({ op: z.literal("cut_idle"), minIdleSec: z.number().positive().optional(), keepSec: z.number().min(0).optional() }),
|
|
78
75
|
z.object({
|
|
79
76
|
op: z.literal("audio"),
|
|
80
|
-
normalize:
|
|
81
|
-
denoise: z.enum(
|
|
77
|
+
normalize: loudnessTargetSchema.optional(),
|
|
78
|
+
denoise: z.enum(DENOISE_STRENGTHS).optional(),
|
|
82
79
|
}),
|
|
83
80
|
z.object({
|
|
84
81
|
op: z.literal("burn_subtitles"),
|
|
85
|
-
subtitles: z.string().optional(),
|
|
82
|
+
subtitles: z.string().min(1).optional(),
|
|
86
83
|
transcribe: z.boolean().optional(),
|
|
87
|
-
style: z.enum(
|
|
84
|
+
style: z.enum(CAPTION_STYLE_NAMES).optional(),
|
|
88
85
|
}),
|
|
89
86
|
z.object({ op: z.literal("backdrop"), ...backdropOptionsSchema }),
|
|
90
87
|
z.object({ op: z.literal("keystroke_overlay"), ...keystrokeOptionsSchema }),
|
|
@@ -4,24 +4,16 @@ import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
|
4
4
|
import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
|
|
5
5
|
import { requireFfmpeg, probeMedia } from "../utils/ffmpeg.js";
|
|
6
6
|
import { runEditJob } from "../utils/jobs.js";
|
|
7
|
-
import { buildRedactArgs,
|
|
7
|
+
import { buildRedactArgs, stillEdit, redactRegionSchema, REDACT_STYLES } from "../utils/media.js";
|
|
8
8
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
9
|
-
export const redactRegionSchema = z.object({
|
|
10
|
-
x: z.number().int().nonnegative(),
|
|
11
|
-
y: z.number().int().nonnegative(),
|
|
12
|
-
width: z.number().int().positive(),
|
|
13
|
-
height: z.number().int().positive(),
|
|
14
|
-
start: z.number().nonnegative().optional(),
|
|
15
|
-
end: z.number().positive().optional(),
|
|
16
|
-
});
|
|
17
9
|
const inputSchema = {
|
|
18
|
-
input: z.string().min(1).describe("Path to the source video."),
|
|
10
|
+
input: z.string().min(1).describe("Path to the source video or image (png/jpg; time ranges are ignored for an image)."),
|
|
19
11
|
regions: z
|
|
20
12
|
.array(redactRegionSchema)
|
|
21
13
|
.min(1)
|
|
22
14
|
.describe("Pixel rectangles (x, y, width, height), each optionally limited to start..end seconds."),
|
|
23
15
|
style: z
|
|
24
|
-
.enum(
|
|
16
|
+
.enum(REDACT_STYLES)
|
|
25
17
|
.optional()
|
|
26
18
|
.describe("box (default): irreversible fill; blur/pixelate are partially recoverable."),
|
|
27
19
|
pad: z
|
|
@@ -37,7 +29,7 @@ const inputSchema = {
|
|
|
37
29
|
export function register(server) {
|
|
38
30
|
server.registerTool("redact_region", {
|
|
39
31
|
title: "Redact Regions",
|
|
40
|
-
description: "Cover given rectangles in a video (e.g. secrets on screen). Not automatic detection: find " +
|
|
32
|
+
description: "Cover given rectangles in a video or screenshot (e.g. secrets on screen). Not automatic detection: find " +
|
|
41
33
|
"them with find_text redact: true. Off-frame regions are rejected.",
|
|
42
34
|
inputSchema,
|
|
43
35
|
outputSchema: OUTPUT_PATH,
|
|
@@ -49,15 +41,14 @@ export function register(server) {
|
|
|
49
41
|
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
50
42
|
}
|
|
51
43
|
const { width, height, durationSec } = await probeMedia(args.input);
|
|
52
|
-
|
|
53
|
-
const ext = editOutputExt(args.input);
|
|
44
|
+
const { still, ext } = stillEdit(args.input, args.output);
|
|
54
45
|
const output = resolveOutput(args.output, subdir("edits"), `redact-${stamp()}-${rand()}${ext}`, args.overwrite);
|
|
55
46
|
const ffArgs = buildRedactArgs(args.input, output, args.regions, {
|
|
56
47
|
style: args.style,
|
|
57
48
|
pad: args.pad,
|
|
58
49
|
color: args.color,
|
|
59
|
-
}, { width, height });
|
|
60
|
-
await runEditJob(ffArgs, { output, durationSec, extra });
|
|
50
|
+
}, { width, height }, still);
|
|
51
|
+
await runEditJob(ffArgs, { output, durationSec: still ? null : durationSec, extra });
|
|
61
52
|
return okResponse({
|
|
62
53
|
outputPath: output,
|
|
63
54
|
regions: args.regions.length,
|
package/dist/tools/reframe.js
CHANGED
|
@@ -4,16 +4,16 @@ import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
|
4
4
|
import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
|
|
5
5
|
import { requireFfmpeg } from "../utils/ffmpeg.js";
|
|
6
6
|
import { runEditJob, probeDuration } from "../utils/jobs.js";
|
|
7
|
-
import { buildReframeArgs } from "../utils/produce.js";
|
|
7
|
+
import { buildReframeArgs, ASPECTS, REFRAME_FITS } from "../utils/produce.js";
|
|
8
8
|
import { editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
9
9
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
10
10
|
const inputSchema = {
|
|
11
11
|
input: z.string().min(1).describe("Path to the source video."),
|
|
12
12
|
aspect: z
|
|
13
|
-
.enum(
|
|
13
|
+
.enum(ASPECTS)
|
|
14
14
|
.describe("Target aspect ratio."),
|
|
15
15
|
fit: z
|
|
16
|
-
.enum(
|
|
16
|
+
.enum(REFRAME_FITS)
|
|
17
17
|
.optional()
|
|
18
18
|
.describe("pad (default): letterbox, nothing lost. crop: fill and center-crop."),
|
|
19
19
|
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
@@ -8,6 +8,7 @@ import { jobTimeoutMs } from "../utils/jobs.js";
|
|
|
8
8
|
import { buildSampleByFpsArgs, pickFramePrefix, buildSampleAtTimestampArgs, planFpsSampling, buildSceneScanArgs, parseSceneScan, pickSceneFrames, DEFAULT_SCENE_THRESHOLD, DEFAULT_MAX_FRAMES, MAX_FRAMES_CEILING, } from "../utils/media.js";
|
|
9
9
|
import { subdir, stamp, rand, sequencePattern, resolveOutputDir } from "../utils/paths.js";
|
|
10
10
|
import { encodeInlineImages, clampInlineCount, DEFAULT_MAX_IMAGE_WIDTH, DEFAULT_MAX_INLINE_IMAGES, MAX_INLINE_IMAGES, } from "../utils/images.js";
|
|
11
|
+
import { mapPool } from "../utils/pool.js";
|
|
11
12
|
const inputSchema = {
|
|
12
13
|
input: z.string().min(1).describe("Path to the source video file."),
|
|
13
14
|
mode: z
|
|
@@ -127,14 +128,17 @@ export function register(server) {
|
|
|
127
128
|
}
|
|
128
129
|
else {
|
|
129
130
|
const ts = mode === "scenes" ? sceneTimes : args.timestamps;
|
|
130
|
-
|
|
131
|
+
const outs = await mapPool(ts, async (t, i) => {
|
|
131
132
|
const out = join(dir, `frame_${String(i).padStart(3, "0")}_${t}s.png`);
|
|
132
133
|
rmSync(out, { force: true });
|
|
133
134
|
await runFfmpeg(buildSampleAtTimestampArgs(args.input, t, out), 60_000, { signal: extra.signal });
|
|
135
|
+
return out;
|
|
136
|
+
});
|
|
137
|
+
for (const [i, out] of outs.entries()) {
|
|
134
138
|
if (existsSync(out))
|
|
135
139
|
frames.push(out);
|
|
136
140
|
else
|
|
137
|
-
skipped.push(
|
|
141
|
+
skipped.push(ts[i]);
|
|
138
142
|
}
|
|
139
143
|
}
|
|
140
144
|
const inline = args.returnImages === false
|
package/dist/tools/stepGuide.js
CHANGED
|
@@ -11,10 +11,10 @@ import { inputSteps } from "../utils/steps.js";
|
|
|
11
11
|
import { readMarkers } from "../utils/chapters.js";
|
|
12
12
|
import { ocrStatus } from "../utils/capabilities.js";
|
|
13
13
|
import { readFrames, scanMatches } from "../utils/ocrScan.js";
|
|
14
|
-
import { DEFAULT_SECRET_PATTERN } from "../utils/bugReport.js";
|
|
14
|
+
import { DEFAULT_SECRET_PATTERN, resolveSource } from "../utils/bugReport.js";
|
|
15
15
|
import { resolveOutputDir, subdir, stamp, rand } from "../utils/paths.js";
|
|
16
16
|
import { GUIDE_FILES, HTML_IMAGE_LADDER, HTML_MAX_BYTES, MAX_GUIDE_STEPS, assignSections, base64Bytes, buildHtmlImageArgs, buildGuideHtml, buildGuideMarkdown, buildStepFrameArgs, buildStepShotArgs, caption, guideSteps, htmlImageName, labelAt, nextHtmlRung, shotFilter, } from "../utils/stepGuide.js";
|
|
17
|
-
import {
|
|
17
|
+
import { mapPool } from "../utils/pool.js";
|
|
18
18
|
const OCR_BATCH = 10;
|
|
19
19
|
const HTML_SAMPLE = 5;
|
|
20
20
|
const inputSchema = {
|
|
@@ -84,18 +84,17 @@ export function register(server) {
|
|
|
84
84
|
const total = shots.length * (useOcr ? 3 : 2) || 1;
|
|
85
85
|
let done = 0;
|
|
86
86
|
const tick = () => progress?.(++done / total);
|
|
87
|
-
const frames =
|
|
88
|
-
for (const { s } of shots) {
|
|
87
|
+
const frames = await mapPool(shots, async ({ s }) => {
|
|
89
88
|
const out = join(work, `frame-${String(s.n).padStart(3, "0")}.png`);
|
|
90
89
|
await runFfmpeg(buildStepFrameArgs(source.path, s.shotT, out), 60_000, { signal: extra.signal });
|
|
91
|
-
frames.push(out);
|
|
92
90
|
tick();
|
|
93
|
-
|
|
91
|
+
return out;
|
|
92
|
+
});
|
|
94
93
|
const read = frames.map(() => null);
|
|
95
94
|
if (useOcr) {
|
|
96
95
|
for (let b = 0; b < frames.length; b += OCR_BATCH) {
|
|
97
96
|
extra.signal.throwIfAborted();
|
|
98
|
-
const batch = await readFrames(frames.slice(b, b + OCR_BATCH), work, extra.signal);
|
|
97
|
+
const batch = await readFrames(frames.slice(b, b + OCR_BATCH), work, extra.signal, { sameSize: true });
|
|
99
98
|
batch.forEach((f, k) => {
|
|
100
99
|
read[b + k] = f;
|
|
101
100
|
tick();
|
|
@@ -121,18 +120,22 @@ export function register(server) {
|
|
|
121
120
|
}
|
|
122
121
|
mkdirSync(imageDir, { recursive: true });
|
|
123
122
|
let redactions = 0;
|
|
124
|
-
|
|
123
|
+
const frameSize = { width: info.width, height: info.height };
|
|
124
|
+
const rendered = await mapPool(shots, async ({ i }, k) => {
|
|
125
125
|
const step = steps[i];
|
|
126
126
|
const file = GUIDE_FILES.image(step.n);
|
|
127
127
|
const ring = step.x !== undefined && step.y !== undefined ? { x: step.x, y: step.y } : undefined;
|
|
128
|
-
const filter = shotFilter(
|
|
128
|
+
const filter = shotFilter(frameSize, { click: ring, boxes: boxes[k] });
|
|
129
129
|
const out = join(imageDir, file);
|
|
130
130
|
await runFfmpeg(buildStepShotArgs(frames[k], filter, out), 60_000, { signal: extra.signal });
|
|
131
|
+
tick();
|
|
132
|
+
return { step, file, out };
|
|
133
|
+
});
|
|
134
|
+
for (const [k, { step, file, out }] of rendered.entries()) {
|
|
131
135
|
if (wantMd)
|
|
132
136
|
written.push(out);
|
|
133
137
|
step.image = file;
|
|
134
138
|
redactions += boxes[k].length;
|
|
135
|
-
tick();
|
|
136
139
|
}
|
|
137
140
|
const stepsNote = all.length === 0 ? "The event log has no clicks, shortcuts, typing, or scrolls." : undefined;
|
|
138
141
|
const data = {
|
package/dist/tools/titleCard.js
CHANGED
|
@@ -6,9 +6,9 @@ import { requireFfmpeg } from "../utils/ffmpeg.js";
|
|
|
6
6
|
import { runEditJob } from "../utils/jobs.js";
|
|
7
7
|
import { buildTitleCardArgs, DEFAULT_TITLE_DURATION } from "../utils/produce.js";
|
|
8
8
|
import { resolveTextFont } from "../utils/fonts.js";
|
|
9
|
-
import { fontFileSchema } from "./callout.js";
|
|
10
9
|
import { resolveOutput, subdir, stamp, rand, tempPath } from "../utils/paths.js";
|
|
11
10
|
import { assertEditContainer } from "../utils/media.js";
|
|
11
|
+
import { fontFileSchema } from "../utils/callout.js";
|
|
12
12
|
const inputSchema = {
|
|
13
13
|
text: z.string().min(1).describe("Title text. Multiple lines are allowed (use \\n)."),
|
|
14
14
|
duration: z.number().positive().optional().describe("Card length in seconds (default 3)."),
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { errorResponse, okResponse } from "../utils/errors.js";
|
|
3
3
|
import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
|
|
4
|
-
import { requireFfmpeg, runFfmpeg,
|
|
4
|
+
import { requireFfmpeg, runFfmpeg, runFfmpegFrames } from "../utils/ffmpeg.js";
|
|
5
5
|
import { resolveCaptureTarget } from "../utils/resolveTarget.js";
|
|
6
6
|
import { buildScreenshotArgs } from "../utils/targets.js";
|
|
7
|
-
import { detectionSize, targetSize,
|
|
7
|
+
import { detectionSize, targetSize, buildRawStreamArgs, targetDiffOptions, DEFAULT_PIXEL_THRESHOLD, } from "../utils/diff.js";
|
|
8
|
+
import { waitLoop } from "../utils/waitLoop.js";
|
|
9
|
+
import { FrameQueue } from "../utils/frameQueue.js";
|
|
8
10
|
import { windowMatchReport } from "../utils/windows.js";
|
|
9
11
|
import { confirmCapture, describeTarget } from "../utils/consent.js";
|
|
10
12
|
import { subdir, stamp, rand } from "../utils/paths.js";
|
|
@@ -55,7 +57,6 @@ const inputSchema = {
|
|
|
55
57
|
.optional()
|
|
56
58
|
.describe("Keep the final screenshot on disk and return its path (default false)."),
|
|
57
59
|
};
|
|
58
|
-
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
59
60
|
export function register(server) {
|
|
60
61
|
server.registerTool("wait_for_change", {
|
|
61
62
|
title: "Wait for Screen Change",
|
|
@@ -81,55 +82,36 @@ export function register(server) {
|
|
|
81
82
|
await confirmCapture(server, `Watch ${describeTarget(args.target, window)} for up to ${timeoutMs / 1000} s, until it ${mode === "settle" ? "stops changing" : "changes"}?`, extra.signal);
|
|
82
83
|
const area = targetSize(target, monitors);
|
|
83
84
|
const size = detectionSize(area.width, area.height);
|
|
84
|
-
const grab = () => runFfmpegBuffer(buildRawGrabArgs(target, monitors, size), 15_000, { signal: extra.signal });
|
|
85
85
|
const opts = targetDiffOptions(area, size, args.pixelThreshold);
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
let
|
|
90
|
-
let
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
86
|
+
const frames = new FrameQueue();
|
|
87
|
+
const stop = new AbortController();
|
|
88
|
+
const capture = runFfmpegFrames(buildRawStreamArgs(target, monitors, size, 1000 / interval), size.width * size.height, (f) => frames.push(f), timeoutMs + 60_000, { signal: AbortSignal.any([extra.signal, stop.signal]) }).then(() => frames.end(), (err) => frames.fail(err));
|
|
89
|
+
let loop;
|
|
90
|
+
let endedAt = 0;
|
|
91
|
+
try {
|
|
92
|
+
loop = await waitLoop({
|
|
93
|
+
grab: () => frames.next(15_000),
|
|
94
|
+
mode,
|
|
95
|
+
width: size.width,
|
|
96
|
+
height: size.height,
|
|
97
|
+
diff: opts,
|
|
98
|
+
timeoutMs,
|
|
99
|
+
settleMs,
|
|
100
|
+
intervalMs: interval,
|
|
101
|
+
signal: extra.signal,
|
|
102
|
+
sleep: async () => { },
|
|
103
103
|
});
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const d = diffFrames(baseline, current, size.width, size.height, opts);
|
|
110
|
-
if (d.regions.length > 0) {
|
|
111
|
-
regions = d.regions;
|
|
112
|
-
outcome = "changed";
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
const changed = settle.push(current);
|
|
118
|
-
if (changed.length > 0) {
|
|
119
|
-
everChanged = true;
|
|
120
|
-
lastChangeAt = Date.now();
|
|
121
|
-
regions = changed;
|
|
122
|
-
}
|
|
123
|
-
else if (Date.now() - lastChangeAt >= settleMs) {
|
|
124
|
-
outcome = "settled";
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
104
|
+
endedAt = Date.now();
|
|
105
|
+
}
|
|
106
|
+
finally {
|
|
107
|
+
stop.abort();
|
|
108
|
+
await capture;
|
|
128
109
|
}
|
|
110
|
+
const { outcome, regions, everChanged, startedAt: started } = loop;
|
|
129
111
|
const result = {
|
|
130
112
|
outcome,
|
|
131
113
|
mode,
|
|
132
|
-
elapsedSec: Number(((
|
|
114
|
+
elapsedSec: Number(((endedAt - started) / 1000).toFixed(2)),
|
|
133
115
|
...(mode === "settle" ? { changedWhileWaiting: everChanged } : {}),
|
|
134
116
|
regions,
|
|
135
117
|
origin: { x: area.x, y: area.y },
|
package/dist/tools/zoom.js
CHANGED
|
@@ -1,31 +1,16 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { existsSync
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
3
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
4
|
import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
|
|
5
5
|
import { requireFfmpeg, runFfmpegFrames, probeMedia } from "../utils/ffmpeg.js";
|
|
6
6
|
import { runEditJob, jobTimeoutMs } from "../utils/jobs.js";
|
|
7
7
|
import { analysisSize } from "../utils/diff.js";
|
|
8
|
-
import { keyframesToViews, buildZoomArgs, createAutoZoomPlanner, planClickZoom, buildAnalysisArgs, DEFAULT_TRANSITION_SEC, DEFAULT_AUTO_MAX_ZOOM, DEFAULT_RING_COLOR, MAX_ZOOM, } from "../utils/zoom.js";
|
|
9
|
-
import { eventPaths
|
|
8
|
+
import { keyframesToViews, buildZoomArgs, createAutoZoomPlanner, planClickZoom, buildAnalysisArgs, DEFAULT_TRANSITION_SEC, DEFAULT_AUTO_MAX_ZOOM, DEFAULT_RING_COLOR, MAX_ZOOM, readClicks, zoomKeyframeSchema, } from "../utils/zoom.js";
|
|
9
|
+
import { eventPaths } from "../utils/events.js";
|
|
10
10
|
import { validateColor } from "../utils/validate.js";
|
|
11
11
|
export const MAX_RINGS = 200;
|
|
12
|
-
export function readClicks(path) {
|
|
13
|
-
if (!existsSync(path))
|
|
14
|
-
return null;
|
|
15
|
-
return parseEventsJsonl(readFileSync(path, "utf8"))
|
|
16
|
-
.filter((e) => e.type === "down" && e.inFrame)
|
|
17
|
-
.map((e) => ({ t: e.t, x: e.x, y: e.y }));
|
|
18
|
-
}
|
|
19
12
|
import { editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
20
13
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
21
|
-
export const zoomKeyframeSchema = z.object({
|
|
22
|
-
t: z.number().nonnegative(),
|
|
23
|
-
x: z.number().optional(),
|
|
24
|
-
y: z.number().optional(),
|
|
25
|
-
width: z.number().positive().optional(),
|
|
26
|
-
height: z.number().positive().optional(),
|
|
27
|
-
full: z.boolean().optional(),
|
|
28
|
-
});
|
|
29
14
|
const inputSchema = {
|
|
30
15
|
input: z.string().min(1).describe("Path to the source video."),
|
|
31
16
|
keyframes: z
|
package/dist/utils/audio.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { extname } from "node:path";
|
|
2
2
|
import { ScreencastError } from "./errors.js";
|
|
3
3
|
import { isAudioOnlyPath } from "./media.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
export const LOUDNESS_PRESET_NAMES = ["youtube", "podcast", "broadcast"];
|
|
6
|
+
export const loudnessTargetSchema = z.union([z.enum(LOUDNESS_PRESET_NAMES), z.number().min(-70).max(-5)]);
|
|
4
7
|
export const LOUDNESS_PRESETS = {
|
|
5
8
|
youtube: { i: -14, tp: -1, lra: 11 },
|
|
6
9
|
podcast: { i: -16, tp: -1.5, lra: 11 },
|
|
@@ -76,6 +79,7 @@ export function buildLoudnessApplyArgs(input, output, t, m) {
|
|
|
76
79
|
output,
|
|
77
80
|
];
|
|
78
81
|
}
|
|
82
|
+
export const DENOISE_STRENGTHS = ["light", "medium", "strong"];
|
|
79
83
|
export const DENOISE_NR = { light: 6, medium: 12, strong: 20 };
|
|
80
84
|
export function buildNoiseFloorArgs(input) {
|
|
81
85
|
return [
|
package/dist/utils/backdrop.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ScreencastError } from "./errors.js";
|
|
2
2
|
import { validateColor } from "./validate.js";
|
|
3
|
-
import { ASPECT_DIMS } from "./produce.js";
|
|
3
|
+
import { ASPECT_DIMS, ASPECTS } from "./produce.js";
|
|
4
4
|
import { resolveQuality } from "./targets.js";
|
|
5
5
|
import { stillOutput } from "./paths.js";
|
|
6
|
+
import { z } from "zod";
|
|
6
7
|
export const BACKDROP_PRESETS = {
|
|
7
8
|
desktop: ["#1B2330", "#0A0D12"],
|
|
8
9
|
rec: ["#FF4545", "#5C0F1A"],
|
|
@@ -149,3 +150,13 @@ export function buildBackdropArgs(input, output, opts, src, still = false, quali
|
|
|
149
150
|
: [...head, "-map", "0:a?", ...resolveQuality(quality), "-c:a", "copy", "-movflags", "+faststart", output];
|
|
150
151
|
return { args, layout };
|
|
151
152
|
}
|
|
153
|
+
export const backdropOptionsSchema = {
|
|
154
|
+
preset: z.enum(BACKDROP_PRESET_NAMES).optional(),
|
|
155
|
+
colors: z.array(z.string()).min(1).max(MAX_BACKDROP_COLORS).optional(),
|
|
156
|
+
image: z.string().min(1).optional(),
|
|
157
|
+
padding: z.number().int().nonnegative().max(2000).optional(),
|
|
158
|
+
radius: z.number().int().nonnegative().max(1000).optional(),
|
|
159
|
+
shadow: z.number().int().nonnegative().max(200).optional(),
|
|
160
|
+
shadowOpacity: z.number().min(0).max(1).optional(),
|
|
161
|
+
aspect: z.enum(ASPECTS).optional(),
|
|
162
|
+
};
|
package/dist/utils/bugReport.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ScreencastError } from "./errors.js";
|
|
2
2
|
import { findMatches, normalizeForMatch, regexRanges } from "./ocr.js";
|
|
3
3
|
import { formatTimecode } from "./sheet.js";
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
5
|
+
import { eventPaths, whenFinalized } from "./events.js";
|
|
6
|
+
import { getStore } from "../context.js";
|
|
4
7
|
export const DEFAULT_CLIP_SEC = 30;
|
|
5
8
|
export const MAX_CLIP_SEC = 600;
|
|
6
9
|
export const DEFAULT_SCAN_EVERY_SEC = 1;
|
|
@@ -170,3 +173,23 @@ export function buildReportMarkdown(r) {
|
|
|
170
173
|
: `Not scanned for secrets${red.manual > 0 ? ` (${red.manual} region${red.manual === 1 ? "" : "s"} boxed out by hand)` : ""}: review the clip before posting.`, `Generated by screencast-mcp bug_report, ${r.createdAt}.`, "</sub>", "");
|
|
171
174
|
return out.join("\n");
|
|
172
175
|
}
|
|
176
|
+
export async function resolveSource(args) {
|
|
177
|
+
if (args.sessionId !== undefined) {
|
|
178
|
+
const record = getStore().get(args.sessionId);
|
|
179
|
+
if (!record)
|
|
180
|
+
throw new ScreencastError(`No session with id "${args.sessionId}".`);
|
|
181
|
+
if (record.status === "recording" || record.status === "paused") {
|
|
182
|
+
throw new ScreencastError("The recording is still running; stop_recording it first.");
|
|
183
|
+
}
|
|
184
|
+
await whenFinalized(record.id);
|
|
185
|
+
if (!existsSync(record.outputPath))
|
|
186
|
+
throw new ScreencastError(`The session's recording is missing: ${record.outputPath}`);
|
|
187
|
+
const events = record.events?.path;
|
|
188
|
+
return { path: record.outputPath, eventsPath: events && existsSync(events) ? events : null, record };
|
|
189
|
+
}
|
|
190
|
+
const path = args.input;
|
|
191
|
+
if (!existsSync(path))
|
|
192
|
+
throw new ScreencastError(`Input file not found: ${path}`);
|
|
193
|
+
const { jsonl } = eventPaths(path);
|
|
194
|
+
return { path, eventsPath: existsSync(jsonl) ? jsonl : null };
|
|
195
|
+
}
|
package/dist/utils/callout.js
CHANGED
|
@@ -4,6 +4,7 @@ import { enableExpr } from "./media.js";
|
|
|
4
4
|
import { resolveQuality } from "./targets.js";
|
|
5
5
|
import { validateColor } from "./validate.js";
|
|
6
6
|
import { stillOutput } from "./paths.js";
|
|
7
|
+
import { z } from "zod";
|
|
7
8
|
const nonNeg = (v, label) => {
|
|
8
9
|
if (!Number.isFinite(v) || v < 0)
|
|
9
10
|
throw new ScreencastError(`${label} must be a non-negative number.`);
|
|
@@ -73,8 +74,12 @@ export function calloutSteps(items, assets, input, firstInput, tag) {
|
|
|
73
74
|
});
|
|
74
75
|
return { steps, out: cur, extraInputs };
|
|
75
76
|
}
|
|
76
|
-
export function buildCalloutArgs(input, output, items, assets, quality = "standard") {
|
|
77
|
-
const {
|
|
77
|
+
export function buildCalloutArgs(input, output, items, assets, quality = "standard", still = false) {
|
|
78
|
+
const drawn = still ? items.map(({ from: _f, to: _t, ...c }) => c) : items;
|
|
79
|
+
const { steps, out, extraInputs } = calloutSteps(drawn, assets, "[0:v]", 1, "");
|
|
80
|
+
if (still) {
|
|
81
|
+
return ["-y", "-i", input, ...extraInputs, "-filter_complex", steps.join(";"), "-map", out, "-frames:v", "1", ...stillOutput(output)];
|
|
82
|
+
}
|
|
78
83
|
return [
|
|
79
84
|
"-y", "-i", input, ...extraInputs,
|
|
80
85
|
"-filter_complex", steps.join(";"),
|
|
@@ -84,3 +89,44 @@ export function buildCalloutArgs(input, output, items, assets, quality = "standa
|
|
|
84
89
|
output,
|
|
85
90
|
];
|
|
86
91
|
}
|
|
92
|
+
const timing = {
|
|
93
|
+
from: z.number().nonnegative().optional(),
|
|
94
|
+
to: z.number().positive().optional(),
|
|
95
|
+
color: z.string().optional(),
|
|
96
|
+
};
|
|
97
|
+
export const fontFileSchema = z
|
|
98
|
+
.string()
|
|
99
|
+
.min(1)
|
|
100
|
+
.optional()
|
|
101
|
+
.describe("Font: a .ttf/.otf/.ttc path or a C:\\Windows\\Fonts file name. Default: bundled Inter, with a " +
|
|
102
|
+
"covering system font for scripts it lacks (CJK, emoji, Arabic, ...).");
|
|
103
|
+
export const calloutItemSchema = z.discriminatedUnion("type", [
|
|
104
|
+
z.object({
|
|
105
|
+
type: z.literal("box"),
|
|
106
|
+
x: z.number(),
|
|
107
|
+
y: z.number(),
|
|
108
|
+
width: z.number().positive(),
|
|
109
|
+
height: z.number().positive(),
|
|
110
|
+
thickness: z.number().positive().optional().describe("Outline px (default 4)."),
|
|
111
|
+
fill: z.boolean().optional().describe("Fill instead of outline."),
|
|
112
|
+
...timing,
|
|
113
|
+
}),
|
|
114
|
+
z.object({
|
|
115
|
+
type: z.literal("text"),
|
|
116
|
+
x: z.number(),
|
|
117
|
+
y: z.number(),
|
|
118
|
+
text: z.string().min(1),
|
|
119
|
+
size: z.number().positive().optional().describe("Font size px (default 32)."),
|
|
120
|
+
background: z.boolean().optional().describe("Dark panel behind the text (default true)."),
|
|
121
|
+
...timing,
|
|
122
|
+
}),
|
|
123
|
+
z.object({
|
|
124
|
+
type: z.literal("arrow"),
|
|
125
|
+
x1: z.number(),
|
|
126
|
+
y1: z.number(),
|
|
127
|
+
x2: z.number().describe("Head (x2,y2) is the point the arrow points at."),
|
|
128
|
+
y2: z.number(),
|
|
129
|
+
thickness: z.number().positive().optional().describe("Shaft px (default 8)."),
|
|
130
|
+
...timing,
|
|
131
|
+
}),
|
|
132
|
+
]);
|
package/dist/utils/captions.js
CHANGED
|
@@ -81,6 +81,7 @@ export function normalizeCues(cues) {
|
|
|
81
81
|
export function formatSrt(cues) {
|
|
82
82
|
return cues.map((c, i) => `${i + 1}\n${fmt(c.start)} --> ${fmt(c.end)}\n${c.text}\n`).join("\n");
|
|
83
83
|
}
|
|
84
|
+
export const CAPTION_STYLE_NAMES = ["clean", "social"];
|
|
84
85
|
export const CAPTION_STYLES = {
|
|
85
86
|
clean: "FontName=Inter,FontSize=16,PrimaryColour=&H00FFFFFF,OutlineColour=&H00000000,BorderStyle=1,Outline=1.5,Shadow=0,MarginV=16",
|
|
86
87
|
social: "FontName=Inter,Bold=1,FontSize=22,PrimaryColour=&H00FFFFFF,BackColour=&H99000000,BorderStyle=3,Outline=6,Shadow=0,MarginV=40",
|