@tmhs/screencast-mcp 0.39.0 → 0.45.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 +95 -17
- package/assets/icon.png +0 -0
- package/assets/ui/player.html +47 -302
- package/assets/ui/player.js +402 -0
- package/dist/context.js +0 -5
- package/dist/index.js +17 -21
- package/dist/prompts.js +18 -8
- package/dist/resources.js +2 -14
- package/dist/server.js +49 -11
- package/dist/tools/addMarker.js +89 -0
- package/dist/tools/assembleHighlights.js +12 -7
- package/dist/tools/backdrop.js +89 -0
- package/dist/tools/bugReport.js +266 -0
- package/dist/tools/burnSubtitles.js +12 -6
- package/dist/tools/callout.js +32 -16
- package/dist/tools/chapters.js +156 -0
- package/dist/tools/clip.js +12 -9
- package/dist/tools/compress.js +10 -5
- package/dist/tools/concat.js +16 -15
- package/dist/tools/contactSheet.js +39 -33
- package/dist/tools/convert.js +12 -6
- package/dist/tools/crop.js +12 -7
- package/dist/tools/cutIdle.js +15 -9
- package/dist/tools/denoise.js +12 -6
- package/dist/tools/doctor.js +133 -0
- package/dist/tools/exportGif.js +14 -10
- package/dist/tools/exportPreset.js +11 -8
- package/dist/tools/extractAudio.js +10 -8
- package/dist/tools/findText.js +52 -98
- package/dist/tools/getMediaInfo.js +17 -3
- package/dist/tools/getSession.js +15 -3
- package/dist/tools/keystrokeOverlay.js +131 -0
- package/dist/tools/listAudioDevices.js +14 -7
- package/dist/tools/listSessions.js +13 -3
- package/dist/tools/listTargets.js +76 -0
- package/dist/tools/musicBed.js +14 -10
- package/dist/tools/normalizeAudio.js +12 -8
- package/dist/tools/overlay.js +16 -12
- package/dist/tools/pipeline.js +86 -25
- package/dist/tools/readEvents.js +21 -12
- package/dist/tools/redactRegion.js +19 -17
- package/dist/tools/reframe.js +9 -5
- package/dist/tools/reviewRecording.js +75 -22
- package/dist/tools/sampleFrames.js +33 -40
- package/dist/tools/saveReplay.js +90 -0
- package/dist/tools/scale.js +9 -3
- package/dist/tools/screenDiff.js +23 -17
- package/dist/tools/screenshot.js +21 -17
- package/dist/tools/speed.js +15 -4
- package/dist/tools/startRecording.js +96 -59
- package/dist/tools/stopRecording.js +35 -10
- package/dist/tools/titleCard.js +19 -11
- package/dist/tools/transcribe.js +13 -7
- package/dist/tools/trim.js +11 -10
- package/dist/tools/waitForChange.js +37 -22
- package/dist/tools/xfadeTransition.js +12 -8
- package/dist/tools/zoom.js +26 -29
- package/dist/utils/anim.js +1 -21
- package/dist/utils/animExport.js +5 -10
- package/dist/utils/audio.js +4 -33
- package/dist/utils/audioDevices.js +1 -48
- package/dist/utils/backdrop.js +151 -0
- package/dist/utils/bugReport.js +246 -0
- package/dist/utils/callout.js +1 -19
- package/dist/utils/calloutAssets.js +21 -11
- package/dist/utils/capabilities.js +95 -0
- package/dist/utils/captions.js +9 -26
- package/dist/utils/chapters.js +222 -0
- package/dist/utils/consent.js +29 -0
- package/dist/utils/diff.js +0 -46
- package/dist/utils/errors.js +5 -13
- package/dist/utils/events.js +21 -77
- package/dist/utils/expr.js +11 -0
- package/dist/utils/ffmpeg.js +119 -48
- package/dist/utils/fontCoverage.js +177 -0
- package/dist/utils/fonts.js +139 -23
- package/dist/utils/idle.js +12 -24
- package/dist/utils/images.js +0 -17
- package/dist/utils/jobs.js +42 -41
- package/dist/utils/keystrokes.js +170 -0
- package/dist/utils/lifecycle.js +11 -31
- package/dist/utils/logging.js +75 -0
- package/dist/utils/media.js +16 -124
- package/dist/utils/monitors.js +7 -43
- package/dist/utils/ocr.js +53 -71
- package/dist/utils/ocrScan.js +77 -0
- package/dist/utils/paths.js +68 -31
- package/dist/utils/pipeline.js +39 -25
- package/dist/utils/player.js +50 -27
- package/dist/utils/produce.js +6 -66
- package/dist/utils/replay.js +278 -0
- package/dist/utils/resolveTarget.js +0 -19
- package/dist/utils/retention.js +1 -15
- package/dist/utils/roots.js +42 -0
- package/dist/utils/sessions.js +195 -160
- package/dist/utils/sheet.js +0 -19
- package/dist/utils/still.js +0 -15
- package/dist/utils/targetList.js +63 -0
- package/dist/utils/targets.js +5 -70
- package/dist/utils/toolSpec.js +25 -0
- package/dist/utils/toolsets.js +122 -0
- package/dist/utils/validate.js +0 -22
- package/dist/utils/wgc.js +0 -46
- package/dist/utils/windows.js +5 -50
- package/dist/utils/zoom.js +55 -85
- package/dist/wgcRecorder.js +1 -30
- package/package.json +7 -3
- package/dist/context.d.ts +0 -9
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/prompts.d.ts +0 -10
- package/dist/prompts.d.ts.map +0 -1
- package/dist/prompts.js.map +0 -1
- package/dist/resources.d.ts +0 -3
- package/dist/resources.d.ts.map +0 -1
- package/dist/resources.js.map +0 -1
- package/dist/server.d.ts +0 -3
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/tools/assembleHighlights.d.ts +0 -3
- package/dist/tools/assembleHighlights.d.ts.map +0 -1
- package/dist/tools/assembleHighlights.js.map +0 -1
- package/dist/tools/burnSubtitles.d.ts +0 -3
- package/dist/tools/burnSubtitles.d.ts.map +0 -1
- package/dist/tools/burnSubtitles.js.map +0 -1
- package/dist/tools/callout.d.ts +0 -37
- package/dist/tools/callout.d.ts.map +0 -1
- package/dist/tools/callout.js.map +0 -1
- package/dist/tools/clip.d.ts +0 -3
- package/dist/tools/clip.d.ts.map +0 -1
- package/dist/tools/clip.js.map +0 -1
- package/dist/tools/compress.d.ts +0 -3
- package/dist/tools/compress.d.ts.map +0 -1
- package/dist/tools/compress.js.map +0 -1
- package/dist/tools/concat.d.ts +0 -3
- package/dist/tools/concat.d.ts.map +0 -1
- package/dist/tools/concat.js.map +0 -1
- package/dist/tools/contactSheet.d.ts +0 -3
- package/dist/tools/contactSheet.d.ts.map +0 -1
- package/dist/tools/contactSheet.js.map +0 -1
- package/dist/tools/convert.d.ts +0 -3
- package/dist/tools/convert.d.ts.map +0 -1
- package/dist/tools/convert.js.map +0 -1
- package/dist/tools/crop.d.ts +0 -3
- package/dist/tools/crop.d.ts.map +0 -1
- package/dist/tools/crop.js.map +0 -1
- package/dist/tools/cutIdle.d.ts +0 -3
- package/dist/tools/cutIdle.d.ts.map +0 -1
- package/dist/tools/cutIdle.js.map +0 -1
- package/dist/tools/denoise.d.ts +0 -3
- package/dist/tools/denoise.d.ts.map +0 -1
- package/dist/tools/denoise.js.map +0 -1
- package/dist/tools/exportGif.d.ts +0 -3
- package/dist/tools/exportGif.d.ts.map +0 -1
- package/dist/tools/exportGif.js.map +0 -1
- package/dist/tools/exportPreset.d.ts +0 -3
- package/dist/tools/exportPreset.d.ts.map +0 -1
- package/dist/tools/exportPreset.js.map +0 -1
- package/dist/tools/extractAudio.d.ts +0 -3
- package/dist/tools/extractAudio.d.ts.map +0 -1
- package/dist/tools/extractAudio.js.map +0 -1
- package/dist/tools/findText.d.ts +0 -6
- package/dist/tools/findText.d.ts.map +0 -1
- package/dist/tools/findText.js.map +0 -1
- package/dist/tools/getMediaInfo.d.ts +0 -3
- package/dist/tools/getMediaInfo.d.ts.map +0 -1
- package/dist/tools/getMediaInfo.js.map +0 -1
- package/dist/tools/getSession.d.ts +0 -3
- package/dist/tools/getSession.d.ts.map +0 -1
- package/dist/tools/getSession.js.map +0 -1
- package/dist/tools/listAudioDevices.d.ts +0 -3
- package/dist/tools/listAudioDevices.d.ts.map +0 -1
- package/dist/tools/listAudioDevices.js.map +0 -1
- package/dist/tools/listSessions.d.ts +0 -3
- package/dist/tools/listSessions.d.ts.map +0 -1
- package/dist/tools/listSessions.js.map +0 -1
- package/dist/tools/musicBed.d.ts +0 -3
- package/dist/tools/musicBed.d.ts.map +0 -1
- package/dist/tools/musicBed.js.map +0 -1
- package/dist/tools/normalizeAudio.d.ts +0 -3
- package/dist/tools/normalizeAudio.d.ts.map +0 -1
- package/dist/tools/normalizeAudio.js.map +0 -1
- package/dist/tools/overlay.d.ts +0 -3
- package/dist/tools/overlay.d.ts.map +0 -1
- package/dist/tools/overlay.js.map +0 -1
- package/dist/tools/pipeline.d.ts +0 -3
- package/dist/tools/pipeline.d.ts.map +0 -1
- package/dist/tools/pipeline.js.map +0 -1
- package/dist/tools/readEvents.d.ts +0 -6
- package/dist/tools/readEvents.d.ts.map +0 -1
- package/dist/tools/readEvents.js.map +0 -1
- package/dist/tools/redactRegion.d.ts +0 -13
- package/dist/tools/redactRegion.d.ts.map +0 -1
- package/dist/tools/redactRegion.js.map +0 -1
- package/dist/tools/reframe.d.ts +0 -3
- package/dist/tools/reframe.d.ts.map +0 -1
- package/dist/tools/reframe.js.map +0 -1
- package/dist/tools/reviewRecording.d.ts +0 -5
- package/dist/tools/reviewRecording.d.ts.map +0 -1
- package/dist/tools/reviewRecording.js.map +0 -1
- package/dist/tools/sampleFrames.d.ts +0 -3
- package/dist/tools/sampleFrames.d.ts.map +0 -1
- package/dist/tools/sampleFrames.js.map +0 -1
- package/dist/tools/scale.d.ts +0 -3
- package/dist/tools/scale.d.ts.map +0 -1
- package/dist/tools/scale.js.map +0 -1
- package/dist/tools/screenDiff.d.ts +0 -3
- package/dist/tools/screenDiff.d.ts.map +0 -1
- package/dist/tools/screenDiff.js.map +0 -1
- package/dist/tools/screenshot.d.ts +0 -3
- package/dist/tools/screenshot.d.ts.map +0 -1
- package/dist/tools/screenshot.js.map +0 -1
- package/dist/tools/speed.d.ts +0 -3
- package/dist/tools/speed.d.ts.map +0 -1
- package/dist/tools/speed.js.map +0 -1
- package/dist/tools/startRecording.d.ts +0 -3
- package/dist/tools/startRecording.d.ts.map +0 -1
- package/dist/tools/startRecording.js.map +0 -1
- package/dist/tools/stopRecording.d.ts +0 -3
- package/dist/tools/stopRecording.d.ts.map +0 -1
- package/dist/tools/stopRecording.js.map +0 -1
- package/dist/tools/titleCard.d.ts +0 -3
- package/dist/tools/titleCard.d.ts.map +0 -1
- package/dist/tools/titleCard.js.map +0 -1
- package/dist/tools/transcribe.d.ts +0 -3
- package/dist/tools/transcribe.d.ts.map +0 -1
- package/dist/tools/transcribe.js.map +0 -1
- package/dist/tools/trim.d.ts +0 -3
- package/dist/tools/trim.d.ts.map +0 -1
- package/dist/tools/trim.js.map +0 -1
- package/dist/tools/waitForChange.d.ts +0 -3
- package/dist/tools/waitForChange.d.ts.map +0 -1
- package/dist/tools/waitForChange.js.map +0 -1
- package/dist/tools/xfadeTransition.d.ts +0 -3
- package/dist/tools/xfadeTransition.d.ts.map +0 -1
- package/dist/tools/xfadeTransition.js.map +0 -1
- package/dist/tools/zoom.d.ts +0 -15
- package/dist/tools/zoom.d.ts.map +0 -1
- package/dist/tools/zoom.js.map +0 -1
- package/dist/utils/anim.d.ts +0 -33
- package/dist/utils/anim.d.ts.map +0 -1
- package/dist/utils/anim.js.map +0 -1
- package/dist/utils/animExport.d.ts +0 -27
- package/dist/utils/animExport.d.ts.map +0 -1
- package/dist/utils/animExport.js.map +0 -1
- package/dist/utils/audio.d.ts +0 -49
- package/dist/utils/audio.d.ts.map +0 -1
- package/dist/utils/audio.js.map +0 -1
- package/dist/utils/audioDevices.d.ts +0 -33
- package/dist/utils/audioDevices.d.ts.map +0 -1
- package/dist/utils/audioDevices.js.map +0 -1
- package/dist/utils/callout.d.ts +0 -72
- package/dist/utils/callout.d.ts.map +0 -1
- package/dist/utils/callout.js.map +0 -1
- package/dist/utils/calloutAssets.d.ts +0 -3
- package/dist/utils/calloutAssets.d.ts.map +0 -1
- package/dist/utils/calloutAssets.js.map +0 -1
- package/dist/utils/captions.d.ts +0 -26
- package/dist/utils/captions.d.ts.map +0 -1
- package/dist/utils/captions.js.map +0 -1
- package/dist/utils/diff.d.ts +0 -112
- package/dist/utils/diff.d.ts.map +0 -1
- package/dist/utils/diff.js.map +0 -1
- package/dist/utils/errors.d.ts +0 -33
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/events.d.ts +0 -143
- package/dist/utils/events.d.ts.map +0 -1
- package/dist/utils/events.js.map +0 -1
- package/dist/utils/ffmpeg.d.ts +0 -50
- package/dist/utils/ffmpeg.d.ts.map +0 -1
- package/dist/utils/ffmpeg.js.map +0 -1
- package/dist/utils/fonts.d.ts +0 -17
- package/dist/utils/fonts.d.ts.map +0 -1
- package/dist/utils/fonts.js.map +0 -1
- package/dist/utils/idle.d.ts +0 -23
- package/dist/utils/idle.d.ts.map +0 -1
- package/dist/utils/idle.js.map +0 -1
- package/dist/utils/images.d.ts +0 -21
- package/dist/utils/images.d.ts.map +0 -1
- package/dist/utils/images.js.map +0 -1
- package/dist/utils/jobs.d.ts +0 -44
- package/dist/utils/jobs.d.ts.map +0 -1
- package/dist/utils/jobs.js.map +0 -1
- package/dist/utils/lifecycle.d.ts +0 -29
- package/dist/utils/lifecycle.d.ts.map +0 -1
- package/dist/utils/lifecycle.js.map +0 -1
- package/dist/utils/media.d.ts +0 -272
- package/dist/utils/media.d.ts.map +0 -1
- package/dist/utils/media.js.map +0 -1
- package/dist/utils/monitors.d.ts +0 -47
- package/dist/utils/monitors.d.ts.map +0 -1
- package/dist/utils/monitors.js.map +0 -1
- package/dist/utils/ocr.d.ts +0 -50
- package/dist/utils/ocr.d.ts.map +0 -1
- package/dist/utils/ocr.js.map +0 -1
- package/dist/utils/paths.d.ts +0 -28
- package/dist/utils/paths.d.ts.map +0 -1
- package/dist/utils/paths.js.map +0 -1
- package/dist/utils/pipeline.d.ts +0 -69
- package/dist/utils/pipeline.d.ts.map +0 -1
- package/dist/utils/pipeline.js.map +0 -1
- package/dist/utils/player.d.ts +0 -30
- package/dist/utils/player.d.ts.map +0 -1
- package/dist/utils/player.js.map +0 -1
- package/dist/utils/produce.d.ts +0 -126
- package/dist/utils/produce.d.ts.map +0 -1
- package/dist/utils/produce.js.map +0 -1
- package/dist/utils/resolveTarget.d.ts +0 -32
- package/dist/utils/resolveTarget.d.ts.map +0 -1
- package/dist/utils/resolveTarget.js.map +0 -1
- package/dist/utils/retention.d.ts +0 -10
- package/dist/utils/retention.d.ts.map +0 -1
- package/dist/utils/retention.js.map +0 -1
- package/dist/utils/sessions.d.ts +0 -154
- package/dist/utils/sessions.d.ts.map +0 -1
- package/dist/utils/sessions.js.map +0 -1
- package/dist/utils/sheet.d.ts +0 -26
- package/dist/utils/sheet.d.ts.map +0 -1
- package/dist/utils/sheet.js.map +0 -1
- package/dist/utils/still.d.ts +0 -7
- package/dist/utils/still.d.ts.map +0 -1
- package/dist/utils/still.js.map +0 -1
- package/dist/utils/targets.d.ts +0 -113
- package/dist/utils/targets.d.ts.map +0 -1
- package/dist/utils/targets.js.map +0 -1
- package/dist/utils/validate.d.ts +0 -15
- package/dist/utils/validate.d.ts.map +0 -1
- package/dist/utils/validate.js.map +0 -1
- package/dist/utils/wgc.d.ts +0 -46
- package/dist/utils/wgc.d.ts.map +0 -1
- package/dist/utils/wgc.js.map +0 -1
- package/dist/utils/windows.d.ts +0 -94
- package/dist/utils/windows.d.ts.map +0 -1
- package/dist/utils/windows.js.map +0 -1
- package/dist/utils/zoom.d.ts +0 -95
- package/dist/utils/zoom.d.ts.map +0 -1
- package/dist/utils/zoom.js.map +0 -1
- package/dist/wgcRecorder.d.ts +0 -2
- package/dist/wgcRecorder.d.ts.map +0 -1
- package/dist/wgcRecorder.js.map +0 -1
package/dist/tools/speed.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
+
import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
|
|
4
5
|
import { requireFfmpeg, probeMedia } from "../utils/ffmpeg.js";
|
|
5
6
|
import { runEditJob } from "../utils/jobs.js";
|
|
6
7
|
import { buildSpeedArgs, editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
@@ -12,8 +13,14 @@ const inputSchema = {
|
|
|
12
13
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
13
14
|
};
|
|
14
15
|
export function register(server) {
|
|
15
|
-
server.
|
|
16
|
-
"
|
|
16
|
+
server.registerTool("speed", {
|
|
17
|
+
title: "Change Speed",
|
|
18
|
+
description: "Change playback speed by a factor (>1 faster, <1 slower) and re-encode. " +
|
|
19
|
+
"Audio is retempo'd to match when the source has an audio track.",
|
|
20
|
+
inputSchema,
|
|
21
|
+
outputSchema: OUTPUT_PATH,
|
|
22
|
+
annotations: WRITES_FILE,
|
|
23
|
+
}, async (args, extra) => {
|
|
17
24
|
try {
|
|
18
25
|
requireFfmpeg();
|
|
19
26
|
if (!existsSync(args.input)) {
|
|
@@ -24,7 +31,12 @@ export function register(server) {
|
|
|
24
31
|
const ext = editOutputExt(args.input);
|
|
25
32
|
const output = resolveOutput(args.output, subdir("edits"), `speed-${stamp()}-${rand()}${ext}`, args.overwrite);
|
|
26
33
|
const ffArgs = buildSpeedArgs(args.input, output, args.factor, audioCodec !== null);
|
|
27
|
-
await runEditJob(ffArgs, {
|
|
34
|
+
await runEditJob(ffArgs, {
|
|
35
|
+
output,
|
|
36
|
+
durationSec: durationSec !== null ? durationSec / args.factor : null,
|
|
37
|
+
inputDurationSec: durationSec,
|
|
38
|
+
extra,
|
|
39
|
+
});
|
|
28
40
|
return okResponse({ outputPath: output, factor: args.factor, audio: audioCodec !== null });
|
|
29
41
|
}
|
|
30
42
|
catch (error) {
|
|
@@ -32,4 +44,3 @@ export function register(server) {
|
|
|
32
44
|
}
|
|
33
45
|
});
|
|
34
46
|
}
|
|
35
|
-
//# sourceMappingURL=speed.js.map
|
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
+
import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
|
|
4
5
|
import { requireFfmpeg, wgcAvailable } from "../utils/ffmpeg.js";
|
|
5
6
|
import { fileURLToPath } from "node:url";
|
|
6
7
|
import { buildCaptureArgs, captureFrame, resolveQuality, DEFAULT_FPS, DEFAULT_QUALITY, DEFAULT_MAX_RECORDING_SEC, MAX_RECORDING_CAP_SEC, resolveMaxDuration, captureKeyframeArgs, } from "../utils/targets.js";
|
|
7
8
|
import { resolveCaptureTarget } from "../utils/resolveTarget.js";
|
|
8
9
|
import { windowMatchReport } from "../utils/windows.js";
|
|
9
10
|
import { resolveLoopbackDevice } from "../utils/audioDevices.js";
|
|
11
|
+
import { confirmCapture, describeTarget } from "../utils/consent.js";
|
|
12
|
+
import { logMessage, StderrWatch } from "../utils/logging.js";
|
|
10
13
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
11
14
|
import { getStore } from "../context.js";
|
|
12
|
-
import { classifyUnrequestedExit, killPid } from "../utils/sessions.js";
|
|
15
|
+
import { classifyUnrequestedExit, killPid, serverIdentity } from "../utils/sessions.js";
|
|
13
16
|
import { rmSync } from "node:fs";
|
|
14
|
-
import { basename } from "node:path";
|
|
15
|
-
import {
|
|
17
|
+
import { basename, join } from "node:path";
|
|
18
|
+
import { MAX_REPLAY_SEC, MIN_REPLAY_SEC, discardReplay, planReplayBuffer, prepareReplayDir, segmentOutputArgs, } from "../utils/replay.js";
|
|
19
|
+
import { DEFAULT_KEY_MODE, eventPaths, parseCaptureStart, prepareEventPaths, startEventLogger, stopEventLogger, summarizeEvents, trackFinalizer, writeEventsFile, } from "../utils/events.js";
|
|
16
20
|
const inputSchema = {
|
|
17
21
|
target: z
|
|
18
22
|
.string()
|
|
19
|
-
.describe("
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"ONCE at start (it must be visible, on top, not minimized); it does not " +
|
|
23
|
-
"follow a window moved or resized mid-recording."),
|
|
23
|
+
.describe("full | monitor:<i> (0 = primary) | window:<title> (or window:exe=<app.exe> / window:hwnd=<n>) | " +
|
|
24
|
+
"region:<x>,<y>,<w>,<h>. With gdigrab a window's rectangle is resolved once at start (visible, " +
|
|
25
|
+
"on top); it does not follow the window."),
|
|
24
26
|
exactTitle: z
|
|
25
27
|
.boolean()
|
|
26
28
|
.optional()
|
|
27
|
-
.describe("
|
|
28
|
-
"title (case-insensitive); never fall back to a substring match. Default false."),
|
|
29
|
+
.describe("window: targets match the whole title only, never a substring (default false)."),
|
|
29
30
|
fps: z
|
|
30
31
|
.number()
|
|
31
32
|
.int()
|
|
@@ -41,20 +42,18 @@ const inputSchema = {
|
|
|
41
42
|
.object({
|
|
42
43
|
source: z
|
|
43
44
|
.enum(["system", "none"])
|
|
44
|
-
.describe("system
|
|
45
|
+
.describe("system = what the machine plays (needs a loopback device); none = video only."),
|
|
45
46
|
device: z
|
|
46
47
|
.string()
|
|
47
48
|
.optional()
|
|
48
|
-
.describe("
|
|
49
|
-
"omitted, a loopback device is auto-detected."),
|
|
49
|
+
.describe("dshow loopback device (from list_audio_devices); auto-detected if omitted."),
|
|
50
50
|
})
|
|
51
51
|
.optional()
|
|
52
|
-
.describe("Audio
|
|
53
|
-
"loopback device; microphone capture is not supported."),
|
|
52
|
+
.describe("Audio (default none). No microphone capture."),
|
|
54
53
|
output: z
|
|
55
54
|
.string()
|
|
56
55
|
.optional()
|
|
57
|
-
.describe("
|
|
56
|
+
.describe("Output .mp4 path (default under SCREENCAST_HOME/recordings)."),
|
|
58
57
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
59
58
|
maxDurationSec: z
|
|
60
59
|
.number()
|
|
@@ -62,34 +61,45 @@ const inputSchema = {
|
|
|
62
61
|
.min(0)
|
|
63
62
|
.max(MAX_RECORDING_CAP_SEC)
|
|
64
63
|
.optional()
|
|
65
|
-
.describe(`
|
|
66
|
-
|
|
67
|
-
"A safety net against a recording that is never stopped."),
|
|
64
|
+
.describe(`Auto-stop after this many seconds (default ${DEFAULT_MAX_RECORDING_SEC} or ` +
|
|
65
|
+
"SCREENCAST_MAX_RECORDING_SEC; max 7 days; 0 = no cap)."),
|
|
68
66
|
events: z
|
|
69
67
|
.boolean()
|
|
70
68
|
.optional()
|
|
71
|
-
.describe("Also log
|
|
72
|
-
"
|
|
73
|
-
"false). Read it with read_events. Adds about a second to start."),
|
|
69
|
+
.describe("Also log clicks, scroll, cursor, and typing (video-timed, video pixels) for read_events " +
|
|
70
|
+
"(default false; ~1 s slower start)."),
|
|
74
71
|
keys: z
|
|
75
72
|
.enum(["masked", "shortcuts"])
|
|
76
73
|
.optional()
|
|
77
|
-
.describe("With events: masked (default) logs typing only as
|
|
78
|
-
"
|
|
79
|
-
"or Win (e.g. Ctrl+S), with their times; typed text is never logged."),
|
|
74
|
+
.describe("With events: masked (default) logs typing only as 0.5 s-grid bursts, never keys; shortcuts " +
|
|
75
|
+
"also names Ctrl/Alt/Win chords. Typed text is never logged."),
|
|
80
76
|
backend: z
|
|
81
77
|
.enum(["gdigrab", "wgc"])
|
|
82
78
|
.optional()
|
|
83
|
-
.describe("gdigrab (default)
|
|
84
|
-
"
|
|
85
|
-
|
|
79
|
+
.describe("gdigrab (default): the screen rectangle. wgc (window: targets, FFmpeg 8+): the window's own " +
|
|
80
|
+
"surface, even when covered or moved; client area only, no audio."),
|
|
81
|
+
replayBufferSec: z
|
|
82
|
+
.number()
|
|
83
|
+
.int()
|
|
84
|
+
.min(MIN_REPLAY_SEC)
|
|
85
|
+
.max(MAX_REPLAY_SEC)
|
|
86
|
+
.optional()
|
|
87
|
+
.describe("Instant replay: keep only the last N s (bounded disk) for save_replay. gdigrab only."),
|
|
86
88
|
};
|
|
87
89
|
export function register(server) {
|
|
88
|
-
server.
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
server.registerTool("start_recording", {
|
|
91
|
+
title: "Start Recording",
|
|
92
|
+
description: "Start a background screen recording. Returns a session id; finalize it with stop_recording. " +
|
|
93
|
+
"Never auto-starts.",
|
|
94
|
+
inputSchema,
|
|
95
|
+
outputSchema: looseOutput({
|
|
96
|
+
sessionId: z.string(),
|
|
97
|
+
status: z.string(),
|
|
98
|
+
backend: z.string(),
|
|
99
|
+
outputPath: z.string(),
|
|
100
|
+
}),
|
|
101
|
+
annotations: WRITES_FILE,
|
|
102
|
+
}, async (args, extra) => {
|
|
93
103
|
try {
|
|
94
104
|
const { ffmpeg } = requireFfmpeg();
|
|
95
105
|
const { target, monitors, window } = await resolveCaptureTarget(args.target, {
|
|
@@ -106,16 +116,24 @@ export function register(server) {
|
|
|
106
116
|
throw new ScreencastError('backend "wgc" needs FFmpeg 8 or newer (the gfxcapture filter). Use gdigrab, or update ffmpeg.');
|
|
107
117
|
}
|
|
108
118
|
}
|
|
119
|
+
if (args.replayBufferSec !== undefined && backend === "wgc") {
|
|
120
|
+
throw new ScreencastError('replayBufferSec is not supported with backend "wgc" yet; use gdigrab.');
|
|
121
|
+
}
|
|
122
|
+
const replay = args.replayBufferSec !== undefined ? planReplayBuffer(args.replayBufferSec) : null;
|
|
109
123
|
const fps = args.fps ?? DEFAULT_FPS;
|
|
110
124
|
const quality = args.quality ?? DEFAULT_QUALITY;
|
|
111
125
|
const maxDurationSec = resolveMaxDuration(args.maxDurationSec);
|
|
112
126
|
const output = resolveOutput(args.output, subdir("recordings"), `rec-${stamp()}-${rand()}.mp4`, args.overwrite);
|
|
113
|
-
// Resolve a loopback device up front so a missing one fails before the
|
|
114
|
-
// ffmpeg child is spawned, with a clear install hint.
|
|
115
127
|
const audio = args.audio?.source === "system"
|
|
116
128
|
? { device: await resolveLoopbackDevice(args.audio.device) }
|
|
117
129
|
: undefined;
|
|
118
|
-
|
|
130
|
+
await confirmCapture(server, (replay ? `Keep a rolling ${replay.bufferSec} s replay buffer of ` : "Record ") +
|
|
131
|
+
`${describeTarget(args.target, window)} ` +
|
|
132
|
+
(maxDurationSec > 0 ? `for up to ${maxDurationSec} s` : "with no time limit") +
|
|
133
|
+
(audio ? `, with system audio (${audio.device})` : ", without audio") +
|
|
134
|
+
(args.events ? ", logging mouse clicks and typing" : "") +
|
|
135
|
+
(replay ? ", kept only until save_replay or stop_recording { save: true } writes it out?" : `, saved to ${output}?`), extra.signal);
|
|
136
|
+
const captureArgs = buildCaptureArgs(target, {
|
|
119
137
|
fps,
|
|
120
138
|
quality,
|
|
121
139
|
output,
|
|
@@ -123,10 +141,13 @@ export function register(server) {
|
|
|
123
141
|
audio,
|
|
124
142
|
maxDurationSec,
|
|
125
143
|
});
|
|
126
|
-
|
|
144
|
+
const ffArgs = replay ? segmentOutputArgs(captureArgs, replay) : captureArgs;
|
|
145
|
+
if (replay)
|
|
146
|
+
prepareReplayDir(replay);
|
|
127
147
|
const keyMode = args.keys ?? DEFAULT_KEY_MODE;
|
|
128
|
-
const evPaths = args.events ? eventPaths(output) : null;
|
|
129
|
-
|
|
148
|
+
const evPaths = args.events ? (replay ? { raw: join(replay.dir, "events.raw"), jsonl: "" } : eventPaths(output)) : null;
|
|
149
|
+
if (evPaths && !replay)
|
|
150
|
+
prepareEventPaths(evPaths, args.overwrite);
|
|
130
151
|
let frame = args.events
|
|
131
152
|
? captureFrame(target, monitors)
|
|
132
153
|
: null;
|
|
@@ -141,18 +162,17 @@ export function register(server) {
|
|
|
141
162
|
stdio: ["pipe", "ignore", "pipe"],
|
|
142
163
|
windowsHide: true,
|
|
143
164
|
});
|
|
144
|
-
// Detect an immediate failure (bad window title, busy device, etc.).
|
|
145
|
-
// The head keeps the input banner, whose start: time aligns events.
|
|
146
165
|
let stderrTail = "";
|
|
147
166
|
let stderrHead = "";
|
|
167
|
+
const id = `rec-${stamp()}-${rand(6)}`;
|
|
168
|
+
const watch = new StderrWatch(() => ({ sessionId: id }));
|
|
148
169
|
child.stderr?.on("data", (d) => {
|
|
149
170
|
const text = d.toString();
|
|
150
171
|
stderrTail = (stderrTail + text).slice(-2000);
|
|
151
172
|
if (stderrHead.length < 8000)
|
|
152
173
|
stderrHead += text;
|
|
174
|
+
watch.feed(text);
|
|
153
175
|
});
|
|
154
|
-
// gdigrab is running once it survives a moment; the wgc recorder says
|
|
155
|
-
// so when its first frame is written (a repaint can take a second).
|
|
156
176
|
const settled = await new Promise((resolve) => {
|
|
157
177
|
const timer = setTimeout(() => resolve("running"), backend === "wgc" ? 15_000 : 1200);
|
|
158
178
|
if (backend === "wgc") {
|
|
@@ -173,12 +193,13 @@ export function register(server) {
|
|
|
173
193
|
resolve("exited");
|
|
174
194
|
});
|
|
175
195
|
});
|
|
176
|
-
const id = `rec-${stamp()}-${rand(6)}`;
|
|
177
196
|
if (settled === "exited") {
|
|
178
197
|
if (logger)
|
|
179
198
|
await stopEventLogger(logger);
|
|
180
199
|
if (evPaths)
|
|
181
200
|
rmSync(evPaths.raw, { force: true });
|
|
201
|
+
if (replay)
|
|
202
|
+
discardReplay(replay);
|
|
182
203
|
const tail = stderrTail.trim().split("\n").slice(-6).join("\n");
|
|
183
204
|
throw new ScreencastError(`Recording failed to start (${backend === "wgc" ? "window capture" : "ffmpeg"} exited immediately):\n${tail}`);
|
|
184
205
|
}
|
|
@@ -193,18 +214,27 @@ export function register(server) {
|
|
|
193
214
|
fps,
|
|
194
215
|
quality,
|
|
195
216
|
pid: child.pid ?? null,
|
|
196
|
-
|
|
217
|
+
...serverIdentity(),
|
|
197
218
|
status: "recording",
|
|
198
219
|
startedAt: new Date().toISOString(),
|
|
220
|
+
videoStartMs: parseCaptureStart(stderrHead) ?? spawnedAt,
|
|
199
221
|
...(maxDurationSec > 0 ? { maxDurationSec } : {}),
|
|
200
222
|
...(window ? { matchedWindow: window.matchedTitle } : {}),
|
|
201
|
-
...(evPaths ? { events: { path: evPaths.jsonl, keys: keyMode } } : {}),
|
|
223
|
+
...(evPaths && !replay ? { events: { path: evPaths.jsonl, keys: keyMode } } : {}),
|
|
224
|
+
...(replay
|
|
225
|
+
? {
|
|
226
|
+
replay: {
|
|
227
|
+
...replay,
|
|
228
|
+
...(evPaths && frame
|
|
229
|
+
? { events: { raw: evPaths.raw, keys: keyMode, startMs: parseCaptureStart(stderrHead) ?? spawnedAt, frame } }
|
|
230
|
+
: {}),
|
|
231
|
+
},
|
|
232
|
+
}
|
|
233
|
+
: {}),
|
|
202
234
|
backend,
|
|
203
235
|
processImage: backend === "wgc" ? basename(process.execPath).toLowerCase() : "ffmpeg.exe",
|
|
204
236
|
};
|
|
205
237
|
const store = getStore();
|
|
206
|
-
// Register the child for shutdown first; if the registry write fails,
|
|
207
|
-
// stop the capture rather than leave one nothing can reach (#207).
|
|
208
238
|
store.attachChild(id, child);
|
|
209
239
|
try {
|
|
210
240
|
store.create(record);
|
|
@@ -217,9 +247,15 @@ export function register(server) {
|
|
|
217
247
|
await stopEventLogger(logger);
|
|
218
248
|
if (evPaths)
|
|
219
249
|
rmSync(evPaths.raw, { force: true });
|
|
250
|
+
if (replay)
|
|
251
|
+
discardReplay(replay);
|
|
220
252
|
throw new ScreencastError(`Recording stopped: the session registry could not be written (${err.message}).`);
|
|
221
253
|
}
|
|
222
|
-
if (logger &&
|
|
254
|
+
if (logger && replay) {
|
|
255
|
+
const exited = new Promise((resolve) => child.once("exit", () => resolve()));
|
|
256
|
+
trackFinalizer(id, exited.then(() => stopEventLogger(logger)));
|
|
257
|
+
}
|
|
258
|
+
else if (logger && evPaths && frame) {
|
|
223
259
|
const exited = new Promise((resolve) => child.once("exit", () => resolve()));
|
|
224
260
|
trackFinalizer(id, exited.then(async () => {
|
|
225
261
|
await stopEventLogger(logger);
|
|
@@ -239,19 +275,15 @@ export function register(server) {
|
|
|
239
275
|
process.stderr.write(`Event log for ${id} failed: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
240
276
|
}));
|
|
241
277
|
}
|
|
242
|
-
// Keep the on-disk record consistent if the child dies on its own. A
|
|
243
|
-
// non-zero exit is a crash (disk full, encoder failure), not a clean
|
|
244
|
-
// stop - record it as "failed" with the stderr tail so the caller can
|
|
245
|
-
// tell the two apart. A clean exit nobody requested is the
|
|
246
|
-
// maxDurationSec cap, or the recorded window closing (#240).
|
|
247
278
|
child.on("exit", (code) => {
|
|
248
279
|
store.detachChild(id);
|
|
249
280
|
const cur = store.get(id);
|
|
250
|
-
// A deliberate stop (stop_recording / shutdown) records its own final
|
|
251
|
-
// state; only an exit nobody asked for is classified here.
|
|
252
281
|
if (!cur || cur.status !== "recording" || store.isStopping(id))
|
|
253
282
|
return;
|
|
254
283
|
const verdict = classifyUnrequestedExit({ code, backend, maxDurationSec, elapsedMs: Date.now() - spawnedAt });
|
|
284
|
+
logMessage(verdict.status === "failed" ? "error" : "notice", verdict.status === "failed"
|
|
285
|
+
? `Recording ${id} failed: the recorder exited with code ${code}.`
|
|
286
|
+
: `Recording ${id} ended on its own (${verdict.endReason}).`, { sessionId: id, ...verdict });
|
|
255
287
|
store.tryUpdate(id, {
|
|
256
288
|
...verdict,
|
|
257
289
|
stoppedAt: new Date().toISOString(),
|
|
@@ -271,8 +303,14 @@ export function register(server) {
|
|
|
271
303
|
audioDevice: audio?.device ?? null,
|
|
272
304
|
maxDurationSec: maxDurationSec > 0 ? maxDurationSec : null,
|
|
273
305
|
...(window ? windowMatchReport(window) : {}),
|
|
274
|
-
...(evPaths ? { eventsPath: evPaths.jsonl, keys: keyMode } : {}),
|
|
275
|
-
|
|
306
|
+
...(evPaths && !replay ? { eventsPath: evPaths.jsonl, keys: keyMode } : {}),
|
|
307
|
+
...(replay
|
|
308
|
+
? { replay: { bufferSec: replay.bufferSec, segmentSec: replay.segmentSec, dir: replay.dir, events: !!evPaths } }
|
|
309
|
+
: {}),
|
|
310
|
+
note: (replay
|
|
311
|
+
? `Replay buffer running: save_replay keeps the last seconds (up to ${replay.bufferSec}s) without stopping it; ` +
|
|
312
|
+
"stop_recording discards the buffer unless save: true (then it writes outputPath)."
|
|
313
|
+
: "Call stop_recording with this sessionId to finalize the file.") +
|
|
276
314
|
(maxDurationSec > 0
|
|
277
315
|
? ` It stops on its own after ${maxDurationSec}s (maxDurationSec).`
|
|
278
316
|
: ""),
|
|
@@ -283,4 +321,3 @@ export function register(server) {
|
|
|
283
321
|
}
|
|
284
322
|
});
|
|
285
323
|
}
|
|
286
|
-
//# sourceMappingURL=startRecording.js.map
|
|
@@ -1,23 +1,38 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
+
import { STOPS_SESSION, looseOutput } from "../utils/toolSpec.js";
|
|
4
5
|
import { requireFfmpeg } from "../utils/ffmpeg.js";
|
|
5
6
|
import { probeDuration, stopSession } from "../utils/lifecycle.js";
|
|
6
7
|
import { getStore } from "../context.js";
|
|
7
|
-
import {
|
|
8
|
+
import { finishReplay } from "../utils/replay.js";
|
|
9
|
+
function replayReport(r) {
|
|
10
|
+
return {
|
|
11
|
+
saved: r.saved,
|
|
12
|
+
discarded: r.discarded,
|
|
13
|
+
...(r.save ? { durationSec: r.save.durationSec, eventsPath: r.save.eventsPath } : {}),
|
|
14
|
+
...(r.error ? { error: r.error, note: "The buffer was kept; call stop_recording with save: true again, or save_replay." } : {}),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
8
17
|
const inputSchema = {
|
|
9
18
|
sessionId: z.string().min(1).describe("Session id returned by start_recording."),
|
|
19
|
+
save: z
|
|
20
|
+
.boolean()
|
|
21
|
+
.optional()
|
|
22
|
+
.describe("Replay buffer: write it all to outputPath first (default: discard)."),
|
|
10
23
|
};
|
|
11
24
|
export function register(server) {
|
|
12
25
|
server.registerTool("stop_recording", {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"duration. Falls back to terminating the process by pid if the live " +
|
|
16
|
-
"handle was lost (for example after a server restart). Clients with MCP " +
|
|
17
|
-
"Apps show the review player for the result.",
|
|
26
|
+
title: "Stop Recording",
|
|
27
|
+
description: "Stop a recording gracefully so the file is finalized; returns the path and duration.",
|
|
18
28
|
inputSchema,
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
outputSchema: looseOutput({
|
|
30
|
+
sessionId: z.string(),
|
|
31
|
+
status: z.string(),
|
|
32
|
+
outputPath: z.string(),
|
|
33
|
+
durationSec: z.number().nullable(),
|
|
34
|
+
}),
|
|
35
|
+
annotations: STOPS_SESSION,
|
|
21
36
|
}, async (args) => {
|
|
22
37
|
try {
|
|
23
38
|
const store = getStore();
|
|
@@ -26,7 +41,16 @@ export function register(server) {
|
|
|
26
41
|
throw new ScreencastError(`No session with id "${args.sessionId}".`);
|
|
27
42
|
}
|
|
28
43
|
if (record.status !== "recording") {
|
|
44
|
+
const replay = record.replay && existsSync(record.replay.dir)
|
|
45
|
+
? await finishReplay(record.replay, {
|
|
46
|
+
save: args.save ?? false,
|
|
47
|
+
output: record.outputPath,
|
|
48
|
+
quality: record.quality,
|
|
49
|
+
tools: requireFfmpeg,
|
|
50
|
+
})
|
|
51
|
+
: undefined;
|
|
29
52
|
return okResponse({
|
|
53
|
+
...(replay ? { replay: replayReport(replay) } : {}),
|
|
30
54
|
sessionId: record.id,
|
|
31
55
|
status: record.status,
|
|
32
56
|
outputPath: record.outputPath,
|
|
@@ -40,9 +64,10 @@ export function register(server) {
|
|
|
40
64
|
});
|
|
41
65
|
}
|
|
42
66
|
const { ffprobe } = requireFfmpeg();
|
|
43
|
-
const { record: updated, graceful, durationSec } = await stopSession(store, record, {
|
|
67
|
+
const { record: updated, graceful, durationSec, replay } = await stopSession(store, record, {
|
|
44
68
|
reason: "stopped",
|
|
45
69
|
probe: (path) => probeDuration(ffprobe, path),
|
|
70
|
+
saveReplay: args.save,
|
|
46
71
|
});
|
|
47
72
|
return okResponse({
|
|
48
73
|
sessionId: record.id,
|
|
@@ -50,6 +75,7 @@ export function register(server) {
|
|
|
50
75
|
outputPath: record.outputPath,
|
|
51
76
|
durationSec: durationSec ?? null,
|
|
52
77
|
finalizedGracefully: graceful,
|
|
78
|
+
...(replay ? { replay: replayReport(replay) } : {}),
|
|
53
79
|
...(updated?.events
|
|
54
80
|
? { eventsPath: updated.events.path, events: updated.events.summary ?? {}, ...(updated.events.error ? { eventsError: updated.events.error } : {}) }
|
|
55
81
|
: {}),
|
|
@@ -65,4 +91,3 @@ export function register(server) {
|
|
|
65
91
|
}
|
|
66
92
|
});
|
|
67
93
|
}
|
|
68
|
-
//# sourceMappingURL=stopRecording.js.map
|
package/dist/tools/titleCard.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { writeFileSync, rmSync } from "node:fs";
|
|
3
3
|
import { errorResponse, okResponse } from "../utils/errors.js";
|
|
4
|
+
import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
|
|
4
5
|
import { requireFfmpeg } from "../utils/ffmpeg.js";
|
|
5
6
|
import { runEditJob } from "../utils/jobs.js";
|
|
6
7
|
import { buildTitleCardArgs, DEFAULT_TITLE_DURATION } from "../utils/produce.js";
|
|
7
|
-
import {
|
|
8
|
+
import { resolveTextFont } from "../utils/fonts.js";
|
|
9
|
+
import { fontFileSchema } from "./callout.js";
|
|
8
10
|
import { resolveOutput, subdir, stamp, rand, tempPath } from "../utils/paths.js";
|
|
9
11
|
const inputSchema = {
|
|
10
12
|
text: z.string().min(1).describe("Title text. Multiple lines are allowed (use \\n)."),
|
|
@@ -16,24 +18,27 @@ const inputSchema = {
|
|
|
16
18
|
fontColor: z.string().optional().describe("Text color (default white)."),
|
|
17
19
|
fontSize: z.number().int().positive().optional().describe("Text size in px (default 96)."),
|
|
18
20
|
bold: z.boolean().optional().describe("Use the bold weight (default true)."),
|
|
21
|
+
fontFile: fontFileSchema,
|
|
19
22
|
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
20
23
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
21
24
|
};
|
|
22
25
|
export function register(server) {
|
|
23
|
-
server.
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
26
|
+
server.registerTool("title_card", {
|
|
27
|
+
title: "Title Card",
|
|
28
|
+
description: "Generate a title card clip (centered text on a solid background, silent audio track) to stitch " +
|
|
29
|
+
"in with assemble_highlights. Uncoverable characters are reported in warnings.",
|
|
30
|
+
inputSchema,
|
|
31
|
+
outputSchema: OUTPUT_PATH,
|
|
32
|
+
annotations: WRITES_FILE,
|
|
33
|
+
}, async (args, extra) => {
|
|
27
34
|
try {
|
|
28
35
|
requireFfmpeg();
|
|
29
36
|
const output = resolveOutput(args.output, subdir("edits"), `title-${stamp()}-${rand()}.mp4`, args.overwrite);
|
|
30
|
-
const
|
|
31
|
-
// Write the text to a temp file so arbitrary content (quotes, colons,
|
|
32
|
-
// percent signs) needs no inline filtergraph escaping.
|
|
37
|
+
const font = resolveTextFont(args.text, { weight: args.bold === false ? "regular" : "bold", fontFile: args.fontFile });
|
|
33
38
|
const textFile = tempPath(".txt");
|
|
34
39
|
writeFileSync(textFile, args.text);
|
|
35
40
|
try {
|
|
36
|
-
const ffArgs = buildTitleCardArgs(textFile, fontFile, output, {
|
|
41
|
+
const ffArgs = buildTitleCardArgs(textFile, font.fontFile, output, {
|
|
37
42
|
duration: args.duration,
|
|
38
43
|
width: args.width,
|
|
39
44
|
height: args.height,
|
|
@@ -47,11 +52,14 @@ export function register(server) {
|
|
|
47
52
|
finally {
|
|
48
53
|
rmSync(textFile, { force: true });
|
|
49
54
|
}
|
|
50
|
-
return okResponse({
|
|
55
|
+
return okResponse({
|
|
56
|
+
outputPath: output,
|
|
57
|
+
...((font.fallback || args.fontFile) && { fontFile: font.fontFile }),
|
|
58
|
+
...(font.warning && { warnings: [font.warning] }),
|
|
59
|
+
});
|
|
51
60
|
}
|
|
52
61
|
catch (error) {
|
|
53
62
|
return errorResponse(error);
|
|
54
63
|
}
|
|
55
64
|
});
|
|
56
65
|
}
|
|
57
|
-
//# sourceMappingURL=titleCard.js.map
|
package/dist/tools/transcribe.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
+
import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
|
|
4
5
|
import { requireFfmpeg, runFfmpeg, probeMedia, hasFilter } from "../utils/ffmpeg.js";
|
|
5
6
|
import { jobTimeoutMs } from "../utils/jobs.js";
|
|
6
7
|
import { resolveWhisperModel, buildTranscribeArgs, parseSrt, normalizeCues, formatSrt, WHISPER_MODEL_ENV, } from "../utils/captions.js";
|
|
@@ -16,9 +17,15 @@ const inputSchema = {
|
|
|
16
17
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
17
18
|
};
|
|
18
19
|
export function register(server) {
|
|
19
|
-
server.
|
|
20
|
-
"
|
|
21
|
-
"
|
|
20
|
+
server.registerTool("transcribe", {
|
|
21
|
+
title: "Transcribe Speech",
|
|
22
|
+
description: "Transcribe a recording's speech to an SRT subtitle file, locally, with FFmpeg 8's " +
|
|
23
|
+
"whisper filter (needs a whisper.cpp model file). Returns the SRT path and the text. " +
|
|
24
|
+
"Pair with burn_subtitles to caption the video.",
|
|
25
|
+
inputSchema,
|
|
26
|
+
outputSchema: looseOutput({ srtPath: z.string(), cues: z.number().int(), text: z.string() }),
|
|
27
|
+
annotations: WRITES_FILE,
|
|
28
|
+
}, async (args, extra) => {
|
|
22
29
|
try {
|
|
23
30
|
requireFfmpeg();
|
|
24
31
|
if (!existsSync(args.input))
|
|
@@ -32,11 +39,11 @@ export function register(server) {
|
|
|
32
39
|
if (!info.audioCodec)
|
|
33
40
|
throw new ScreencastError(`Input has no audio to transcribe: ${args.input}`);
|
|
34
41
|
const output = resolveOutput(args.output, subdir("edits"), `captions-${stamp()}-${rand()}.srt`, args.overwrite);
|
|
35
|
-
// whisper writes (appends) to its destination; use a fresh temp file,
|
|
36
|
-
// then tidy it into the output.
|
|
37
42
|
const raw = tempPath(".srt");
|
|
38
43
|
try {
|
|
39
|
-
await runFfmpeg(buildTranscribeArgs(args.input, model, raw, args.language ?? "auto"), jobTimeoutMs(info.durationSec)
|
|
44
|
+
await runFfmpeg(buildTranscribeArgs(args.input, model, raw, args.language ?? "auto"), jobTimeoutMs(info.durationSec), {
|
|
45
|
+
signal: extra.signal,
|
|
46
|
+
});
|
|
40
47
|
const cues = existsSync(raw) ? normalizeCues(parseSrt(readFileSync(raw, "utf8"))) : [];
|
|
41
48
|
writeFileSync(output, formatSrt(cues));
|
|
42
49
|
const text = cues.map((c) => c.text.replace(/\n/g, " ")).join(" ");
|
|
@@ -56,4 +63,3 @@ export function register(server) {
|
|
|
56
63
|
}
|
|
57
64
|
});
|
|
58
65
|
}
|
|
59
|
-
//# sourceMappingURL=transcribe.js.map
|
package/dist/tools/trim.js
CHANGED
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { extname } from "node:path";
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
5
|
+
import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
|
|
5
6
|
import { requireFfmpeg } from "../utils/ffmpeg.js";
|
|
6
7
|
import { runEditJob, probeDuration } from "../utils/jobs.js";
|
|
7
8
|
import { buildTrimArgs, editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
@@ -14,23 +15,25 @@ const inputSchema = {
|
|
|
14
15
|
exact: z
|
|
15
16
|
.boolean()
|
|
16
17
|
.optional()
|
|
17
|
-
.describe("Re-encode
|
|
18
|
-
"
|
|
19
|
-
"still ship in the file, hidden only by an edit list. Never use false to remove sensitive content."),
|
|
18
|
+
.describe("Re-encode for a frame-exact cut with the removed content really gone (default true). false = fast " +
|
|
19
|
+
"stream copy that snaps to a keyframe and keeps hidden earlier frames; never use it to remove secrets."),
|
|
20
20
|
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
21
21
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
22
22
|
};
|
|
23
23
|
export function register(server) {
|
|
24
|
-
server.
|
|
25
|
-
|
|
26
|
-
"
|
|
24
|
+
server.registerTool("trim", {
|
|
25
|
+
title: "Trim Video",
|
|
26
|
+
description: "Cut a video down to one sub-clip by start + (end or duration). For several segments use clip; " +
|
|
27
|
+
"to combine with other edits use pipeline.",
|
|
28
|
+
inputSchema,
|
|
29
|
+
outputSchema: OUTPUT_PATH,
|
|
30
|
+
annotations: WRITES_FILE,
|
|
31
|
+
}, async (args, extra) => {
|
|
27
32
|
try {
|
|
28
33
|
requireFfmpeg();
|
|
29
34
|
if (!existsSync(args.input)) {
|
|
30
35
|
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
31
36
|
}
|
|
32
|
-
// A stream copy keeps the input's container; a re-encode needs one that
|
|
33
|
-
// holds libx264/AAC.
|
|
34
37
|
if (args.exact !== false)
|
|
35
38
|
assertEditContainer(args.output);
|
|
36
39
|
const ext = args.exact === false ? extname(args.input) || ".mp4" : editOutputExt(args.input);
|
|
@@ -41,7 +44,6 @@ export function register(server) {
|
|
|
41
44
|
duration: args.duration,
|
|
42
45
|
exact: args.exact,
|
|
43
46
|
});
|
|
44
|
-
// Length of the trimmed clip, which sizes the job's timeout and progress.
|
|
45
47
|
const start = args.start ?? 0;
|
|
46
48
|
const end = args.end ?? (await probeDuration(args.input));
|
|
47
49
|
const durationSec = args.duration ?? (end !== null ? end - start : null);
|
|
@@ -53,4 +55,3 @@ export function register(server) {
|
|
|
53
55
|
}
|
|
54
56
|
});
|
|
55
57
|
}
|
|
56
|
-
//# sourceMappingURL=trim.js.map
|