@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.
Files changed (133) hide show
  1. package/README.md +13 -8
  2. package/dist/index.js +550 -106
  3. package/dist/wgcRecorder.js +15 -139
  4. package/package.json +8 -4
  5. package/assets/.gitkeep +0 -0
  6. package/assets/icon.png +0 -0
  7. package/dist/cli.js +0 -516
  8. package/dist/context.js +0 -50
  9. package/dist/prompts.js +0 -95
  10. package/dist/resources.js +0 -93
  11. package/dist/server.js +0 -174
  12. package/dist/setup.js +0 -438
  13. package/dist/tools/addMarker.js +0 -93
  14. package/dist/tools/assembleHighlights.js +0 -69
  15. package/dist/tools/backdrop.js +0 -89
  16. package/dist/tools/bugReport.js +0 -266
  17. package/dist/tools/burnSubtitles.js +0 -56
  18. package/dist/tools/callout.js +0 -103
  19. package/dist/tools/chapters.js +0 -156
  20. package/dist/tools/clip.js +0 -52
  21. package/dist/tools/compress.js +0 -51
  22. package/dist/tools/concat.js +0 -67
  23. package/dist/tools/contactSheet.js +0 -135
  24. package/dist/tools/convert.js +0 -46
  25. package/dist/tools/crop.js +0 -43
  26. package/dist/tools/cursor.js +0 -87
  27. package/dist/tools/cutByTranscript.js +0 -86
  28. package/dist/tools/cutIdle.js +0 -84
  29. package/dist/tools/deleteRecording.js +0 -119
  30. package/dist/tools/denoise.js +0 -60
  31. package/dist/tools/doctor.js +0 -146
  32. package/dist/tools/exportGif.js +0 -57
  33. package/dist/tools/exportPreset.js +0 -48
  34. package/dist/tools/extractAudio.js +0 -65
  35. package/dist/tools/findText.js +0 -196
  36. package/dist/tools/getMediaInfo.js +0 -36
  37. package/dist/tools/getSession.js +0 -40
  38. package/dist/tools/indexRecording.js +0 -195
  39. package/dist/tools/keystrokeOverlay.js +0 -131
  40. package/dist/tools/listAudioDevices.js +0 -35
  41. package/dist/tools/listSessions.js +0 -28
  42. package/dist/tools/listTargets.js +0 -76
  43. package/dist/tools/listVideoDevices.js +0 -26
  44. package/dist/tools/musicBed.js +0 -55
  45. package/dist/tools/narrate.js +0 -86
  46. package/dist/tools/normalizeAudio.js +0 -60
  47. package/dist/tools/overlay.js +0 -62
  48. package/dist/tools/pauseRecording.js +0 -44
  49. package/dist/tools/pipeline.js +0 -400
  50. package/dist/tools/readEvents.js +0 -98
  51. package/dist/tools/redactRegion.js +0 -70
  52. package/dist/tools/reframe.js +0 -46
  53. package/dist/tools/resumeRecording.js +0 -46
  54. package/dist/tools/reviewRecording.js +0 -163
  55. package/dist/tools/sampleFrames.js +0 -200
  56. package/dist/tools/saveReplay.js +0 -90
  57. package/dist/tools/scale.js +0 -44
  58. package/dist/tools/screenDiff.js +0 -86
  59. package/dist/tools/screenshot.js +0 -76
  60. package/dist/tools/searchRecording.js +0 -79
  61. package/dist/tools/speed.js +0 -46
  62. package/dist/tools/startRecording.js +0 -398
  63. package/dist/tools/stepGuide.js +0 -250
  64. package/dist/tools/stopRecording.js +0 -132
  65. package/dist/tools/titleCard.js +0 -67
  66. package/dist/tools/transcribe.js +0 -66
  67. package/dist/tools/trim.js +0 -57
  68. package/dist/tools/waitForChange.js +0 -128
  69. package/dist/tools/xfadeTransition.js +0 -58
  70. package/dist/tools/zoom.js +0 -149
  71. package/dist/utils/anim.js +0 -54
  72. package/dist/utils/animExport.js +0 -56
  73. package/dist/utils/argPaths.js +0 -39
  74. package/dist/utils/audio.js +0 -113
  75. package/dist/utils/audioDevices.js +0 -107
  76. package/dist/utils/backdrop.js +0 -151
  77. package/dist/utils/bugReport.js +0 -172
  78. package/dist/utils/callout.js +0 -90
  79. package/dist/utils/calloutAssets.js +0 -42
  80. package/dist/utils/capabilities.js +0 -96
  81. package/dist/utils/captions.js +0 -103
  82. package/dist/utils/chapters.js +0 -227
  83. package/dist/utils/consent.js +0 -29
  84. package/dist/utils/cursor.js +0 -317
  85. package/dist/utils/diff.js +0 -184
  86. package/dist/utils/errors.js +0 -29
  87. package/dist/utils/events.js +0 -403
  88. package/dist/utils/expr.js +0 -11
  89. package/dist/utils/ffmpeg.js +0 -285
  90. package/dist/utils/fontCoverage.js +0 -177
  91. package/dist/utils/fonts.js +0 -154
  92. package/dist/utils/gpu.js +0 -219
  93. package/dist/utils/idle.js +0 -91
  94. package/dist/utils/images.js +0 -38
  95. package/dist/utils/jobs.js +0 -129
  96. package/dist/utils/keystrokes.js +0 -155
  97. package/dist/utils/lifecycle.js +0 -233
  98. package/dist/utils/logging.js +0 -75
  99. package/dist/utils/media.js +0 -574
  100. package/dist/utils/monitors.js +0 -124
  101. package/dist/utils/narrate.js +0 -233
  102. package/dist/utils/ocr.js +0 -222
  103. package/dist/utils/ocrScan.js +0 -91
  104. package/dist/utils/paths.js +0 -155
  105. package/dist/utils/pause.js +0 -190
  106. package/dist/utils/pipeline.js +0 -361
  107. package/dist/utils/player.js +0 -85
  108. package/dist/utils/pool.js +0 -29
  109. package/dist/utils/produce.js +0 -298
  110. package/dist/utils/recipes.js +0 -71
  111. package/dist/utils/recorder.js +0 -173
  112. package/dist/utils/recordingFiles.js +0 -32
  113. package/dist/utils/recordingIndex.js +0 -312
  114. package/dist/utils/replay.js +0 -283
  115. package/dist/utils/resolveTarget.js +0 -25
  116. package/dist/utils/retention.js +0 -48
  117. package/dist/utils/roots.js +0 -43
  118. package/dist/utils/sessions.js +0 -499
  119. package/dist/utils/sheet.js +0 -59
  120. package/dist/utils/stepGuide.js +0 -231
  121. package/dist/utils/steps.js +0 -88
  122. package/dist/utils/still.js +0 -38
  123. package/dist/utils/targetList.js +0 -64
  124. package/dist/utils/targets.js +0 -265
  125. package/dist/utils/timeline.js +0 -85
  126. package/dist/utils/toolSpec.js +0 -31
  127. package/dist/utils/toolsets.js +0 -134
  128. package/dist/utils/transcriptCut.js +0 -149
  129. package/dist/utils/validate.js +0 -23
  130. package/dist/utils/waitLoop.js +0 -50
  131. package/dist/utils/wgc.js +0 -84
  132. package/dist/utils/windows.js +0 -192
  133. package/dist/utils/zoom.js +0 -234
@@ -1,35 +0,0 @@
1
- import { z } from "zod";
2
- import { errorResponse, okResponse } from "../utils/errors.js";
3
- import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
4
- import { requireFfmpeg } from "../utils/ffmpeg.js";
5
- import { listDshowAudioDevices, pickLoopbackDevice, NO_LOOPBACK_HINT, } from "../utils/audioDevices.js";
6
- export function register(server) {
7
- server.registerTool("list_audio_devices", {
8
- title: "List Audio Devices",
9
- description: "List DirectShow audio devices and flag a likely loopback (Stereo Mix or a virtual-audio " +
10
- "driver), for start_recording's audio.device.",
11
- inputSchema: {},
12
- outputSchema: looseOutput({
13
- devices: z.array(z.unknown()),
14
- loopbackDevice: z.string().nullable(),
15
- note: z.string(),
16
- }),
17
- annotations: READ_ONLY,
18
- }, async () => {
19
- try {
20
- requireFfmpeg();
21
- const devices = await listDshowAudioDevices(true);
22
- const loopback = pickLoopbackDevice(devices);
23
- return okResponse({
24
- devices,
25
- loopbackDevice: loopback,
26
- note: loopback
27
- ? `Pass "${loopback}" as the audio device to capture system audio.`
28
- : `No loopback device detected. ${NO_LOOPBACK_HINT}`,
29
- });
30
- }
31
- catch (error) {
32
- return errorResponse(error);
33
- }
34
- });
35
- }
@@ -1,28 +0,0 @@
1
- import { z } from "zod";
2
- import { errorResponse, okResponse } from "../utils/errors.js";
3
- import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
4
- import { isAlive } from "../utils/sessions.js";
5
- import { getStore } from "../context.js";
6
- export function register(server) {
7
- server.registerTool("list_sessions", {
8
- title: "List Sessions",
9
- description: "List all recording sessions (active and finished) with their status, " +
10
- "target, output path, and whether the process is still alive.",
11
- inputSchema: {},
12
- outputSchema: looseOutput({
13
- count: z.number().int(),
14
- sessions: z.array(looseOutput({ id: z.string(), status: z.string(), outputPath: z.string(), alive: z.boolean() })),
15
- }),
16
- annotations: READ_ONLY,
17
- }, async () => {
18
- try {
19
- const sessions = getStore()
20
- .list()
21
- .map((s) => ({ ...s, alive: s.status === "recording" && isAlive(s.pid) }));
22
- return okResponse({ count: sessions.length, sessions });
23
- }
24
- catch (error) {
25
- return errorResponse(error);
26
- }
27
- });
28
- }
@@ -1,76 +0,0 @@
1
- import { z } from "zod";
2
- import { errorResponse, okResponse } from "../utils/errors.js";
3
- import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
4
- import { getMonitors } from "../utils/monitors.js";
5
- import { getRawWindows } from "../utils/windows.js";
6
- import { wgcAvailable } from "../utils/ffmpeg.js";
7
- import { buildTargetList } from "../utils/targetList.js";
8
- const inputSchema = {
9
- exe: z
10
- .string()
11
- .min(1)
12
- .optional()
13
- .describe("Only list windows of this executable, e.g. 'Code.exe' or 'code'."),
14
- titleContains: z
15
- .string()
16
- .min(1)
17
- .optional()
18
- .describe("Only list windows whose title contains this text (case-insensitive)."),
19
- capturableOnly: z
20
- .boolean()
21
- .optional()
22
- .describe("Leave out windows neither backend can capture (minimized, off screen). Default false."),
23
- };
24
- const bounds = z.object({ x: z.number(), y: z.number(), width: z.number(), height: z.number() });
25
- const outputSchema = looseOutput({
26
- full: z.looseObject({ target: z.literal("full"), bounds }),
27
- monitors: z.array(z.looseObject({
28
- target: z.string(),
29
- index: z.number(),
30
- primary: z.boolean(),
31
- bounds,
32
- dpi: z.number().nullable(),
33
- scale: z.number().nullable(),
34
- })),
35
- windows: z.array(z.looseObject({
36
- target: z.string(),
37
- title: z.string(),
38
- exe: z.string().nullable(),
39
- pid: z.number().nullable(),
40
- hwnd: z.number().nullable(),
41
- bounds,
42
- minimized: z.boolean(),
43
- cloaked: z.boolean(),
44
- capturable: z.boolean(),
45
- wgcCapturable: z.boolean(),
46
- })),
47
- wgcAvailable: z.boolean(),
48
- note: z.string(),
49
- });
50
- export function register(server) {
51
- server.registerTool("list_targets", {
52
- title: "List Capture Targets",
53
- description: "List the desktop, monitors, and visible windows (topmost first, with capturability per backend). " +
54
- "Each entry has a `target` string to pass as-is to capture tools; use it instead of guessing a title.",
55
- inputSchema,
56
- outputSchema,
57
- annotations: READ_ONLY,
58
- }, async (args) => {
59
- try {
60
- const [monitors, windows] = await Promise.all([getMonitors(), getRawWindows()]);
61
- const list = buildTargetList(monitors, windows, {
62
- wgcAvailable: wgcAvailable(),
63
- filter: { exe: args.exe, titleContains: args.titleContains, capturableOnly: args.capturableOnly },
64
- });
65
- return okResponse({
66
- ...list,
67
- note: "Pass a target string unchanged. A window handle lasts until the app closes the window; " +
68
- "list again after an app restarts, or target it by window:exe=<app.exe>. " +
69
- 'A window with capturable false but wgcCapturable true needs backend: "wgc".',
70
- });
71
- }
72
- catch (error) {
73
- return errorResponse(error);
74
- }
75
- });
76
- }
@@ -1,26 +0,0 @@
1
- import { z } from "zod";
2
- import { errorResponse, okResponse } from "../utils/errors.js";
3
- import { READ_ONLY, looseOutput } from "../utils/toolSpec.js";
4
- import { requireFfmpeg } from "../utils/ffmpeg.js";
5
- import { listDshowVideoDevices } from "../utils/audioDevices.js";
6
- export function register(server) {
7
- server.registerTool("list_video_devices", {
8
- title: "List Video Devices",
9
- description: "List DirectShow cameras for start_recording's webcam.device.",
10
- inputSchema: {},
11
- outputSchema: looseOutput({ devices: z.array(z.string()) }),
12
- annotations: READ_ONLY,
13
- }, async () => {
14
- try {
15
- requireFfmpeg();
16
- const devices = await listDshowVideoDevices(true);
17
- return okResponse({
18
- devices,
19
- note: devices.length ? `start_recording { webcam: { device: "${devices[0]}" } } records it.` : "No camera found.",
20
- });
21
- }
22
- catch (error) {
23
- return errorResponse(error);
24
- }
25
- });
26
- }
@@ -1,55 +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 { buildMusicBedArgs } from "../utils/produce.js";
8
- import { editOutputExt, assertEditContainer } from "../utils/media.js";
9
- import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
10
- const inputSchema = {
11
- video: z.string().min(1).describe("Path to the video."),
12
- music: z.string().min(1).describe("Music audio file."),
13
- musicVolume: z.number().nonnegative().optional().describe("0..1 (default 0.25 over existing audio, 0.8 alone)."),
14
- fadeIn: z.number().nonnegative().optional().describe("Fade-in seconds (default 1)."),
15
- fadeOut: z.number().nonnegative().optional().describe("Fade-out seconds (default 2)."),
16
- duck: z.boolean().optional().describe("Duck the music under the original audio (default false)."),
17
- output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
18
- overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
19
- };
20
- export function register(server) {
21
- server.registerTool("music_bed", {
22
- title: "Add Music Bed",
23
- description: "Lay music under a video: looped or trimmed to length, faded, leveled, and mixed with any " +
24
- "existing audio. Video is stream-copied.",
25
- inputSchema,
26
- outputSchema: OUTPUT_PATH,
27
- annotations: WRITES_FILE,
28
- }, async (args, extra) => {
29
- try {
30
- requireFfmpeg();
31
- for (const f of [args.video, args.music]) {
32
- if (!existsSync(f))
33
- throw new ScreencastError(`Input file not found: ${f}`);
34
- }
35
- const info = await probeMedia(args.video);
36
- if (info.durationSec === null) {
37
- throw new ScreencastError(`Could not read duration of ${args.video}.`);
38
- }
39
- assertEditContainer(args.output);
40
- const ext = editOutputExt(args.video);
41
- const output = resolveOutput(args.output, subdir("edits"), `music-${stamp()}-${rand()}${ext}`, args.overwrite);
42
- const ffArgs = buildMusicBedArgs(args.video, args.music, output, info.durationSec, info.audioCodec !== null, {
43
- musicVolume: args.musicVolume,
44
- fadeIn: args.fadeIn,
45
- fadeOut: args.fadeOut,
46
- duck: args.duck,
47
- });
48
- await runEditJob(ffArgs, { output, durationSec: info.durationSec, extra });
49
- return okResponse({ outputPath: output, mixedWithOriginal: info.audioCodec !== null });
50
- }
51
- catch (error) {
52
- return errorResponse(error);
53
- }
54
- });
55
- }
@@ -1,86 +0,0 @@
1
- import { z } from "zod";
2
- import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
3
- import { tmpdir } from "node:os";
4
- import { join } from "node:path";
5
- import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
6
- import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
7
- import { requireFfmpeg, probeMedia } from "../utils/ffmpeg.js";
8
- import { runEditJob } from "../utils/jobs.js";
9
- import { editOutputExt, assertEditContainer } from "../utils/media.js";
10
- import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
11
- import { markersOrChapters, readMarkers, writeMarkers } from "../utils/chapters.js";
12
- import { formatSrt } from "../utils/captions.js";
13
- import { buildNarrateArgs, narrationCues, placementWarnings, resolveLines, synthesize, wavDurationSec, MAX_RATE, MIN_RATE, } from "../utils/narrate.js";
14
- const inputSchema = {
15
- video: z.string().min(1).describe("Path to the video."),
16
- lines: z
17
- .array(z.object({
18
- t: z.number().nonnegative().optional().describe("Seconds."),
19
- marker: z.string().optional().describe("Or a marker label."),
20
- text: z.string().min(1),
21
- }))
22
- .min(1),
23
- voice: z.string().optional().describe("Voice name or part (doctor lists them)."),
24
- rate: z.number().min(MIN_RATE).max(MAX_RATE).optional().describe("Default 1."),
25
- duck: z.boolean().optional().describe("Duck the original audio (default true)."),
26
- output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
27
- overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
28
- };
29
- export function register(server) {
30
- server.registerTool("narrate", {
31
- title: "Narrate",
32
- description: "Offline voiceover with the built-in Windows voices: speaks each line at its time or marker " +
33
- "over the audio, plus an SRT.",
34
- inputSchema,
35
- outputSchema: OUTPUT_PATH,
36
- annotations: WRITES_FILE,
37
- }, async (args, extra) => {
38
- let work = null;
39
- try {
40
- requireFfmpeg();
41
- if (!existsSync(args.video))
42
- throw new ScreencastError(`Input file not found: ${args.video}`);
43
- const info = await probeMedia(args.video);
44
- if (info.durationSec === null)
45
- throw new ScreencastError(`Could not read duration of ${args.video}.`);
46
- const needsMarkers = args.lines.some((l) => l.marker !== undefined);
47
- const markers = needsMarkers ? (await markersOrChapters(args.video, extra.signal)).markers : [];
48
- const lines = resolveLines(args.lines, markers);
49
- assertEditContainer(args.output);
50
- const output = resolveOutput(args.output, subdir("edits"), `narrated-${stamp()}-${rand()}${editOutputExt(args.video)}`, args.overwrite);
51
- const srtPath = output.replace(/\.[^./\\]+$/, "") + ".srt";
52
- if (!args.overwrite && existsSync(srtPath))
53
- throw new ScreencastError(`Output already exists: ${srtPath}. Pass overwrite: true to replace it.`);
54
- work = mkdtempSync(join(tmpdir(), "screencast-tts-"));
55
- const wavs = lines.map((_, i) => join(work, `line-${i}.wav`));
56
- const voice = await synthesize(lines.map((l, i) => ({ text: l.text, path: wavs[i] })), { voice: args.voice, rate: args.rate, signal: extra.signal });
57
- const placed = lines.map((l, i) => ({ ...l, durationSec: wavDurationSec(readFileSync(wavs[i])) }));
58
- const warnings = placementWarnings(placed, info.durationSec);
59
- const ffArgs = buildNarrateArgs(args.video, wavs, output, placed, info.durationSec, {
60
- hasAudio: info.audioCodec !== null,
61
- channels: info.channels,
62
- duck: args.duck,
63
- });
64
- await runEditJob(ffArgs, { output, durationSec: info.durationSec, extra });
65
- writeFileSync(srtPath, formatSrt(narrationCues(placed, info.durationSec)));
66
- const inputMarkers = readMarkers(args.video);
67
- if (inputMarkers.length > 0)
68
- writeMarkers(output, inputMarkers);
69
- return okResponse({
70
- outputPath: output,
71
- srtPath,
72
- voice,
73
- lines: placed.map((p) => ({ t: p.t, durationSec: Math.round(p.durationSec * 100) / 100 })),
74
- mixedWithOriginal: info.audioCodec !== null,
75
- ...(warnings.length ? { warnings } : {}),
76
- });
77
- }
78
- catch (error) {
79
- return errorResponse(error);
80
- }
81
- finally {
82
- if (work)
83
- rmSync(work, { recursive: true, force: true });
84
- }
85
- });
86
- }
@@ -1,60 +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, probeMedia } from "../utils/ffmpeg.js";
6
- import { runEditJob, jobTimeoutMs } from "../utils/jobs.js";
7
- import { loudnessTarget, buildLoudnessMeasureArgs, buildLoudnessApplyArgs, parseLoudnorm, } from "../utils/audio.js";
8
- import { editOutputExt, assertEditContainer } from "../utils/media.js";
9
- import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
10
- const inputSchema = {
11
- input: z.string().min(1).describe("Path to the source video or audio file."),
12
- target: z
13
- .union([z.enum(["youtube", "podcast", "broadcast"]), z.number()])
14
- .optional()
15
- .describe("youtube (-14 LUFS, default), podcast (-16), broadcast (-23), or a LUFS number."),
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("normalize_audio", {
21
- title: "Normalize Loudness",
22
- description: "Normalize loudness to a delivery target (two-pass EBU R128 loudnorm); video is copied. " +
23
- "Reports loudness before and after.",
24
- inputSchema,
25
- outputSchema: OUTPUT_PATH,
26
- annotations: WRITES_FILE,
27
- }, async (args, extra) => {
28
- try {
29
- const { ffmpeg } = requireFfmpeg();
30
- if (!existsSync(args.input)) {
31
- throw new ScreencastError(`Input file not found: ${args.input}`);
32
- }
33
- const info = await probeMedia(args.input);
34
- if (!info.audioCodec)
35
- throw new ScreencastError(`Input has no audio stream: ${args.input}`);
36
- const t = loudnessTarget(args.target);
37
- assertEditContainer(args.output);
38
- const ext = editOutputExt(args.input, { audio: true });
39
- const output = resolveOutput(args.output, subdir("edits"), `loudnorm-${stamp()}-${rand()}${ext}`, args.overwrite);
40
- const timeout = jobTimeoutMs(info.durationSec);
41
- const before = await runCapture(ffmpeg, buildLoudnessMeasureArgs(args.input, t), timeout, { signal: extra.signal });
42
- const measured = parseLoudnorm(before.stderr);
43
- await runEditJob(buildLoudnessApplyArgs(args.input, output, t, measured), {
44
- output,
45
- durationSec: info.durationSec,
46
- extra,
47
- });
48
- const after = parseLoudnorm((await runCapture(ffmpeg, buildLoudnessMeasureArgs(output, t), timeout, { signal: extra.signal })).stderr);
49
- return okResponse({
50
- outputPath: output,
51
- target: { lufs: t.i, truePeakDb: t.tp, lra: t.lra },
52
- before: { lufs: measured.input_i, truePeakDb: measured.input_tp },
53
- after: { lufs: after.input_i, truePeakDb: after.input_tp },
54
- });
55
- }
56
- catch (error) {
57
- return errorResponse(error);
58
- }
59
- });
60
- }
@@ -1,62 +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 { buildOverlayArgs, 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 base video."),
11
- overlay: z.string().min(1).describe("Overlay image or video path."),
12
- x: z.number().int().nonnegative().describe("Left, px."),
13
- y: z.number().int().nonnegative().describe("Top, px."),
14
- width: z.number().int().positive().optional().describe("Scale to this width (other side keeps aspect)."),
15
- height: z.number().int().positive().optional().describe("Scale to this height."),
16
- start: z.number().nonnegative().optional().describe("Show from this second."),
17
- end: z.number().positive().optional().describe("Hide after this second."),
18
- shape: z.enum(["rect", "circle"]).optional().describe("circle: centre square masked round (webcam)."),
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("overlay", {
24
- title: "Overlay Image or Video",
25
- description: "Composite an image or video (logo, watermark, picture-in-picture) onto a video at a pixel " +
26
- "position, optionally scaled and time-limited; keeps the base's audio and length.",
27
- inputSchema,
28
- outputSchema: OUTPUT_PATH,
29
- annotations: WRITES_FILE,
30
- }, async (args, extra) => {
31
- try {
32
- requireFfmpeg();
33
- if (!existsSync(args.input)) {
34
- throw new ScreencastError(`Input file not found: ${args.input}`);
35
- }
36
- if (!existsSync(args.overlay)) {
37
- throw new ScreencastError(`Overlay file not found: ${args.overlay}`);
38
- }
39
- assertEditContainer(args.output);
40
- const ext = editOutputExt(args.input);
41
- const output = resolveOutput(args.output, subdir("edits"), `overlay-${stamp()}-${rand()}${ext}`, args.overwrite);
42
- const scale = args.width !== undefined || args.height !== undefined
43
- ? { width: args.width, height: args.height }
44
- : undefined;
45
- const durationSec = await probeDuration(args.input);
46
- const ffArgs = buildOverlayArgs(args.input, args.overlay, output, {
47
- x: args.x,
48
- y: args.y,
49
- start: args.start,
50
- end: args.end,
51
- scale,
52
- shape: args.shape,
53
- durationSec,
54
- });
55
- await runEditJob(ffArgs, { output, durationSec, extra });
56
- return okResponse({ outputPath: output });
57
- }
58
- catch (error) {
59
- return errorResponse(error);
60
- }
61
- });
62
- }
@@ -1,44 +0,0 @@
1
- import { z } from "zod";
2
- import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
3
- import { STOPS_SESSION, looseOutput } from "../utils/toolSpec.js";
4
- import { probeDuration, requireFfmpeg } from "../utils/ffmpeg.js";
5
- import { pauseSession } from "../utils/lifecycle.js";
6
- import { recordedSec } from "../utils/pause.js";
7
- import { getStore } from "../context.js";
8
- const r3 = (n) => Math.round(n * 1000) / 1000;
9
- export function register(server) {
10
- server.registerTool("pause_recording", {
11
- title: "Pause Recording",
12
- description: "Pause a recording; until resume_recording nothing is captured, and the gap is left out of the file, events, and markers.",
13
- inputSchema: { sessionId: z.string().min(1).describe("From start_recording.") },
14
- outputSchema: looseOutput({ sessionId: z.string(), status: z.string(), recordedSec: z.number() }),
15
- annotations: STOPS_SESSION,
16
- }, async (args) => {
17
- try {
18
- const store = getStore();
19
- const record = store.get(args.sessionId);
20
- if (!record)
21
- throw new ScreencastError(`No session with id "${args.sessionId}".`);
22
- if (record.status === "paused") {
23
- return okResponse({
24
- sessionId: record.id,
25
- status: "paused",
26
- recordedSec: r3(recordedSec(record.segments?.parts ?? [])),
27
- note: "Already paused.",
28
- });
29
- }
30
- const { ffprobe } = requireFfmpeg();
31
- const res = await pauseSession(store, record, { probe: (p) => probeDuration(p, { ffprobe }) });
32
- return okResponse({
33
- sessionId: record.id,
34
- status: "paused",
35
- recordedSec: r3(res.recordedSec),
36
- segments: res.record?.segments?.parts.length ?? 0,
37
- note: "Nothing is captured until resume_recording; stop_recording joins what was recorded.",
38
- });
39
- }
40
- catch (error) {
41
- return errorResponse(error);
42
- }
43
- });
44
- }