@tmhs/screencast-mcp 0.49.0 → 0.50.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 +13 -8
- package/dist/index.js +550 -106
- package/dist/wgcRecorder.js +15 -139
- package/package.json +8 -4
- package/assets/.gitkeep +0 -0
- package/assets/icon.png +0 -0
- package/dist/cli.js +0 -516
- package/dist/context.js +0 -50
- package/dist/prompts.js +0 -95
- package/dist/resources.js +0 -93
- package/dist/server.js +0 -174
- package/dist/setup.js +0 -438
- package/dist/tools/addMarker.js +0 -93
- package/dist/tools/assembleHighlights.js +0 -69
- package/dist/tools/backdrop.js +0 -89
- package/dist/tools/bugReport.js +0 -266
- package/dist/tools/burnSubtitles.js +0 -56
- package/dist/tools/callout.js +0 -103
- package/dist/tools/chapters.js +0 -156
- package/dist/tools/clip.js +0 -52
- package/dist/tools/compress.js +0 -51
- package/dist/tools/concat.js +0 -67
- package/dist/tools/contactSheet.js +0 -135
- package/dist/tools/convert.js +0 -46
- package/dist/tools/crop.js +0 -43
- package/dist/tools/cursor.js +0 -87
- package/dist/tools/cutByTranscript.js +0 -86
- package/dist/tools/cutIdle.js +0 -84
- package/dist/tools/deleteRecording.js +0 -119
- package/dist/tools/denoise.js +0 -60
- package/dist/tools/doctor.js +0 -146
- package/dist/tools/exportGif.js +0 -57
- package/dist/tools/exportPreset.js +0 -48
- package/dist/tools/extractAudio.js +0 -65
- package/dist/tools/findText.js +0 -196
- package/dist/tools/getMediaInfo.js +0 -36
- package/dist/tools/getSession.js +0 -40
- package/dist/tools/indexRecording.js +0 -195
- package/dist/tools/keystrokeOverlay.js +0 -131
- package/dist/tools/listAudioDevices.js +0 -35
- package/dist/tools/listSessions.js +0 -28
- package/dist/tools/listTargets.js +0 -76
- package/dist/tools/listVideoDevices.js +0 -26
- package/dist/tools/musicBed.js +0 -55
- package/dist/tools/narrate.js +0 -86
- package/dist/tools/normalizeAudio.js +0 -60
- package/dist/tools/overlay.js +0 -62
- package/dist/tools/pauseRecording.js +0 -44
- package/dist/tools/pipeline.js +0 -400
- package/dist/tools/readEvents.js +0 -98
- package/dist/tools/redactRegion.js +0 -70
- package/dist/tools/reframe.js +0 -46
- package/dist/tools/resumeRecording.js +0 -46
- package/dist/tools/reviewRecording.js +0 -163
- package/dist/tools/sampleFrames.js +0 -200
- package/dist/tools/saveReplay.js +0 -90
- package/dist/tools/scale.js +0 -44
- package/dist/tools/screenDiff.js +0 -86
- package/dist/tools/screenshot.js +0 -76
- package/dist/tools/searchRecording.js +0 -79
- package/dist/tools/speed.js +0 -46
- package/dist/tools/startRecording.js +0 -398
- package/dist/tools/stepGuide.js +0 -250
- package/dist/tools/stopRecording.js +0 -132
- package/dist/tools/titleCard.js +0 -67
- package/dist/tools/transcribe.js +0 -66
- package/dist/tools/trim.js +0 -57
- package/dist/tools/waitForChange.js +0 -128
- package/dist/tools/xfadeTransition.js +0 -58
- package/dist/tools/zoom.js +0 -149
- package/dist/utils/anim.js +0 -54
- package/dist/utils/animExport.js +0 -56
- package/dist/utils/argPaths.js +0 -39
- package/dist/utils/audio.js +0 -113
- package/dist/utils/audioDevices.js +0 -107
- package/dist/utils/backdrop.js +0 -151
- package/dist/utils/bugReport.js +0 -172
- package/dist/utils/callout.js +0 -90
- package/dist/utils/calloutAssets.js +0 -42
- package/dist/utils/capabilities.js +0 -96
- package/dist/utils/captions.js +0 -103
- package/dist/utils/chapters.js +0 -227
- package/dist/utils/consent.js +0 -29
- package/dist/utils/cursor.js +0 -317
- package/dist/utils/diff.js +0 -184
- package/dist/utils/errors.js +0 -29
- package/dist/utils/events.js +0 -403
- package/dist/utils/expr.js +0 -11
- package/dist/utils/ffmpeg.js +0 -285
- package/dist/utils/fontCoverage.js +0 -177
- package/dist/utils/fonts.js +0 -154
- package/dist/utils/gpu.js +0 -219
- package/dist/utils/idle.js +0 -91
- package/dist/utils/images.js +0 -38
- package/dist/utils/jobs.js +0 -129
- package/dist/utils/keystrokes.js +0 -155
- package/dist/utils/lifecycle.js +0 -233
- package/dist/utils/logging.js +0 -75
- package/dist/utils/media.js +0 -574
- package/dist/utils/monitors.js +0 -124
- package/dist/utils/narrate.js +0 -233
- package/dist/utils/ocr.js +0 -222
- package/dist/utils/ocrScan.js +0 -91
- package/dist/utils/paths.js +0 -155
- package/dist/utils/pause.js +0 -190
- package/dist/utils/pipeline.js +0 -361
- package/dist/utils/player.js +0 -85
- package/dist/utils/pool.js +0 -29
- package/dist/utils/produce.js +0 -298
- package/dist/utils/recipes.js +0 -71
- package/dist/utils/recorder.js +0 -173
- package/dist/utils/recordingFiles.js +0 -32
- package/dist/utils/recordingIndex.js +0 -312
- package/dist/utils/replay.js +0 -283
- package/dist/utils/resolveTarget.js +0 -25
- package/dist/utils/retention.js +0 -48
- package/dist/utils/roots.js +0 -43
- package/dist/utils/sessions.js +0 -499
- package/dist/utils/sheet.js +0 -59
- package/dist/utils/stepGuide.js +0 -231
- package/dist/utils/steps.js +0 -88
- package/dist/utils/still.js +0 -38
- package/dist/utils/targetList.js +0 -64
- package/dist/utils/targets.js +0 -265
- package/dist/utils/timeline.js +0 -85
- package/dist/utils/toolSpec.js +0 -31
- package/dist/utils/toolsets.js +0 -134
- package/dist/utils/transcriptCut.js +0 -149
- package/dist/utils/validate.js +0 -23
- package/dist/utils/waitLoop.js +0 -50
- package/dist/utils/wgc.js +0 -84
- package/dist/utils/windows.js +0 -192
- package/dist/utils/zoom.js +0 -234
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
-
import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
|
|
5
|
-
import { requireFfmpeg, runCapture } from "../utils/ffmpeg.js";
|
|
6
|
-
import { runEditJob, probeDuration } from "../utils/jobs.js";
|
|
7
|
-
import { buildExtractAudioArgs, buildProbeArgs, parseMediaInfo, copyAudioExtension, } from "../utils/media.js";
|
|
8
|
-
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
9
|
-
const EXTENSION = {
|
|
10
|
-
mp3: "mp3",
|
|
11
|
-
aac: "m4a",
|
|
12
|
-
wav: "wav",
|
|
13
|
-
};
|
|
14
|
-
const inputSchema = {
|
|
15
|
-
input: z.string().min(1).describe("Path to the source media."),
|
|
16
|
-
format: z
|
|
17
|
-
.enum(["mp3", "aac", "wav", "copy"])
|
|
18
|
-
.describe("Audio output codec. copy keeps the source codec without re-encoding."),
|
|
19
|
-
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
20
|
-
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
21
|
-
};
|
|
22
|
-
export function register(server) {
|
|
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) => {
|
|
31
|
-
try {
|
|
32
|
-
const { ffprobe } = requireFfmpeg();
|
|
33
|
-
if (!existsSync(args.input)) {
|
|
34
|
-
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
35
|
-
}
|
|
36
|
-
const format = args.format;
|
|
37
|
-
let audioCodec = null;
|
|
38
|
-
let ext;
|
|
39
|
-
if (format === "copy") {
|
|
40
|
-
const res = await runCapture(ffprobe, buildProbeArgs(args.input), 30_000, { signal: extra.signal });
|
|
41
|
-
if (res.code !== 0) {
|
|
42
|
-
throw new ScreencastError(`ffprobe failed (exit ${res.code}): ${res.stderr.trim().slice(-400)}`);
|
|
43
|
-
}
|
|
44
|
-
audioCodec = parseMediaInfo(JSON.parse(res.stdout)).audioCodec;
|
|
45
|
-
if (!audioCodec) {
|
|
46
|
-
throw new ScreencastError(`Input has no audio stream to extract: ${args.input}`);
|
|
47
|
-
}
|
|
48
|
-
ext = copyAudioExtension(audioCodec);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
ext = EXTENSION[format];
|
|
52
|
-
}
|
|
53
|
-
const output = resolveOutput(args.output, subdir("edits"), `audio-${stamp()}-${rand()}.${ext}`, args.overwrite);
|
|
54
|
-
await runEditJob(buildExtractAudioArgs(args.input, output, format), { output, durationSec: await probeDuration(args.input), extra });
|
|
55
|
-
return okResponse({
|
|
56
|
-
outputPath: output,
|
|
57
|
-
format,
|
|
58
|
-
...(audioCodec ? { sourceAudioCodec: audioCodec } : {}),
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
return errorResponse(error);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
package/dist/tools/findText.js
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { extname, join } from "node:path";
|
|
3
|
-
import { existsSync, mkdtempSync, rmSync } from "node:fs";
|
|
4
|
-
import { tmpdir } from "node:os";
|
|
5
|
-
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
6
|
-
import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
|
|
7
|
-
import { requireFfmpeg, runFfmpeg } from "../utils/ffmpeg.js";
|
|
8
|
-
import { resolveCaptureTarget } from "../utils/resolveTarget.js";
|
|
9
|
-
import { captureStill } from "../utils/still.js";
|
|
10
|
-
import { buildHighlightArgs, targetSize } from "../utils/diff.js";
|
|
11
|
-
import { findMatches, redactionRects } from "../utils/ocr.js";
|
|
12
|
-
import { readFrames, scanVideoFrames, scanMatches } from "../utils/ocrScan.js";
|
|
13
|
-
import { windowMatchReport } from "../utils/windows.js";
|
|
14
|
-
import { confirmCapture, describeTarget } from "../utils/consent.js";
|
|
15
|
-
import { subdir, stamp, rand, stillOutput } from "../utils/paths.js";
|
|
16
|
-
import { encodeInlineImages, DEFAULT_MAX_IMAGE_WIDTH } from "../utils/images.js";
|
|
17
|
-
const IMAGE_EXTENSIONS = new Set([".png", ".jpg", ".jpeg", ".bmp", ".gif", ".webp", ".tif", ".tiff"]);
|
|
18
|
-
const MAX_LINES = 300;
|
|
19
|
-
export const DEFAULT_SCAN_FRAMES = 30;
|
|
20
|
-
export const MAX_SCAN_FRAMES = 120;
|
|
21
|
-
const inputSchema = {
|
|
22
|
-
target: z
|
|
23
|
-
.string()
|
|
24
|
-
.optional()
|
|
25
|
-
.describe("Live screen target (full | monitor:<i> | window:... | region:...), or pass input."),
|
|
26
|
-
input: z.string().optional().describe("Image or video file to read instead of a live target."),
|
|
27
|
-
timestamp: z.number().nonnegative().optional().describe("Video input: second to read (default 0)."),
|
|
28
|
-
scanEverySec: z
|
|
29
|
-
.number()
|
|
30
|
-
.positive()
|
|
31
|
-
.optional()
|
|
32
|
-
.describe("Video input: scan a frame every N s across the clip (e.g. for secrets before sharing); matches " +
|
|
33
|
-
"and redactRegions get times. Widens to stay within maxFrames."),
|
|
34
|
-
maxFrames: z
|
|
35
|
-
.number()
|
|
36
|
-
.int()
|
|
37
|
-
.min(1)
|
|
38
|
-
.max(MAX_SCAN_FRAMES)
|
|
39
|
-
.optional()
|
|
40
|
-
.describe(`scanEverySec frame cap (default ${DEFAULT_SCAN_FRAMES}; ~1 s each).`),
|
|
41
|
-
exactTitle: z.boolean().optional().describe("window: targets match the whole title only (default false)."),
|
|
42
|
-
backend: z
|
|
43
|
-
.enum(["gdigrab", "wgc"])
|
|
44
|
-
.optional()
|
|
45
|
-
.describe("Live target: gdigrab (default) = what is visible; wgc (window:, FFmpeg 8+) = the window even if covered."),
|
|
46
|
-
query: z
|
|
47
|
-
.string()
|
|
48
|
-
.optional()
|
|
49
|
-
.describe("Text to find (case-insensitive, tolerates OCR misreads like I/l, O/0, _/-). Omit to return all text."),
|
|
50
|
-
regex: z.boolean().optional().describe("Treat query as a regular expression (case-insensitive)."),
|
|
51
|
-
redact: z
|
|
52
|
-
.boolean()
|
|
53
|
-
.optional()
|
|
54
|
-
.describe("Also return padded match rectangles ready for redact_region's regions."),
|
|
55
|
-
keep: z
|
|
56
|
-
.boolean()
|
|
57
|
-
.optional()
|
|
58
|
-
.describe("Live target: keep the capture and return its path (default false: deleted after reading)."),
|
|
59
|
-
returnImage: z
|
|
60
|
-
.boolean()
|
|
61
|
-
.optional()
|
|
62
|
-
.describe("Return the image with matches outlined (default: true with a query)."),
|
|
63
|
-
};
|
|
64
|
-
export function register(server) {
|
|
65
|
-
server.registerTool("find_text", {
|
|
66
|
-
title: "Find Text (OCR)",
|
|
67
|
-
description: "OCR (built into Windows) on the screen, an image, or video frames, with line and match boxes " +
|
|
68
|
-
"in image pixels (add `origin` for desktop coordinates). Locate UI text or secrets (e.g. regex " +
|
|
69
|
-
"'sk-|ghp_|api.?key') to redact. Best-effort: review results.",
|
|
70
|
-
inputSchema,
|
|
71
|
-
outputSchema: looseOutput({
|
|
72
|
-
imageSize: looseOutput({ width: z.number(), height: z.number() }),
|
|
73
|
-
}),
|
|
74
|
-
annotations: READ_ONLY,
|
|
75
|
-
}, async (args, extra) => {
|
|
76
|
-
try {
|
|
77
|
-
requireFfmpeg();
|
|
78
|
-
if ((args.target === undefined) === (args.input === undefined)) {
|
|
79
|
-
throw new ScreencastError("Provide exactly one of: target (live screen) or input (a file).");
|
|
80
|
-
}
|
|
81
|
-
const work = mkdtempSync(join(tmpdir(), "screencast-ocr-"));
|
|
82
|
-
try {
|
|
83
|
-
if (args.scanEverySec !== undefined)
|
|
84
|
-
return await scanClip(args, work, extra.signal);
|
|
85
|
-
let source;
|
|
86
|
-
let windowReport = {};
|
|
87
|
-
let origin;
|
|
88
|
-
if (args.target !== undefined) {
|
|
89
|
-
const resolved = await resolveCaptureTarget(args.target, { exactTitle: args.exactTitle, backend: args.backend });
|
|
90
|
-
source = args.keep ? join(subdir("screenshots"), `ocr-${stamp()}-${rand()}.png`) : join(work, "capture.png");
|
|
91
|
-
const backend = args.backend ?? "gdigrab";
|
|
92
|
-
await confirmCapture(server, `Capture ${describeTarget(args.target, resolved.window)} once to read the text on it?`, extra.signal);
|
|
93
|
-
await captureStill(resolved, source, backend);
|
|
94
|
-
if (resolved.window)
|
|
95
|
-
windowReport = windowMatchReport(resolved.window);
|
|
96
|
-
const area = targetSize(resolved.target, resolved.monitors);
|
|
97
|
-
origin = backend === "wgc" && resolved.window?.client ? resolved.window.client : { x: area.x, y: area.y };
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
if (!existsSync(args.input))
|
|
101
|
-
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
102
|
-
const isImage = IMAGE_EXTENSIONS.has(extname(args.input).toLowerCase());
|
|
103
|
-
source = join(work, "frame.png");
|
|
104
|
-
await runFfmpeg(["-y", "-v", "error", ...(isImage ? [] : ["-ss", String(args.timestamp ?? 0)]), "-i", args.input, "-frames:v", "1", ...stillOutput(source)], 60_000, { signal: extra.signal });
|
|
105
|
-
}
|
|
106
|
-
const [frame] = await readFrames([source], work, extra.signal);
|
|
107
|
-
if (!frame)
|
|
108
|
-
throw new ScreencastError("Could not read the frame.");
|
|
109
|
-
const { lines, width, height } = frame;
|
|
110
|
-
const matches = args.query ? findMatches(lines, args.query, args.regex === true) : [];
|
|
111
|
-
const images = [];
|
|
112
|
-
const wantImage = args.returnImage ?? Boolean(args.query);
|
|
113
|
-
if (wantImage) {
|
|
114
|
-
const shown = join(work, "shown.png");
|
|
115
|
-
await runFfmpeg(buildHighlightArgs(source, matches, shown), 30_000, { signal: extra.signal });
|
|
116
|
-
images.push(...(await encodeInlineImages([shown], DEFAULT_MAX_IMAGE_WIDTH, 1)).images);
|
|
117
|
-
}
|
|
118
|
-
return okResponse({
|
|
119
|
-
...(args.target !== undefined ? (args.keep ? { screenshotPath: source } : {}) : { input: args.input }),
|
|
120
|
-
imageSize: { width, height },
|
|
121
|
-
...(origin ? { origin } : {}),
|
|
122
|
-
...(args.query
|
|
123
|
-
? {
|
|
124
|
-
query: args.query,
|
|
125
|
-
matchCount: matches.length,
|
|
126
|
-
matches,
|
|
127
|
-
...(args.redact ? { redactRegions: redactionRects(matches, { width, height }) } : {}),
|
|
128
|
-
}
|
|
129
|
-
: {}),
|
|
130
|
-
text: lines.map((l) => l.text).join("\n"),
|
|
131
|
-
lines: lines.slice(0, MAX_LINES).map(({ words: _w, ...l }) => l),
|
|
132
|
-
...(lines.length > MAX_LINES ? { linesTruncated: lines.length - MAX_LINES } : {}),
|
|
133
|
-
...windowReport,
|
|
134
|
-
note: "OCR is best-effort: small or stylised text can be missed. Review before relying on it, especially for redaction.",
|
|
135
|
-
}, images);
|
|
136
|
-
}
|
|
137
|
-
finally {
|
|
138
|
-
rmSync(work, { recursive: true, force: true });
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
catch (error) {
|
|
142
|
-
return errorResponse(error);
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
async function scanClip(args, work, signal) {
|
|
147
|
-
if (args.input === undefined)
|
|
148
|
-
throw new ScreencastError("scanEverySec reads a video file: pass input, not target.");
|
|
149
|
-
if (!existsSync(args.input))
|
|
150
|
-
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
151
|
-
if (IMAGE_EXTENSIONS.has(extname(args.input).toLowerCase())) {
|
|
152
|
-
throw new ScreencastError("scanEverySec is for a video input; an image has one frame, so drop scanEverySec.");
|
|
153
|
-
}
|
|
154
|
-
const maxFrames = args.maxFrames ?? DEFAULT_SCAN_FRAMES;
|
|
155
|
-
const scan = await scanVideoFrames(args.input, { everySec: args.scanEverySec, maxFrames }, work, signal);
|
|
156
|
-
const { step } = scan;
|
|
157
|
-
const [size] = scan.frames;
|
|
158
|
-
if (!size)
|
|
159
|
-
throw new ScreencastError("Could not read any frames from the video.");
|
|
160
|
-
const seenLines = new Set();
|
|
161
|
-
for (const frame of scan.frames)
|
|
162
|
-
for (const l of frame.lines)
|
|
163
|
-
seenLines.add(l.text);
|
|
164
|
-
const { matches, redactRegions } = args.query
|
|
165
|
-
? scanMatches(scan, args.query, args.regex === true)
|
|
166
|
-
: { matches: [], redactRegions: [] };
|
|
167
|
-
const images = [];
|
|
168
|
-
const first = matches[0];
|
|
169
|
-
const firstFrame = first && scan.frames.find((f) => f.t === first.t)?.path;
|
|
170
|
-
if ((args.returnImage ?? Boolean(args.query)) && first && firstFrame) {
|
|
171
|
-
const shown = join(work, "shown.png");
|
|
172
|
-
await runFfmpeg(buildHighlightArgs(firstFrame, matches.filter((m) => m.t === first.t), shown), 30_000, { signal });
|
|
173
|
-
images.push(...(await encodeInlineImages([shown], DEFAULT_MAX_IMAGE_WIDTH, 1)).images);
|
|
174
|
-
}
|
|
175
|
-
const text = [...seenLines].join("\n");
|
|
176
|
-
return okResponse({
|
|
177
|
-
input: args.input,
|
|
178
|
-
imageSize: { width: size.width, height: size.height },
|
|
179
|
-
scan: {
|
|
180
|
-
everySec: Math.round(step * 1000) / 1000,
|
|
181
|
-
framesScanned: scan.frames.length,
|
|
182
|
-
...(scan.clamped ? { note: `Widened from ${args.scanEverySec} s to fit maxFrames ${maxFrames}.` } : {}),
|
|
183
|
-
},
|
|
184
|
-
...(args.query
|
|
185
|
-
? {
|
|
186
|
-
query: args.query,
|
|
187
|
-
matchCount: matches.length,
|
|
188
|
-
matches: matches.slice(0, MAX_LINES),
|
|
189
|
-
...(args.redact ? { redactRegions } : {}),
|
|
190
|
-
}
|
|
191
|
-
: {}),
|
|
192
|
-
text: text.length > 20_000 ? `${text.slice(0, 20_000)}...` : text,
|
|
193
|
-
note: "OCR is best-effort and reads only the sampled frames: text shown briefly between samples, or small " +
|
|
194
|
-
"or stylised text, can be missed. Review before sharing, especially for redaction.",
|
|
195
|
-
}, images);
|
|
196
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
-
import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
|
|
5
|
-
import { probeMedia } from "../utils/ffmpeg.js";
|
|
6
|
-
const inputSchema = {
|
|
7
|
-
input: z.string().min(1).describe("Path to the media file to probe."),
|
|
8
|
-
};
|
|
9
|
-
export function register(server) {
|
|
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) => {
|
|
26
|
-
try {
|
|
27
|
-
if (!existsSync(args.input)) {
|
|
28
|
-
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
29
|
-
}
|
|
30
|
-
return okResponse({ input: args.input, ...(await probeMedia(args.input)) });
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
return errorResponse(error);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
package/dist/tools/getSession.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
-
import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
|
|
5
|
-
import { isAlive } from "../utils/sessions.js";
|
|
6
|
-
import { getStore } from "../context.js";
|
|
7
|
-
const inputSchema = {
|
|
8
|
-
sessionId: z.string().min(1).describe("Session id returned by start_recording."),
|
|
9
|
-
};
|
|
10
|
-
export function register(server) {
|
|
11
|
-
server.registerTool("get_session", {
|
|
12
|
-
title: "Get Session",
|
|
13
|
-
description: "Inspect a single recording session by id, including live status and " +
|
|
14
|
-
"whether its output file exists on disk.",
|
|
15
|
-
inputSchema,
|
|
16
|
-
outputSchema: looseOutput({
|
|
17
|
-
id: z.string(),
|
|
18
|
-
status: z.string(),
|
|
19
|
-
outputPath: z.string(),
|
|
20
|
-
alive: z.boolean(),
|
|
21
|
-
fileExists: z.boolean(),
|
|
22
|
-
}),
|
|
23
|
-
annotations: READ_ONLY,
|
|
24
|
-
}, async (args) => {
|
|
25
|
-
try {
|
|
26
|
-
const record = getStore().get(args.sessionId);
|
|
27
|
-
if (!record) {
|
|
28
|
-
throw new ScreencastError(`No session with id "${args.sessionId}".`);
|
|
29
|
-
}
|
|
30
|
-
return okResponse({
|
|
31
|
-
...record,
|
|
32
|
-
alive: record.status === "recording" && isAlive(record.pid),
|
|
33
|
-
fileExists: existsSync(record.outputPath),
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
return errorResponse(error);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { dirname, join } from "node:path";
|
|
3
|
-
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync } from "node:fs";
|
|
4
|
-
import { tmpdir } from "node:os";
|
|
5
|
-
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
6
|
-
import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
|
|
7
|
-
import { requireFfmpeg, runFfmpeg, runCapture, probeMedia, hasFilter } from "../utils/ffmpeg.js";
|
|
8
|
-
import { jobTimeoutMs, progressReporter } from "../utils/jobs.js";
|
|
9
|
-
import { buildSceneScanArgs, parseSceneScan, buildSampleAtTimestampArgs } from "../utils/media.js";
|
|
10
|
-
import { readFrames } from "../utils/ocrScan.js";
|
|
11
|
-
import { ocrStatus } from "../utils/capabilities.js";
|
|
12
|
-
import { parseEventsJsonl } from "../utils/events.js";
|
|
13
|
-
import { resolveWhisperModel, buildTranscribeArgs, parseSrt, normalizeCues } from "../utils/captions.js";
|
|
14
|
-
import { subdir, tempPath } from "../utils/paths.js";
|
|
15
|
-
import { DEFAULT_INDEX_FRAMES, DEFAULT_INDEX_THRESHOLD, INDEX_VERSION, MAX_INDEX_FRAMES, attach, canReuseIndex, cueTexts, defaultTranscriptPath, eventTexts, fingerprintFile, findIndex, indexMatchesVideo, indexWritePath, keyframeTime, legacyIndexSidecarPath, markerTexts, maskSegmentText, mergeSegments, planKeyframes, readIndex, resolveRecording, segmentsFrom, writeIndex, } from "../utils/recordingIndex.js";
|
|
16
|
-
import { mapPool } from "../utils/pool.js";
|
|
17
|
-
const OCR_BATCH = 8;
|
|
18
|
-
const inputSchema = {
|
|
19
|
-
input: z.string().optional().describe("Recording path."),
|
|
20
|
-
sessionId: z.string().optional().describe("Or a stopped session id."),
|
|
21
|
-
sceneThreshold: z.number().gt(0).lt(1).optional().describe(`Change starting a segment (default ${DEFAULT_INDEX_THRESHOLD}).`),
|
|
22
|
-
maxFrames: z.number().int().min(1).max(MAX_INDEX_FRAMES).optional().describe(`Keyframes to OCR (default ${DEFAULT_INDEX_FRAMES}).`),
|
|
23
|
-
transcript: z.string().optional().describe("An .srt, or 'whisper' to transcribe. Default: <video>.srt if any."),
|
|
24
|
-
force: z.boolean().optional().describe("Re-OCR despite a matching cached index."),
|
|
25
|
-
};
|
|
26
|
-
export function register(server) {
|
|
27
|
-
server.registerTool("index_recording", {
|
|
28
|
-
title: "Index Recording",
|
|
29
|
-
description: "Build a recording's text timeline (<video>.index.json: OCR per scene, events, markers, transcript) " +
|
|
30
|
-
"for search_recording.",
|
|
31
|
-
inputSchema,
|
|
32
|
-
outputSchema: looseOutput({ indexPath: z.string(), segments: z.number() }),
|
|
33
|
-
annotations: WRITES_FILE,
|
|
34
|
-
}, async (args, extra) => {
|
|
35
|
-
const work = mkdtempSync(join(tmpdir(), "screencast-index-"));
|
|
36
|
-
try {
|
|
37
|
-
const { ffmpeg } = requireFfmpeg();
|
|
38
|
-
const source = await resolveRecording(args);
|
|
39
|
-
const info = await probeMedia(source.path);
|
|
40
|
-
const duration = info.videoDurationSec ?? info.durationSec;
|
|
41
|
-
if (!info.width || duration === null || !(duration > 0)) {
|
|
42
|
-
throw new ScreencastError(`Could not read the video size and duration of ${source.path}.`);
|
|
43
|
-
}
|
|
44
|
-
const threshold = args.sceneThreshold ?? DEFAULT_INDEX_THRESHOLD;
|
|
45
|
-
const maxFrames = args.maxFrames ?? DEFAULT_INDEX_FRAMES;
|
|
46
|
-
const edits = subdir("edits");
|
|
47
|
-
const outPath = indexWritePath(source.path, edits);
|
|
48
|
-
const fingerprint = fingerprintFile(source.path);
|
|
49
|
-
const report = progressReporter(extra);
|
|
50
|
-
const notes = [];
|
|
51
|
-
const existingPath = args.force ? null : findIndex(source.path, edits, fingerprint);
|
|
52
|
-
const prior = existingPath ? readIndex(existingPath) : null;
|
|
53
|
-
let ocrNow = null;
|
|
54
|
-
const ocrAvailable = async () => (ocrNow ??= process.platform === "win32" && (await ocrStatus()).available);
|
|
55
|
-
const cached = canReuseIndex(prior, {
|
|
56
|
-
fingerprint,
|
|
57
|
-
sceneThreshold: threshold,
|
|
58
|
-
maxFrames,
|
|
59
|
-
ocrAvailable: prior !== null && !prior.ocr ? await ocrAvailable() : false,
|
|
60
|
-
});
|
|
61
|
-
let segments;
|
|
62
|
-
let framesRead = 0;
|
|
63
|
-
let ocr = false;
|
|
64
|
-
if (cached) {
|
|
65
|
-
segments = prior.segments;
|
|
66
|
-
framesRead = prior.framesRead;
|
|
67
|
-
ocr = prior.ocr;
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
const scan = await runCapture(ffmpeg, buildSceneScanArgs(source.path, threshold), jobTimeoutMs(duration), {
|
|
71
|
-
signal: extra.signal,
|
|
72
|
-
});
|
|
73
|
-
if (scan.code !== 0)
|
|
74
|
-
throw new ScreencastError(`Scene scan failed (exit ${scan.code}): ${scan.stderr.trim().slice(-400)}`);
|
|
75
|
-
report?.(0.1);
|
|
76
|
-
const spans = segmentsFrom(planKeyframes(parseSceneScan(scan.stdout), duration, maxFrames), duration);
|
|
77
|
-
const texts = spans.map(() => []);
|
|
78
|
-
ocr = await ocrAvailable();
|
|
79
|
-
if (ocr) {
|
|
80
|
-
for (let b = 0; b < spans.length; b += OCR_BATCH) {
|
|
81
|
-
extra.signal.throwIfAborted();
|
|
82
|
-
const batch = spans.slice(b, b + OCR_BATCH);
|
|
83
|
-
const grabbed = await mapPool(batch, async (span, i) => {
|
|
84
|
-
const out = join(work, `key_${b + i}.png`);
|
|
85
|
-
await runFfmpeg(buildSampleAtTimestampArgs(source.path, keyframeTime(span), out), 60_000, { signal: extra.signal });
|
|
86
|
-
return { at: b + i, path: out };
|
|
87
|
-
});
|
|
88
|
-
const frames = grabbed.filter((f) => existsSync(f.path));
|
|
89
|
-
const read = frames.length > 0 ? await readFrames(frames.map((f) => f.path), work, extra.signal, { sameSize: true }) : [];
|
|
90
|
-
read.forEach((f, i) => (texts[frames[i].at] = f.lines.map((l) => l.text)));
|
|
91
|
-
framesRead += read.length;
|
|
92
|
-
report?.(0.1 + (0.85 * Math.min(spans.length, b + OCR_BATCH)) / spans.length);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
notes.push("Windows OCR is not available, so the index holds no screen text; install an OCR language (doctor).");
|
|
97
|
-
}
|
|
98
|
-
const read = spans.map((s, i) => ({ ...s, ocr: texts[i] ?? [] }));
|
|
99
|
-
segments = ocr ? mergeSegments(read) : read;
|
|
100
|
-
}
|
|
101
|
-
segments = maskSegmentText(segments);
|
|
102
|
-
const events = source.eventsPath ? eventTexts(parseEventsJsonl(readFileSync(source.eventsPath, "utf8"))) : [];
|
|
103
|
-
segments = attach(segments, events, "events");
|
|
104
|
-
segments = attach(segments, markerTexts(source.markers), "markers");
|
|
105
|
-
const cues = await transcriptCues(args.transcript, source.path, info.audioCodec !== null, duration, extra.signal, notes);
|
|
106
|
-
if (cues !== null)
|
|
107
|
-
segments = attach(segments, cueTexts(cues), "transcript");
|
|
108
|
-
else if (cached && prior) {
|
|
109
|
-
const kept = prior.segments.flatMap((s) => s.transcript ?? []);
|
|
110
|
-
segments = attach(segments, kept, "transcript");
|
|
111
|
-
}
|
|
112
|
-
const index = {
|
|
113
|
-
version: INDEX_VERSION,
|
|
114
|
-
video: source.path,
|
|
115
|
-
fingerprint,
|
|
116
|
-
durationSec: duration,
|
|
117
|
-
createdAt: new Date().toISOString(),
|
|
118
|
-
sceneThreshold: threshold,
|
|
119
|
-
maxFrames,
|
|
120
|
-
framesRead,
|
|
121
|
-
ocr,
|
|
122
|
-
segments,
|
|
123
|
-
};
|
|
124
|
-
mkdirSync(join(outPath, ".."), { recursive: true });
|
|
125
|
-
writeIndex(outPath, index);
|
|
126
|
-
const legacy = legacyIndexSidecarPath(source.path);
|
|
127
|
-
if (legacy !== outPath && existsSync(legacy)) {
|
|
128
|
-
const old = readIndex(legacy);
|
|
129
|
-
if (old && indexMatchesVideo(old, source.path, fingerprint))
|
|
130
|
-
rmSync(legacy, { force: true });
|
|
131
|
-
}
|
|
132
|
-
report?.(1);
|
|
133
|
-
const count = (f) => segments.reduce((n, s) => n + (s[f]?.length ?? 0), 0);
|
|
134
|
-
return okResponse({
|
|
135
|
-
indexPath: outPath,
|
|
136
|
-
segments: segments.length,
|
|
137
|
-
cached,
|
|
138
|
-
framesRead,
|
|
139
|
-
durationSec: duration,
|
|
140
|
-
sources: {
|
|
141
|
-
screenLines: segments.reduce((n, s) => n + s.ocr.length, 0),
|
|
142
|
-
events: count("events"),
|
|
143
|
-
markers: count("markers"),
|
|
144
|
-
transcriptCues: count("transcript"),
|
|
145
|
-
},
|
|
146
|
-
...(notes.length > 0 ? { note: notes.join(" ") } : {}),
|
|
147
|
-
next: "search_recording { query } returns timecoded hits. Secret-shaped screen text is stored masked; the rest " +
|
|
148
|
-
"of the index is plain text, so treat it like the video.",
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
catch (error) {
|
|
152
|
-
return errorResponse(error);
|
|
153
|
-
}
|
|
154
|
-
finally {
|
|
155
|
-
rmSync(work, { recursive: true, force: true });
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
async function transcriptCues(arg, video, hasAudio, duration, signal, notes) {
|
|
160
|
-
if (arg === "whisper") {
|
|
161
|
-
if (!hasAudio) {
|
|
162
|
-
notes.push("The recording has no audio, so there is no transcript.");
|
|
163
|
-
return null;
|
|
164
|
-
}
|
|
165
|
-
if (!hasFilter("whisper")) {
|
|
166
|
-
throw new ScreencastError("This ffmpeg has no whisper filter.", "transcript: 'whisper' needs FFmpeg 8 built with whisper.cpp; or pass an .srt.");
|
|
167
|
-
}
|
|
168
|
-
const model = resolveWhisperModel(undefined);
|
|
169
|
-
const raw = tempPath(".srt");
|
|
170
|
-
try {
|
|
171
|
-
await runFfmpeg(buildTranscribeArgs(video, model, raw), jobTimeoutMs(duration), { signal });
|
|
172
|
-
return existsSync(raw) ? normalizeCues(parseSrt(readFileSync(raw, "utf8"))) : [];
|
|
173
|
-
}
|
|
174
|
-
finally {
|
|
175
|
-
rmSync(raw, { force: true });
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
if (arg !== undefined) {
|
|
179
|
-
if (!existsSync(arg))
|
|
180
|
-
throw new ScreencastError(`Transcript not found: ${arg}`);
|
|
181
|
-
return normalizeCues(parseSrt(readFileSync(arg, "utf8")));
|
|
182
|
-
}
|
|
183
|
-
let siblings;
|
|
184
|
-
try {
|
|
185
|
-
siblings = readdirSync(dirname(video));
|
|
186
|
-
}
|
|
187
|
-
catch {
|
|
188
|
-
return null;
|
|
189
|
-
}
|
|
190
|
-
const found = defaultTranscriptPath(video, siblings);
|
|
191
|
-
if (found.ambiguous) {
|
|
192
|
-
notes.push("Another video in the folder shares this one's base name, so its .srt was not attached; pass transcript.");
|
|
193
|
-
}
|
|
194
|
-
return found.path ? normalizeCues(parseSrt(readFileSync(found.path, "utf8"))) : null;
|
|
195
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
-
import { tmpdir } from "node:os";
|
|
5
|
-
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
6
|
-
import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
|
|
7
|
-
import { requireFfmpeg, probeMedia } from "../utils/ffmpeg.js";
|
|
8
|
-
import { runEditJob } from "../utils/jobs.js";
|
|
9
|
-
import { eventPaths, parseEventsJsonl } from "../utils/events.js";
|
|
10
|
-
import { resolveTextFont } from "../utils/fonts.js";
|
|
11
|
-
import { planBadges, groupBadges, buildKeystrokeArgs, BADGE_POSITIONS, DEFAULT_LINGER_SEC, } from "../utils/keystrokes.js";
|
|
12
|
-
import { editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
13
|
-
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
14
|
-
import { fontFileSchema } from "./callout.js";
|
|
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
|
-
};
|
|
26
|
-
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
|
-
const inputSchema = {
|
|
56
|
-
input: z.string().min(1).describe("Path to the recording."),
|
|
57
|
-
events: o.events.describe("Event log (default: the input's .events.jsonl)."),
|
|
58
|
-
clicks: o.clicks.describe("Show clicks (default true)."),
|
|
59
|
-
typing: o.typing.describe('Show typing as "Typing…" (default true).'),
|
|
60
|
-
keys: o.keys.describe("shortcuts (default): the chord (Ctrl + S); masked: modifiers only (Ctrl + …)."),
|
|
61
|
-
lingerSec: o.lingerSec.describe(`Seconds a badge stays up (default ${DEFAULT_LINGER_SEC}).`),
|
|
62
|
-
position: o.position.describe("Default bottom (centred)."),
|
|
63
|
-
size: o.size.describe("Font px (default 4.5% of the frame height)."),
|
|
64
|
-
color: o.color.describe("Text color (default white)."),
|
|
65
|
-
fontFile: fontFileSchema,
|
|
66
|
-
dryRun: z.boolean().optional().describe("Return the planned badges; write nothing."),
|
|
67
|
-
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
68
|
-
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
69
|
-
};
|
|
70
|
-
export function register(server) {
|
|
71
|
-
server.registerTool("keystroke_overlay", {
|
|
72
|
-
title: "Keystroke Overlay",
|
|
73
|
-
description: "Burn keycast-style badges for shortcuts, clicks, and typing from the recording's input event log " +
|
|
74
|
-
"(start_recording events: true). Never shows typed text: the log has none.",
|
|
75
|
-
inputSchema,
|
|
76
|
-
outputSchema: looseOutput({ badges: z.number().int() }),
|
|
77
|
-
annotations: WRITES_FILE,
|
|
78
|
-
}, async (args, extra) => {
|
|
79
|
-
try {
|
|
80
|
-
requireFfmpeg();
|
|
81
|
-
if (!existsSync(args.input))
|
|
82
|
-
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
83
|
-
const plan = { clicks: args.clicks, typing: args.typing, keys: args.keys, lingerSec: args.lingerSec };
|
|
84
|
-
const { badges, shortcutsLogged } = loadBadges(args.input, args.events, plan);
|
|
85
|
-
const note = shortcutsLogged === 0
|
|
86
|
-
? 'The log names no shortcuts (recorded with keys: "masked"), so only clicks and typing can show.'
|
|
87
|
-
: undefined;
|
|
88
|
-
if (badges.length === 0) {
|
|
89
|
-
return okResponse({ badges: 0, note: "Nothing to show: the log has no clicks, shortcuts, or typing; nothing written." });
|
|
90
|
-
}
|
|
91
|
-
const groups = groupBadges(badges);
|
|
92
|
-
if (args.dryRun) {
|
|
93
|
-
const assets = prepareKeystrokeAssets(groups.map((g) => g.label), null, "", args.fontFile);
|
|
94
|
-
return okResponse({
|
|
95
|
-
dryRun: true,
|
|
96
|
-
badges: badges.length,
|
|
97
|
-
plan: badges,
|
|
98
|
-
...(assets.fallbackFont && { fallbackFont: assets.fallbackFont }),
|
|
99
|
-
...(assets.warnings.length > 0 && { warnings: assets.warnings }),
|
|
100
|
-
...(note && { note }),
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
assertEditContainer(args.output);
|
|
104
|
-
const info = await probeMedia(args.input);
|
|
105
|
-
if (!info.height)
|
|
106
|
-
throw new ScreencastError(`Could not read the size of ${args.input}.`);
|
|
107
|
-
const output = resolveOutput(args.output, subdir("edits"), `keys-${stamp()}-${rand()}${editOutputExt(args.input)}`, args.overwrite);
|
|
108
|
-
const work = mkdtempSync(join(tmpdir(), "screencast-keys-"));
|
|
109
|
-
try {
|
|
110
|
-
const assets = prepareKeystrokeAssets(groups.map((g) => g.label), work, "", args.fontFile);
|
|
111
|
-
const style = { position: args.position, size: args.size, color: args.color };
|
|
112
|
-
const ffArgs = buildKeystrokeArgs(args.input, output, groups, assets, style, { height: info.height });
|
|
113
|
-
await runEditJob(ffArgs, { output, durationSec: info.durationSec, extra });
|
|
114
|
-
return okResponse({
|
|
115
|
-
outputPath: output,
|
|
116
|
-
badges: badges.length,
|
|
117
|
-
labels: groups.map((g) => g.label),
|
|
118
|
-
...(assets.fallbackFont && { fallbackFont: assets.fallbackFont }),
|
|
119
|
-
...(assets.warnings.length > 0 && { warnings: assets.warnings }),
|
|
120
|
-
...(note && { note }),
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
finally {
|
|
124
|
-
rmSync(work, { recursive: true, force: true });
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
return errorResponse(error);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}
|