@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
package/dist/tools/chapters.js
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { extname, 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, runCapture } from "../utils/ffmpeg.js";
|
|
8
|
-
import { jobTimeoutMs, runEditJob } from "../utils/jobs.js";
|
|
9
|
-
import { buildSceneScanArgs, parseSceneScan, editOutputExt, DEFAULT_SCENE_THRESHOLD } from "../utils/media.js";
|
|
10
|
-
import { parseSrt } from "../utils/captions.js";
|
|
11
|
-
import { buildChapters, buildChaptersMuxArgs, ffmetadata, markerPoints, markersOrChapters, scenePoints, transcriptPoints, youtubeChapters, YOUTUBE_MIN_CHAPTER_SEC, } from "../utils/chapters.js";
|
|
12
|
-
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
13
|
-
import { getStore } from "../context.js";
|
|
14
|
-
const CONTAINERS = new Set([".mp4", ".mkv", ".mov"]);
|
|
15
|
-
const MAX_SCENE_CHAPTERS = 12;
|
|
16
|
-
const inputSchema = {
|
|
17
|
-
input: z.string().min(1).optional().describe("Path to the video."),
|
|
18
|
-
sessionId: z.string().min(1).optional().describe("Or a stopped recording's id."),
|
|
19
|
-
from: z
|
|
20
|
-
.enum(["markers", "scenes", "transcript"])
|
|
21
|
-
.optional()
|
|
22
|
-
.describe("markers (default; add_marker, else the file's chapters), scenes (screen changes), or transcript (SRT sections)."),
|
|
23
|
-
chapters: z
|
|
24
|
-
.array(z.object({ start: z.number().min(0), title: z.string().min(1).max(100) }))
|
|
25
|
-
.min(1)
|
|
26
|
-
.max(200)
|
|
27
|
-
.optional()
|
|
28
|
-
.describe("Or explicit { start, title } chapters."),
|
|
29
|
-
transcript: z.string().optional().describe("The .srt for from: transcript."),
|
|
30
|
-
minChapterSec: z
|
|
31
|
-
.number()
|
|
32
|
-
.min(0)
|
|
33
|
-
.optional()
|
|
34
|
-
.describe(`Shortest chapter (default 1; scenes ${YOUTUBE_MIN_CHAPTER_SEC}, transcript 30).`),
|
|
35
|
-
subtitles: z.string().optional().describe("Also mux this .srt/.vtt/.ass as a soft subtitle track."),
|
|
36
|
-
subtitleLanguage: z.string().regex(/^[a-z]{3}$/).optional().describe('ISO 639-2, e.g. "eng".'),
|
|
37
|
-
textOnly: z.boolean().optional().describe("Return chapters and YouTube text only; write no file."),
|
|
38
|
-
output: z.string().optional().describe("Optional .mp4/.mkv/.mov path. Defaults under SCREENCAST_HOME/edits."),
|
|
39
|
-
overwrite: z.boolean().optional().describe("Allow replacing an existing output file."),
|
|
40
|
-
};
|
|
41
|
-
export function register(server) {
|
|
42
|
-
server.registerTool("chapters", {
|
|
43
|
-
title: "Chapters",
|
|
44
|
-
description: "Write chapters (markers, scene changes, transcript, or a list) into an mp4/mkv/mov copy without " +
|
|
45
|
-
"re-encoding; returns YouTube chapter text. Can mux an SRT as soft subtitles.",
|
|
46
|
-
inputSchema,
|
|
47
|
-
outputSchema: looseOutput({
|
|
48
|
-
chapters: z.array(looseOutput({ start: z.number(), end: z.number(), title: z.string() })),
|
|
49
|
-
youtube: z.string(),
|
|
50
|
-
}),
|
|
51
|
-
annotations: WRITES_FILE,
|
|
52
|
-
}, async (args, extra) => {
|
|
53
|
-
try {
|
|
54
|
-
requireFfmpeg();
|
|
55
|
-
let input = args.input;
|
|
56
|
-
let sessionMarkers;
|
|
57
|
-
if (args.sessionId) {
|
|
58
|
-
const record = getStore().get(args.sessionId);
|
|
59
|
-
if (!record)
|
|
60
|
-
throw new ScreencastError(`No session with id "${args.sessionId}".`);
|
|
61
|
-
if (record.status === "recording" || record.status === "paused")
|
|
62
|
-
throw new ScreencastError("The recording is still running; stop it first.");
|
|
63
|
-
input ??= record.outputPath;
|
|
64
|
-
sessionMarkers = record.markers;
|
|
65
|
-
}
|
|
66
|
-
if (!input)
|
|
67
|
-
throw new ScreencastError("Pass input or sessionId.");
|
|
68
|
-
if (!existsSync(input))
|
|
69
|
-
throw new ScreencastError(`Input file not found: ${input}`);
|
|
70
|
-
for (const f of [args.transcript, args.subtitles]) {
|
|
71
|
-
if (f !== undefined && !existsSync(f))
|
|
72
|
-
throw new ScreencastError(`File not found: ${f}`);
|
|
73
|
-
}
|
|
74
|
-
if (args.subtitles && !/\.(srt|vtt|ass|ssa)$/i.test(args.subtitles)) {
|
|
75
|
-
throw new ScreencastError("subtitles must be an .srt, .vtt, or .ass file.");
|
|
76
|
-
}
|
|
77
|
-
const info = await probeMedia(input);
|
|
78
|
-
const durationSec = info.durationSec;
|
|
79
|
-
if (!durationSec || durationSec <= 0)
|
|
80
|
-
throw new ScreencastError(`Could not read the duration of ${input}.`);
|
|
81
|
-
const from = args.chapters ? "list" : (args.from ?? "markers");
|
|
82
|
-
let points;
|
|
83
|
-
let minDefault = 1;
|
|
84
|
-
let source = from;
|
|
85
|
-
if (args.chapters) {
|
|
86
|
-
points = args.chapters;
|
|
87
|
-
}
|
|
88
|
-
else if (from === "scenes") {
|
|
89
|
-
minDefault = YOUTUBE_MIN_CHAPTER_SEC;
|
|
90
|
-
const { ffmpeg } = requireFfmpeg();
|
|
91
|
-
const scan = await runCapture(ffmpeg, buildSceneScanArgs(input, DEFAULT_SCENE_THRESHOLD), jobTimeoutMs(durationSec), { signal: extra.signal });
|
|
92
|
-
if (scan.code !== 0) {
|
|
93
|
-
throw new ScreencastError(`Scene scan failed (exit ${scan.code}): ${scan.stderr.trim().slice(-400)}`);
|
|
94
|
-
}
|
|
95
|
-
points = scenePoints(parseSceneScan(scan.stdout), args.minChapterSec ?? minDefault, MAX_SCENE_CHAPTERS);
|
|
96
|
-
}
|
|
97
|
-
else if (from === "transcript") {
|
|
98
|
-
if (!args.transcript)
|
|
99
|
-
throw new ScreencastError("from: transcript needs transcript (an .srt path).");
|
|
100
|
-
minDefault = 30;
|
|
101
|
-
points = transcriptPoints(parseSrt(readFileSync(args.transcript, "utf8")), { minChapterSec: args.minChapterSec ?? minDefault });
|
|
102
|
-
if (points.length === 0)
|
|
103
|
-
throw new ScreencastError(`No cues in ${args.transcript}.`);
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
let markers = sessionMarkers ?? [];
|
|
107
|
-
if (markers.length === 0) {
|
|
108
|
-
const found = await markersOrChapters(input, extra.signal);
|
|
109
|
-
markers = found.markers;
|
|
110
|
-
if (found.from === "chapters")
|
|
111
|
-
source = "embedded chapters";
|
|
112
|
-
}
|
|
113
|
-
if (markers.length === 0) {
|
|
114
|
-
throw new ScreencastError(`No markers for ${input}.`, "Add some with add_marker, or use from: scenes / transcript, or pass chapters.");
|
|
115
|
-
}
|
|
116
|
-
points = markerPoints(markers);
|
|
117
|
-
}
|
|
118
|
-
const chapters = buildChapters(points, durationSec, { minChapterSec: args.minChapterSec ?? minDefault });
|
|
119
|
-
if (chapters.length === 0)
|
|
120
|
-
throw new ScreencastError("No chapter falls inside the video.");
|
|
121
|
-
const yt = youtubeChapters(chapters, durationSec);
|
|
122
|
-
const result = {
|
|
123
|
-
source,
|
|
124
|
-
chapters,
|
|
125
|
-
youtube: yt.text,
|
|
126
|
-
...(yt.issues.length > 0 ? { youtubeIssues: yt.issues } : {}),
|
|
127
|
-
};
|
|
128
|
-
if (args.textOnly)
|
|
129
|
-
return okResponse(result);
|
|
130
|
-
const ext = (args.output ? extname(args.output).toLowerCase() : editOutputExt(input));
|
|
131
|
-
if (!CONTAINERS.has(ext)) {
|
|
132
|
-
throw new ScreencastError(`Chapters can be written to .mp4, .mkv, or .mov, not ${ext || "a file without an extension"}.`);
|
|
133
|
-
}
|
|
134
|
-
const output = resolveOutput(args.output, subdir("edits"), `chapters-${stamp()}-${rand()}${ext}`, args.overwrite);
|
|
135
|
-
const work = mkdtempSync(join(tmpdir(), "screencast-chapters-"));
|
|
136
|
-
try {
|
|
137
|
-
const meta = join(work, "chapters.txt");
|
|
138
|
-
writeFileSync(meta, ffmetadata(chapters));
|
|
139
|
-
await runEditJob(buildChaptersMuxArgs(input, meta, output, { container: ext, subtitles: args.subtitles, language: args.subtitleLanguage }), { output, durationSec, extra });
|
|
140
|
-
}
|
|
141
|
-
finally {
|
|
142
|
-
rmSync(work, { recursive: true, force: true });
|
|
143
|
-
}
|
|
144
|
-
return okResponse({
|
|
145
|
-
outputPath: output,
|
|
146
|
-
...result,
|
|
147
|
-
...(args.subtitles
|
|
148
|
-
? { subtitleTrack: { file: args.subtitles, codec: ext === ".mkv" ? "copy" : "mov_text", ...(args.subtitleLanguage ? { language: args.subtitleLanguage } : {}) } }
|
|
149
|
-
: {}),
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
catch (error) {
|
|
153
|
-
return errorResponse(error);
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
}
|
package/dist/tools/clip.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
-
import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
|
|
5
|
-
import { requireFfmpeg } from "../utils/ffmpeg.js";
|
|
6
|
-
import { runEditJob } from "../utils/jobs.js";
|
|
7
|
-
import { buildClipArgs, editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
8
|
-
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
9
|
-
const inputSchema = {
|
|
10
|
-
input: z.string().min(1).describe("Path to the source video."),
|
|
11
|
-
segments: z
|
|
12
|
-
.array(z.object({
|
|
13
|
-
start: z.number().nonnegative(),
|
|
14
|
-
end: z.number().positive(),
|
|
15
|
-
}))
|
|
16
|
-
.min(1)
|
|
17
|
-
.describe("{start, end} segments in seconds; each becomes its own file."),
|
|
18
|
-
output: z
|
|
19
|
-
.string()
|
|
20
|
-
.optional()
|
|
21
|
-
.describe("Optional output path. Only honored for a single segment; multi-segment output lands under SCREENCAST_HOME/edits."),
|
|
22
|
-
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
23
|
-
};
|
|
24
|
-
export function register(server) {
|
|
25
|
-
server.registerTool("clip", {
|
|
26
|
-
title: "Extract Clips",
|
|
27
|
-
description: "Extract several frame-exact segments, each to its own file. For one segment, trim does the same.",
|
|
28
|
-
inputSchema,
|
|
29
|
-
outputSchema: looseOutput({ outputs: z.array(z.string()), count: z.number().int() }),
|
|
30
|
-
annotations: WRITES_FILE,
|
|
31
|
-
}, async (args, extra) => {
|
|
32
|
-
try {
|
|
33
|
-
requireFfmpeg();
|
|
34
|
-
if (!existsSync(args.input)) {
|
|
35
|
-
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
36
|
-
}
|
|
37
|
-
assertEditContainer(args.output);
|
|
38
|
-
const ext = editOutputExt(args.input);
|
|
39
|
-
const single = args.segments.length === 1;
|
|
40
|
-
const outputs = [];
|
|
41
|
-
for (const [i, seg] of args.segments.entries()) {
|
|
42
|
-
const output = resolveOutput(single ? args.output : undefined, subdir("edits"), `clip-${stamp()}-${rand()}-${String(i).padStart(2, "0")}${ext}`, args.overwrite);
|
|
43
|
-
await runEditJob(buildClipArgs(args.input, output, seg), { output, durationSec: seg.end - seg.start, extra });
|
|
44
|
-
outputs.push(output);
|
|
45
|
-
}
|
|
46
|
-
return okResponse({ outputs, count: outputs.length });
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
return errorResponse(error);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
package/dist/tools/compress.js
DELETED
|
@@ -1,51 +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 } from "../utils/ffmpeg.js";
|
|
6
|
-
import { runEditJob, probeDuration } from "../utils/jobs.js";
|
|
7
|
-
import { buildCompressArgs, editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
8
|
-
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
9
|
-
const inputSchema = {
|
|
10
|
-
input: z.string().min(1).describe("Path to the source video."),
|
|
11
|
-
level: z
|
|
12
|
-
.enum(["light", "medium", "heavy"])
|
|
13
|
-
.optional()
|
|
14
|
-
.describe("CRF 23 / 28 / 32 (default medium)."),
|
|
15
|
-
maxWidth: z
|
|
16
|
-
.number()
|
|
17
|
-
.int()
|
|
18
|
-
.positive()
|
|
19
|
-
.optional()
|
|
20
|
-
.describe("Width cap in px (only downscales)."),
|
|
21
|
-
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
22
|
-
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
23
|
-
};
|
|
24
|
-
export function register(server) {
|
|
25
|
-
server.registerTool("compress", {
|
|
26
|
-
title: "Compress Video",
|
|
27
|
-
description: "Re-encode a video smaller (H.264 CRF ladder, optional width cap). For a platform target use export_preset.",
|
|
28
|
-
inputSchema,
|
|
29
|
-
outputSchema: OUTPUT_PATH,
|
|
30
|
-
annotations: WRITES_FILE,
|
|
31
|
-
}, async (args, extra) => {
|
|
32
|
-
try {
|
|
33
|
-
requireFfmpeg();
|
|
34
|
-
if (!existsSync(args.input)) {
|
|
35
|
-
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
36
|
-
}
|
|
37
|
-
assertEditContainer(args.output);
|
|
38
|
-
const ext = editOutputExt(args.input);
|
|
39
|
-
const output = resolveOutput(args.output, subdir("edits"), `compress-${stamp()}-${rand()}${ext}`, args.overwrite);
|
|
40
|
-
const ffArgs = buildCompressArgs(args.input, output, {
|
|
41
|
-
level: args.level,
|
|
42
|
-
maxWidth: args.maxWidth,
|
|
43
|
-
});
|
|
44
|
-
await runEditJob(ffArgs, { output, durationSec: await probeDuration(args.input), extra });
|
|
45
|
-
return okResponse({ outputPath: output, level: args.level ?? "medium" });
|
|
46
|
-
}
|
|
47
|
-
catch (error) {
|
|
48
|
-
return errorResponse(error);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
package/dist/tools/concat.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { extname, resolve } from "node:path";
|
|
3
|
-
import { existsSync, writeFileSync, rmSync } from "node:fs";
|
|
4
|
-
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
5
|
-
import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
|
|
6
|
-
import { requireFfmpeg, probeMedia } from "../utils/ffmpeg.js";
|
|
7
|
-
import { runEditJob } from "../utils/jobs.js";
|
|
8
|
-
import { buildConcatArgs, buildConcatListContent, concatCopyBlocker, editOutputExt, assertEditContainer, } from "../utils/media.js";
|
|
9
|
-
import { buildAssembleArgs, clipLength } from "../utils/produce.js";
|
|
10
|
-
import { resolveOutput, subdir, stamp, rand, tempPath } from "../utils/paths.js";
|
|
11
|
-
const inputSchema = {
|
|
12
|
-
inputs: z
|
|
13
|
-
.array(z.string().min(1))
|
|
14
|
-
.min(2)
|
|
15
|
-
.describe("Video paths to join, in order."),
|
|
16
|
-
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
17
|
-
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
18
|
-
};
|
|
19
|
-
export function register(server) {
|
|
20
|
-
server.registerTool("concat", {
|
|
21
|
-
title: "Concatenate Videos",
|
|
22
|
-
description: "Join videos end to end with hard cuts: stream copy when they match, else a re-encode (`mode` " +
|
|
23
|
-
"says which). For transitions use xfade_transition or assemble_highlights.",
|
|
24
|
-
inputSchema,
|
|
25
|
-
outputSchema: OUTPUT_PATH,
|
|
26
|
-
annotations: WRITES_FILE,
|
|
27
|
-
}, async (args, extra) => {
|
|
28
|
-
try {
|
|
29
|
-
requireFfmpeg();
|
|
30
|
-
const inputs = args.inputs.map((f) => resolve(f));
|
|
31
|
-
for (const f of inputs) {
|
|
32
|
-
if (!existsSync(f))
|
|
33
|
-
throw new ScreencastError(`Input file not found: ${f}`);
|
|
34
|
-
}
|
|
35
|
-
const infos = await Promise.all(inputs.map((f) => probeMedia(f)));
|
|
36
|
-
const [firstInput] = inputs;
|
|
37
|
-
const [first] = infos;
|
|
38
|
-
if (firstInput === undefined || first === undefined)
|
|
39
|
-
throw new ScreencastError("concat needs at least two inputs.");
|
|
40
|
-
const durations = infos.map((i) => clipLength(i));
|
|
41
|
-
const durationSec = durations.every((d) => d !== null) ? durations.reduce((a, d) => a + d, 0) : null;
|
|
42
|
-
const reason = concatCopyBlocker(inputs, infos);
|
|
43
|
-
if (reason !== null) {
|
|
44
|
-
assertEditContainer(args.output);
|
|
45
|
-
const output = resolveOutput(args.output, subdir("edits"), `concat-${stamp()}-${rand()}${editOutputExt(firstInput)}`, args.overwrite);
|
|
46
|
-
const even = (n) => (n !== null && n >= 2 ? n - (n % 2) : undefined);
|
|
47
|
-
const ffArgs = buildAssembleArgs(inputs, durations.map((d) => d ?? 0), output, { transition: "cut", width: even(first.width), height: even(first.height), fps: first.fps ?? undefined }, infos.map((i) => i.audioCodec !== null));
|
|
48
|
-
await runEditJob(ffArgs, { output, durationSec, extra });
|
|
49
|
-
return okResponse({ outputPath: output, inputCount: inputs.length, mode: "reencode", reason });
|
|
50
|
-
}
|
|
51
|
-
const ext = extname(firstInput) || ".mp4";
|
|
52
|
-
const output = resolveOutput(args.output, subdir("edits"), `concat-${stamp()}-${rand()}${ext}`, args.overwrite);
|
|
53
|
-
const listFile = tempPath(".txt");
|
|
54
|
-
writeFileSync(listFile, buildConcatListContent(inputs));
|
|
55
|
-
try {
|
|
56
|
-
await runEditJob(buildConcatArgs(listFile, output), { output, durationSec, extra });
|
|
57
|
-
}
|
|
58
|
-
finally {
|
|
59
|
-
rmSync(listFile, { force: true });
|
|
60
|
-
}
|
|
61
|
-
return okResponse({ outputPath: output, inputCount: inputs.length, mode: "copy" });
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
return errorResponse(error);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { existsSync, mkdtempSync, 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, runFfmpeg, runCapture, probeMedia } from "../utils/ffmpeg.js";
|
|
8
|
-
import { jobTimeoutMs } from "../utils/jobs.js";
|
|
9
|
-
import { buildSceneScanArgs, parseSceneScan, pickSceneFrames, DEFAULT_SCENE_THRESHOLD, } from "../utils/media.js";
|
|
10
|
-
import { evenTimes, formatTimecode, sheetGrid, buildTileArgs, buildSheetArgs, buildPosterArgs, DEFAULT_SHEET_COUNT, MAX_SHEET_COUNT, DEFAULT_TILE_WIDTH, } from "../utils/sheet.js";
|
|
11
|
-
import { bundledFontPath } from "../utils/fonts.js";
|
|
12
|
-
import { resolveOutput, subdir, stamp, rand, sequencePattern } from "../utils/paths.js";
|
|
13
|
-
import { encodeInlineImages, DEFAULT_MAX_IMAGE_WIDTH } from "../utils/images.js";
|
|
14
|
-
import { mapPool } from "../utils/pool.js";
|
|
15
|
-
const inputSchema = {
|
|
16
|
-
input: z.string().min(1).describe("Path to the source video."),
|
|
17
|
-
count: z
|
|
18
|
-
.number()
|
|
19
|
-
.int()
|
|
20
|
-
.min(1)
|
|
21
|
-
.max(MAX_SHEET_COUNT)
|
|
22
|
-
.optional()
|
|
23
|
-
.describe(`Frames to tile (default ${DEFAULT_SHEET_COUNT}).`),
|
|
24
|
-
mode: z
|
|
25
|
-
.enum(["even", "scenes"])
|
|
26
|
-
.optional()
|
|
27
|
-
.describe("even (default) or scenes (strongest changes; static stretches take no tiles)."),
|
|
28
|
-
sceneThreshold: z
|
|
29
|
-
.number()
|
|
30
|
-
.gt(0)
|
|
31
|
-
.lt(1)
|
|
32
|
-
.optional()
|
|
33
|
-
.describe(`Mode scenes: change needed, 0-1 (default ${DEFAULT_SCENE_THRESHOLD}).`),
|
|
34
|
-
columns: z.number().int().min(1).max(12).optional().describe("Tiles per row (default: roughly square)."),
|
|
35
|
-
tileWidth: z
|
|
36
|
-
.number()
|
|
37
|
-
.int()
|
|
38
|
-
.min(64)
|
|
39
|
-
.max(1920)
|
|
40
|
-
.optional()
|
|
41
|
-
.describe(`Tile width in px (default ${DEFAULT_TILE_WIDTH}).`),
|
|
42
|
-
poster: z
|
|
43
|
-
.boolean()
|
|
44
|
-
.optional()
|
|
45
|
-
.describe("Write one representative poster frame instead of a sheet."),
|
|
46
|
-
output: z.string().optional().describe("Optional output .png path. Defaults under SCREENCAST_HOME/frames."),
|
|
47
|
-
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
48
|
-
returnImage: z
|
|
49
|
-
.boolean()
|
|
50
|
-
.optional()
|
|
51
|
-
.describe("Return the sheet inline (default true)."),
|
|
52
|
-
maxImageWidth: z
|
|
53
|
-
.number()
|
|
54
|
-
.int()
|
|
55
|
-
.min(16)
|
|
56
|
-
.optional()
|
|
57
|
-
.describe(`Max inline image width (default ${DEFAULT_MAX_IMAGE_WIDTH}).`),
|
|
58
|
-
};
|
|
59
|
-
export async function renderContactSheet(input, times, output, opts, signal) {
|
|
60
|
-
const grid = sheetGrid(times.length, opts.columns);
|
|
61
|
-
const work = mkdtempSync(join(tmpdir(), "screencast-sheet-"));
|
|
62
|
-
try {
|
|
63
|
-
const font = bundledFontPath("bold");
|
|
64
|
-
await mapPool(times, async (t, i) => {
|
|
65
|
-
const labelFile = join(work, `label_${i}.txt`);
|
|
66
|
-
writeFileSync(labelFile, formatTimecode(t));
|
|
67
|
-
const tile = join(work, `tile_${String(i).padStart(3, "0")}.png`);
|
|
68
|
-
await runFfmpeg(buildTileArgs(input, t, tile, opts.tileWidth, font, labelFile), 60_000, { signal });
|
|
69
|
-
});
|
|
70
|
-
await runFfmpeg(buildSheetArgs(sequencePattern(work, "tile_%03d.png"), grid, output), 60_000, { signal });
|
|
71
|
-
}
|
|
72
|
-
finally {
|
|
73
|
-
rmSync(work, { recursive: true, force: true });
|
|
74
|
-
}
|
|
75
|
-
return grid;
|
|
76
|
-
}
|
|
77
|
-
export function register(server) {
|
|
78
|
-
server.registerTool("contact_sheet", {
|
|
79
|
-
title: "Contact Sheet",
|
|
80
|
-
description: "Tile timestamped frames of a video into one image to see a whole recording at a glance " +
|
|
81
|
-
"(the cheapest first look).",
|
|
82
|
-
inputSchema,
|
|
83
|
-
outputSchema: looseOutput({ outputPath: z.string(), inlineImages: z.number().int() }),
|
|
84
|
-
annotations: WRITES_FILE,
|
|
85
|
-
}, async (args, extra) => {
|
|
86
|
-
try {
|
|
87
|
-
const { ffmpeg } = requireFfmpeg();
|
|
88
|
-
if (!existsSync(args.input)) {
|
|
89
|
-
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
90
|
-
}
|
|
91
|
-
const { durationSec } = await probeMedia(args.input);
|
|
92
|
-
if (durationSec === null)
|
|
93
|
-
throw new ScreencastError(`Could not read duration of ${args.input}.`);
|
|
94
|
-
const kind = args.poster ? "poster" : "sheet";
|
|
95
|
-
const output = resolveOutput(args.output, subdir("frames"), `${kind}-${stamp()}-${rand()}.png`, args.overwrite);
|
|
96
|
-
const tileWidth = args.tileWidth ?? DEFAULT_TILE_WIDTH;
|
|
97
|
-
let result;
|
|
98
|
-
if (args.poster) {
|
|
99
|
-
await runFfmpeg(buildPosterArgs(args.input, durationSec, output, Math.max(tileWidth, 1280)), jobTimeoutMs(durationSec), {
|
|
100
|
-
signal: extra.signal,
|
|
101
|
-
});
|
|
102
|
-
result = { outputPath: output, poster: true };
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
const count = args.count ?? DEFAULT_SHEET_COUNT;
|
|
106
|
-
let times;
|
|
107
|
-
if (args.mode === "scenes") {
|
|
108
|
-
const scan = await runCapture(ffmpeg, buildSceneScanArgs(args.input, args.sceneThreshold ?? DEFAULT_SCENE_THRESHOLD), jobTimeoutMs(durationSec), { signal: extra.signal });
|
|
109
|
-
if (scan.code !== 0) {
|
|
110
|
-
throw new ScreencastError(`Scene scan failed (exit ${scan.code}): ${scan.stderr.trim().slice(-400)}`);
|
|
111
|
-
}
|
|
112
|
-
times = pickSceneFrames(parseSceneScan(scan.stdout), count);
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
times = evenTimes(durationSec, count);
|
|
116
|
-
}
|
|
117
|
-
const grid = await renderContactSheet(args.input, times, output, { tileWidth, columns: args.columns }, extra.signal);
|
|
118
|
-
result = {
|
|
119
|
-
outputPath: output,
|
|
120
|
-
mode: args.mode ?? "even",
|
|
121
|
-
frameTimes: times,
|
|
122
|
-
columns: grid.columns,
|
|
123
|
-
rows: grid.rows,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
const images = args.returnImage === false
|
|
127
|
-
? []
|
|
128
|
-
: (await encodeInlineImages([output], args.maxImageWidth ?? DEFAULT_MAX_IMAGE_WIDTH, 1)).images;
|
|
129
|
-
return okResponse({ ...result, inlineImages: images.length }, images);
|
|
130
|
-
}
|
|
131
|
-
catch (error) {
|
|
132
|
-
return errorResponse(error);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}
|
package/dist/tools/convert.js
DELETED
|
@@ -1,46 +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 } from "../utils/ffmpeg.js";
|
|
6
|
-
import { runEditJob, probeDuration } from "../utils/jobs.js";
|
|
7
|
-
import { buildConvertArgs } from "../utils/media.js";
|
|
8
|
-
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
9
|
-
const inputSchema = {
|
|
10
|
-
input: z.string().min(1).describe("Path to the source media."),
|
|
11
|
-
format: z
|
|
12
|
-
.enum(["mp4", "gif", "webm"])
|
|
13
|
-
.describe("mp4 (H.264), webm (VP9), or gif (palette)."),
|
|
14
|
-
fps: z.number().positive().optional().describe("gif only: fps (default 12)."),
|
|
15
|
-
width: z.number().positive().optional().describe("gif only: width in px (default 720)."),
|
|
16
|
-
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
17
|
-
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
18
|
-
};
|
|
19
|
-
export function register(server) {
|
|
20
|
-
server.registerTool("convert", {
|
|
21
|
-
title: "Convert Format",
|
|
22
|
-
description: "Convert media to mp4, webm, or gif. For a size-bounded GIF/WebP prefer export_gif; for a " +
|
|
23
|
-
"smaller mp4, compress or export_preset.",
|
|
24
|
-
inputSchema,
|
|
25
|
-
outputSchema: OUTPUT_PATH,
|
|
26
|
-
annotations: WRITES_FILE,
|
|
27
|
-
}, async (args, extra) => {
|
|
28
|
-
try {
|
|
29
|
-
requireFfmpeg();
|
|
30
|
-
if (!existsSync(args.input)) {
|
|
31
|
-
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
32
|
-
}
|
|
33
|
-
const format = args.format;
|
|
34
|
-
const output = resolveOutput(args.output, subdir("edits"), `convert-${stamp()}-${rand()}.${format}`, args.overwrite);
|
|
35
|
-
const ffArgs = buildConvertArgs(args.input, output, format, {
|
|
36
|
-
fps: args.fps,
|
|
37
|
-
width: args.width,
|
|
38
|
-
});
|
|
39
|
-
await runEditJob(ffArgs, { output, durationSec: await probeDuration(args.input), extra });
|
|
40
|
-
return okResponse({ outputPath: output, format });
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
return errorResponse(error);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
package/dist/tools/crop.js
DELETED
|
@@ -1,43 +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, probeMedia } from "../utils/ffmpeg.js";
|
|
6
|
-
import { runEditJob } from "../utils/jobs.js";
|
|
7
|
-
import { buildCropArgs, editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
8
|
-
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
9
|
-
const inputSchema = {
|
|
10
|
-
input: z.string().min(1).describe("Path to the source video."),
|
|
11
|
-
x: z.number().int().nonnegative(),
|
|
12
|
-
y: z.number().int().nonnegative(),
|
|
13
|
-
width: z.number().int().positive(),
|
|
14
|
-
height: z.number().int().positive(),
|
|
15
|
-
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
16
|
-
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
17
|
-
};
|
|
18
|
-
export function register(server) {
|
|
19
|
-
server.registerTool("crop", {
|
|
20
|
-
title: "Crop Video",
|
|
21
|
-
description: "Crop a video to a pixel rectangle; one running off the frame is rejected.",
|
|
22
|
-
inputSchema,
|
|
23
|
-
outputSchema: OUTPUT_PATH,
|
|
24
|
-
annotations: WRITES_FILE,
|
|
25
|
-
}, async (args, extra) => {
|
|
26
|
-
try {
|
|
27
|
-
requireFfmpeg();
|
|
28
|
-
if (!existsSync(args.input)) {
|
|
29
|
-
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
30
|
-
}
|
|
31
|
-
const { width, height, durationSec } = await probeMedia(args.input);
|
|
32
|
-
assertEditContainer(args.output);
|
|
33
|
-
const ext = editOutputExt(args.input);
|
|
34
|
-
const output = resolveOutput(args.output, subdir("edits"), `crop-${stamp()}-${rand()}${ext}`, args.overwrite);
|
|
35
|
-
const ffArgs = buildCropArgs(args.input, output, { x: args.x, y: args.y, width: args.width, height: args.height }, { width, height });
|
|
36
|
-
await runEditJob(ffArgs, { output, durationSec, extra });
|
|
37
|
-
return okResponse({ outputPath: output });
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
return errorResponse(error);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
package/dist/tools/cursor.js
DELETED
|
@@ -1,87 +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 { buildCursorArgs, cursorSpritePath, planCursor, transformCursor, DEFAULT_CURSOR_SIZE, DEFAULT_HIDE_AFTER_SEC, } from "../utils/cursor.js";
|
|
11
|
-
import { editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
12
|
-
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
13
|
-
export const cursorOptionsSchema = {
|
|
14
|
-
events: z.string().optional(),
|
|
15
|
-
size: z.number().min(0.25).max(8).optional(),
|
|
16
|
-
smoothing: z.number().min(0).max(1).optional(),
|
|
17
|
-
hideAfterSec: z.number().min(0).max(600).optional(),
|
|
18
|
-
clicks: z.boolean().optional(),
|
|
19
|
-
spotlight: z.boolean().optional(),
|
|
20
|
-
};
|
|
21
|
-
const o = cursorOptionsSchema;
|
|
22
|
-
export function loadCursor(input, events, opts, endSec) {
|
|
23
|
-
const path = events ?? eventPaths(input).jsonl;
|
|
24
|
-
if (!existsSync(path)) {
|
|
25
|
-
throw new ScreencastError(`No event log for ${input} (looked for ${path}). Record with start_recording cursor: "events" ` +
|
|
26
|
-
"(no OS cursor in the video, events logged), or pass events: <path to .events.jsonl>.");
|
|
27
|
-
}
|
|
28
|
-
const plan = planCursor(parseEventsJsonl(readFileSync(path, "utf8")), opts, endSec);
|
|
29
|
-
if (plan.path.length === 0)
|
|
30
|
-
throw new ScreencastError(`The event log ${path} has no cursor positions to draw.`);
|
|
31
|
-
return plan;
|
|
32
|
-
}
|
|
33
|
-
const inputSchema = {
|
|
34
|
-
input: z.string().min(1).describe("Path to the recording."),
|
|
35
|
-
events: o.events.describe("Event log (default: the input's .events.jsonl)."),
|
|
36
|
-
size: o.size.describe(`Times a typical cursor's size (default ${DEFAULT_CURSOR_SIZE}).`),
|
|
37
|
-
smoothing: o.smoothing.describe("0 = as logged, 1 = floaty (default 0.5)."),
|
|
38
|
-
hideAfterSec: o.hideAfterSec.describe(`Hide when the mouse rests this long; 0 = never (default ${DEFAULT_HIDE_AFTER_SEC}).`),
|
|
39
|
-
clicks: o.clicks.describe("Ripple on clicks (default true)."),
|
|
40
|
-
spotlight: o.spotlight.describe("Dim all but the area around the cursor."),
|
|
41
|
-
dryRun: z.boolean().optional().describe("Return the plan; write nothing."),
|
|
42
|
-
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
43
|
-
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
44
|
-
};
|
|
45
|
-
export function register(server) {
|
|
46
|
-
server.registerTool("cursor", {
|
|
47
|
-
title: "Re-rendered Cursor",
|
|
48
|
-
description: 'Draw a smoothed, scaled cursor that hides when idle from the event log of a start_recording cursor: "events" ' +
|
|
49
|
-
"recording (no OS cursor in the video), with click ripples and an optional spotlight.",
|
|
50
|
-
inputSchema,
|
|
51
|
-
outputSchema: looseOutput({ segments: z.number().int() }),
|
|
52
|
-
annotations: WRITES_FILE,
|
|
53
|
-
}, async (args, extra) => {
|
|
54
|
-
try {
|
|
55
|
-
requireFfmpeg();
|
|
56
|
-
if (!existsSync(args.input))
|
|
57
|
-
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
58
|
-
const info = await probeMedia(args.input);
|
|
59
|
-
if (!info.width || !info.height)
|
|
60
|
-
throw new ScreencastError(`Could not read the size of ${args.input}.`);
|
|
61
|
-
const plan = transformCursor(loadCursor(args.input, args.events, args, info.durationSec));
|
|
62
|
-
const summary = {
|
|
63
|
-
segments: plan.path.length,
|
|
64
|
-
clicks: plan.clicks.length,
|
|
65
|
-
shownSec: Math.round(plan.visible.reduce((s, [a, b]) => s + (Math.min(b, info.durationSec ?? b) - a), 0) * 10) / 10,
|
|
66
|
-
};
|
|
67
|
-
if (args.dryRun)
|
|
68
|
-
return okResponse({ dryRun: true, ...summary, visible: plan.visible });
|
|
69
|
-
assertEditContainer(args.output);
|
|
70
|
-
const output = resolveOutput(args.output, subdir("edits"), `cursor-${stamp()}-${rand()}${editOutputExt(args.input)}`, args.overwrite);
|
|
71
|
-
const work = mkdtempSync(join(tmpdir(), "screencast-cursor-"));
|
|
72
|
-
try {
|
|
73
|
-
const cmdFile = join(work, "cursor.cmd");
|
|
74
|
-
const { args: ffArgs, commands } = buildCursorArgs(args.input, output, plan, { size: args.size, clicks: args.clicks, spotlight: args.spotlight }, { width: info.width, height: info.height }, cursorSpritePath(), cmdFile);
|
|
75
|
-
writeFileSync(cmdFile, commands);
|
|
76
|
-
await runEditJob(ffArgs, { output, durationSec: info.durationSec, extra });
|
|
77
|
-
return okResponse({ outputPath: output, ...summary });
|
|
78
|
-
}
|
|
79
|
-
finally {
|
|
80
|
-
rmSync(work, { recursive: true, force: true });
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
return errorResponse(error);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|