@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
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { dirname } 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, probeMedia, hasFilter } from "../utils/ffmpeg.js";
|
|
6
7
|
import { runEditJob } from "../utils/jobs.js";
|
|
7
8
|
import { buildBurnSubtitlesArgs } from "../utils/captions.js";
|
|
@@ -14,13 +15,19 @@ const inputSchema = {
|
|
|
14
15
|
style: z
|
|
15
16
|
.enum(["clean", "social"])
|
|
16
17
|
.optional()
|
|
17
|
-
.describe("
|
|
18
|
+
.describe("clean (default for .srt): outlined line. social: big bold text on a dark box. .ass keeps its own " +
|
|
19
|
+
"styling unless set."),
|
|
18
20
|
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
19
21
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
20
22
|
};
|
|
21
23
|
export function register(server) {
|
|
22
|
-
server.
|
|
23
|
-
"
|
|
24
|
+
server.registerTool("burn_subtitles", {
|
|
25
|
+
title: "Burn In Subtitles",
|
|
26
|
+
description: "Burn SRT/ASS subtitles (e.g. from transcribe) into a video in the bundled font.",
|
|
27
|
+
inputSchema,
|
|
28
|
+
outputSchema: OUTPUT_PATH,
|
|
29
|
+
annotations: WRITES_FILE,
|
|
30
|
+
}, async (args, extra) => {
|
|
24
31
|
try {
|
|
25
32
|
requireFfmpeg();
|
|
26
33
|
for (const f of [args.input, args.subtitles]) {
|
|
@@ -34,17 +41,16 @@ export function register(server) {
|
|
|
34
41
|
const ext = editOutputExt(args.input);
|
|
35
42
|
const output = resolveOutput(args.output, subdir("edits"), `subtitled-${stamp()}-${rand()}${ext}`, args.overwrite);
|
|
36
43
|
const fontsDir = dirname(bundledFontPath("regular"));
|
|
37
|
-
const style = args.style ?? "clean";
|
|
44
|
+
const style = args.style ?? (/\.(ass|ssa)$/i.test(args.subtitles) ? null : "clean");
|
|
38
45
|
await runEditJob(buildBurnSubtitlesArgs(args.input, args.subtitles, output, fontsDir, style), {
|
|
39
46
|
output,
|
|
40
47
|
durationSec: (await probeMedia(args.input)).durationSec,
|
|
41
48
|
extra,
|
|
42
49
|
});
|
|
43
|
-
return okResponse({ outputPath: output, style });
|
|
50
|
+
return okResponse({ outputPath: output, style: style ?? "file" });
|
|
44
51
|
}
|
|
45
52
|
catch (error) {
|
|
46
53
|
return errorResponse(error);
|
|
47
54
|
}
|
|
48
55
|
});
|
|
49
56
|
}
|
|
50
|
-
//# sourceMappingURL=burnSubtitles.js.map
|
package/dist/tools/callout.js
CHANGED
|
@@ -3,6 +3,7 @@ import { join } from "node:path";
|
|
|
3
3
|
import { existsSync, mkdtempSync, rmSync } from "node:fs";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
6
|
+
import { OUTPUT_PATH, WRITES_FILE } from "../utils/toolSpec.js";
|
|
6
7
|
import { requireFfmpeg } from "../utils/ffmpeg.js";
|
|
7
8
|
import { runEditJob, probeDuration } from "../utils/jobs.js";
|
|
8
9
|
import { buildCalloutArgs } from "../utils/callout.js";
|
|
@@ -10,11 +11,16 @@ import { prepareCalloutAssets } from "../utils/calloutAssets.js";
|
|
|
10
11
|
import { editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
11
12
|
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
12
13
|
const timing = {
|
|
13
|
-
from: z.number().nonnegative().optional()
|
|
14
|
-
to: z.number().positive().optional()
|
|
15
|
-
color: z.string().optional()
|
|
14
|
+
from: z.number().nonnegative().optional(),
|
|
15
|
+
to: z.number().positive().optional(),
|
|
16
|
+
color: z.string().optional(),
|
|
16
17
|
};
|
|
17
|
-
|
|
18
|
+
export const fontFileSchema = z
|
|
19
|
+
.string()
|
|
20
|
+
.min(1)
|
|
21
|
+
.optional()
|
|
22
|
+
.describe("Font: a .ttf/.otf/.ttc path or a C:\\Windows\\Fonts file name. Default: bundled Inter, with a " +
|
|
23
|
+
"covering system font for scripts it lacks (CJK, emoji, Arabic, ...).");
|
|
18
24
|
export const calloutItemSchema = z.discriminatedUnion("type", [
|
|
19
25
|
z.object({
|
|
20
26
|
type: z.literal("box"),
|
|
@@ -37,10 +43,10 @@ export const calloutItemSchema = z.discriminatedUnion("type", [
|
|
|
37
43
|
}),
|
|
38
44
|
z.object({
|
|
39
45
|
type: z.literal("arrow"),
|
|
40
|
-
x1: z.number()
|
|
41
|
-
y1: z.number()
|
|
42
|
-
x2: z.number().describe("Head
|
|
43
|
-
y2: z.number()
|
|
46
|
+
x1: z.number(),
|
|
47
|
+
y1: z.number(),
|
|
48
|
+
x2: z.number().describe("Head (x2,y2) is the point the arrow points at."),
|
|
49
|
+
y2: z.number(),
|
|
44
50
|
thickness: z.number().positive().optional().describe("Shaft px (default 8)."),
|
|
45
51
|
...timing,
|
|
46
52
|
}),
|
|
@@ -51,14 +57,21 @@ const inputSchema = {
|
|
|
51
57
|
.array(calloutItemSchema)
|
|
52
58
|
.min(1)
|
|
53
59
|
.max(50)
|
|
54
|
-
.describe("
|
|
55
|
-
"
|
|
60
|
+
.describe("Boxes, text labels, and arrows, drawn in order (later on top), in video pixels. Each shows " +
|
|
61
|
+
"from..to seconds (default: whole video); color is a name, #RRGGBB, or name@alpha."),
|
|
62
|
+
fontFile: fontFileSchema,
|
|
56
63
|
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
57
64
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
58
65
|
};
|
|
59
66
|
export function register(server) {
|
|
60
|
-
server.
|
|
61
|
-
"
|
|
67
|
+
server.registerTool("callout", {
|
|
68
|
+
title: "Add Callouts",
|
|
69
|
+
description: "Annotate a video with timed boxes, text labels, and arrows. Fallback fonts used are listed in " +
|
|
70
|
+
"fallbackFonts; characters no font covers are reported in warnings.",
|
|
71
|
+
inputSchema,
|
|
72
|
+
outputSchema: OUTPUT_PATH,
|
|
73
|
+
annotations: WRITES_FILE,
|
|
74
|
+
}, async (args, extra) => {
|
|
62
75
|
try {
|
|
63
76
|
requireFfmpeg();
|
|
64
77
|
if (!existsSync(args.input)) {
|
|
@@ -68,21 +81,24 @@ export function register(server) {
|
|
|
68
81
|
assertEditContainer(args.output);
|
|
69
82
|
const ext = editOutputExt(args.input);
|
|
70
83
|
const output = resolveOutput(args.output, subdir("edits"), `callout-${stamp()}-${rand()}${ext}`, args.overwrite);
|
|
71
|
-
// Text files and rendered arrows live in a private temp dir.
|
|
72
84
|
const work = mkdtempSync(join(tmpdir(), "screencast-callout-"));
|
|
73
85
|
try {
|
|
74
|
-
const assets = await prepareCalloutAssets(items, work);
|
|
86
|
+
const assets = await prepareCalloutAssets(items, work, "", args.fontFile);
|
|
75
87
|
const ffArgs = buildCalloutArgs(args.input, output, items, assets);
|
|
76
88
|
await runEditJob(ffArgs, { output, durationSec: await probeDuration(args.input), extra });
|
|
89
|
+
return okResponse({
|
|
90
|
+
outputPath: output,
|
|
91
|
+
callouts: items.length,
|
|
92
|
+
...(assets.fallbackFonts.length > 0 && { fallbackFonts: assets.fallbackFonts }),
|
|
93
|
+
...(assets.warnings.length > 0 && { warnings: assets.warnings }),
|
|
94
|
+
});
|
|
77
95
|
}
|
|
78
96
|
finally {
|
|
79
97
|
rmSync(work, { recursive: true, force: true });
|
|
80
98
|
}
|
|
81
|
-
return okResponse({ outputPath: output, callouts: items.length });
|
|
82
99
|
}
|
|
83
100
|
catch (error) {
|
|
84
101
|
return errorResponse(error);
|
|
85
102
|
}
|
|
86
103
|
});
|
|
87
104
|
}
|
|
88
|
-
//# sourceMappingURL=callout.js.map
|
|
@@ -0,0 +1,156 @@
|
|
|
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")
|
|
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
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 { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
|
|
4
5
|
import { requireFfmpeg } from "../utils/ffmpeg.js";
|
|
5
6
|
import { runEditJob } from "../utils/jobs.js";
|
|
6
7
|
import { buildClipArgs, editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
@@ -9,11 +10,11 @@ const inputSchema = {
|
|
|
9
10
|
input: z.string().min(1).describe("Path to the source video."),
|
|
10
11
|
segments: z
|
|
11
12
|
.array(z.object({
|
|
12
|
-
start: z.number().nonnegative()
|
|
13
|
-
end: z.number().positive()
|
|
13
|
+
start: z.number().nonnegative(),
|
|
14
|
+
end: z.number().positive(),
|
|
14
15
|
}))
|
|
15
16
|
.min(1)
|
|
16
|
-
.describe("
|
|
17
|
+
.describe("{start, end} segments in seconds; each becomes its own file."),
|
|
17
18
|
output: z
|
|
18
19
|
.string()
|
|
19
20
|
.optional()
|
|
@@ -21,9 +22,13 @@ const inputSchema = {
|
|
|
21
22
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
22
23
|
};
|
|
23
24
|
export function register(server) {
|
|
24
|
-
server.
|
|
25
|
-
"
|
|
26
|
-
"
|
|
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) => {
|
|
27
32
|
try {
|
|
28
33
|
requireFfmpeg();
|
|
29
34
|
if (!existsSync(args.input)) {
|
|
@@ -33,8 +38,7 @@ export function register(server) {
|
|
|
33
38
|
const ext = editOutputExt(args.input);
|
|
34
39
|
const single = args.segments.length === 1;
|
|
35
40
|
const outputs = [];
|
|
36
|
-
for (
|
|
37
|
-
const seg = args.segments[i];
|
|
41
|
+
for (const [i, seg] of args.segments.entries()) {
|
|
38
42
|
const output = resolveOutput(single ? args.output : undefined, subdir("edits"), `clip-${stamp()}-${rand()}-${String(i).padStart(2, "0")}${ext}`, args.overwrite);
|
|
39
43
|
await runEditJob(buildClipArgs(args.input, output, seg), { output, durationSec: seg.end - seg.start, extra });
|
|
40
44
|
outputs.push(output);
|
|
@@ -46,4 +50,3 @@ export function register(server) {
|
|
|
46
50
|
}
|
|
47
51
|
});
|
|
48
52
|
}
|
|
49
|
-
//# sourceMappingURL=clip.js.map
|
package/dist/tools/compress.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 } from "../utils/ffmpeg.js";
|
|
5
6
|
import { runEditJob, probeDuration } from "../utils/jobs.js";
|
|
6
7
|
import { buildCompressArgs, editOutputExt, assertEditContainer } from "../utils/media.js";
|
|
@@ -10,19 +11,24 @@ const inputSchema = {
|
|
|
10
11
|
level: z
|
|
11
12
|
.enum(["light", "medium", "heavy"])
|
|
12
13
|
.optional()
|
|
13
|
-
.describe("
|
|
14
|
+
.describe("CRF 23 / 28 / 32 (default medium)."),
|
|
14
15
|
maxWidth: z
|
|
15
16
|
.number()
|
|
16
17
|
.int()
|
|
17
18
|
.positive()
|
|
18
19
|
.optional()
|
|
19
|
-
.describe("
|
|
20
|
+
.describe("Width cap in px (only downscales)."),
|
|
20
21
|
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
21
22
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
22
23
|
};
|
|
23
24
|
export function register(server) {
|
|
24
|
-
server.
|
|
25
|
-
"
|
|
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) => {
|
|
26
32
|
try {
|
|
27
33
|
requireFfmpeg();
|
|
28
34
|
if (!existsSync(args.input)) {
|
|
@@ -43,4 +49,3 @@ export function register(server) {
|
|
|
43
49
|
}
|
|
44
50
|
});
|
|
45
51
|
}
|
|
46
|
-
//# sourceMappingURL=compress.js.map
|
package/dist/tools/concat.js
CHANGED
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { extname, resolve } from "node:path";
|
|
3
3
|
import { existsSync, writeFileSync, rmSync } 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, probeMedia } from "../utils/ffmpeg.js";
|
|
6
7
|
import { runEditJob } from "../utils/jobs.js";
|
|
7
8
|
import { buildConcatArgs, buildConcatListContent, concatCopyBlocker, editOutputExt, assertEditContainer, } from "../utils/media.js";
|
|
@@ -11,42 +12,43 @@ const inputSchema = {
|
|
|
11
12
|
inputs: z
|
|
12
13
|
.array(z.string().min(1))
|
|
13
14
|
.min(2)
|
|
14
|
-
.describe("
|
|
15
|
+
.describe("Video paths to join, in order."),
|
|
15
16
|
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
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
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
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) => {
|
|
24
28
|
try {
|
|
25
29
|
requireFfmpeg();
|
|
26
|
-
// The concat demuxer resolves relative list entries against the list
|
|
27
|
-
// file's directory (the OS temp dir), not our cwd, so inputs must be
|
|
28
|
-
// absolute by the time they are written to the list.
|
|
29
30
|
const inputs = args.inputs.map((f) => resolve(f));
|
|
30
31
|
for (const f of inputs) {
|
|
31
32
|
if (!existsSync(f))
|
|
32
33
|
throw new ScreencastError(`Input file not found: ${f}`);
|
|
33
34
|
}
|
|
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.");
|
|
35
40
|
const durations = infos.map((i) => clipLength(i));
|
|
36
41
|
const durationSec = durations.every((d) => d !== null) ? durations.reduce((a, d) => a + d, 0) : null;
|
|
37
|
-
// Mismatched inputs make the concat demuxer write a broken file (#206),
|
|
38
|
-
// and a copy carries any hidden frames along (#203): re-encode then.
|
|
39
42
|
const reason = concatCopyBlocker(inputs, infos);
|
|
40
43
|
if (reason !== null) {
|
|
41
44
|
assertEditContainer(args.output);
|
|
42
|
-
const output = resolveOutput(args.output, subdir("edits"), `concat-${stamp()}-${rand()}${editOutputExt(
|
|
43
|
-
const first = infos[0];
|
|
45
|
+
const output = resolveOutput(args.output, subdir("edits"), `concat-${stamp()}-${rand()}${editOutputExt(firstInput)}`, args.overwrite);
|
|
44
46
|
const even = (n) => (n !== null && n >= 2 ? n - (n % 2) : undefined);
|
|
45
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));
|
|
46
48
|
await runEditJob(ffArgs, { output, durationSec, extra });
|
|
47
49
|
return okResponse({ outputPath: output, inputCount: inputs.length, mode: "reencode", reason });
|
|
48
50
|
}
|
|
49
|
-
const ext = extname(
|
|
51
|
+
const ext = extname(firstInput) || ".mp4";
|
|
50
52
|
const output = resolveOutput(args.output, subdir("edits"), `concat-${stamp()}-${rand()}${ext}`, args.overwrite);
|
|
51
53
|
const listFile = tempPath(".txt");
|
|
52
54
|
writeFileSync(listFile, buildConcatListContent(inputs));
|
|
@@ -63,4 +65,3 @@ export function register(server) {
|
|
|
63
65
|
}
|
|
64
66
|
});
|
|
65
67
|
}
|
|
66
|
-
//# sourceMappingURL=concat.js.map
|
|
@@ -3,6 +3,7 @@ import { join } from "node:path";
|
|
|
3
3
|
import { existsSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
6
|
+
import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
|
|
6
7
|
import { requireFfmpeg, runFfmpeg, runCapture, probeMedia } from "../utils/ffmpeg.js";
|
|
7
8
|
import { jobTimeoutMs } from "../utils/jobs.js";
|
|
8
9
|
import { buildSceneScanArgs, parseSceneScan, pickSceneFrames, DEFAULT_SCENE_THRESHOLD, } from "../utils/media.js";
|
|
@@ -18,18 +19,17 @@ const inputSchema = {
|
|
|
18
19
|
.min(1)
|
|
19
20
|
.max(MAX_SHEET_COUNT)
|
|
20
21
|
.optional()
|
|
21
|
-
.describe(`
|
|
22
|
+
.describe(`Frames to tile (default ${DEFAULT_SHEET_COUNT}).`),
|
|
22
23
|
mode: z
|
|
23
24
|
.enum(["even", "scenes"])
|
|
24
25
|
.optional()
|
|
25
|
-
.describe("
|
|
26
|
-
"opening frame plus the strongest scene changes, so static stretches take no tiles."),
|
|
26
|
+
.describe("even (default) or scenes (strongest changes; static stretches take no tiles)."),
|
|
27
27
|
sceneThreshold: z
|
|
28
28
|
.number()
|
|
29
29
|
.gt(0)
|
|
30
30
|
.lt(1)
|
|
31
31
|
.optional()
|
|
32
|
-
.describe(`Mode
|
|
32
|
+
.describe(`Mode scenes: change needed, 0-1 (default ${DEFAULT_SCENE_THRESHOLD}).`),
|
|
33
33
|
columns: z.number().int().min(1).max(12).optional().describe("Tiles per row (default: roughly square)."),
|
|
34
34
|
tileWidth: z
|
|
35
35
|
.number()
|
|
@@ -37,30 +37,51 @@ const inputSchema = {
|
|
|
37
37
|
.min(64)
|
|
38
38
|
.max(1920)
|
|
39
39
|
.optional()
|
|
40
|
-
.describe(`
|
|
40
|
+
.describe(`Tile width in px (default ${DEFAULT_TILE_WIDTH}).`),
|
|
41
41
|
poster: z
|
|
42
42
|
.boolean()
|
|
43
43
|
.optional()
|
|
44
|
-
.describe("
|
|
45
|
-
"filter over 30 candidates spread across the video), e.g. for a video thumbnail."),
|
|
44
|
+
.describe("Write one representative poster frame instead of a sheet."),
|
|
46
45
|
output: z.string().optional().describe("Optional output .png path. Defaults under SCREENCAST_HOME/frames."),
|
|
47
46
|
overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
|
|
48
47
|
returnImage: z
|
|
49
48
|
.boolean()
|
|
50
49
|
.optional()
|
|
51
|
-
.describe("
|
|
50
|
+
.describe("Return the sheet inline (default true)."),
|
|
52
51
|
maxImageWidth: z
|
|
53
52
|
.number()
|
|
54
53
|
.int()
|
|
55
54
|
.min(16)
|
|
56
55
|
.optional()
|
|
57
|
-
.describe(`
|
|
56
|
+
.describe(`Max inline image width (default ${DEFAULT_MAX_IMAGE_WIDTH}).`),
|
|
58
57
|
};
|
|
58
|
+
export async function renderContactSheet(input, times, output, opts, signal) {
|
|
59
|
+
const grid = sheetGrid(times.length, opts.columns);
|
|
60
|
+
const work = mkdtempSync(join(tmpdir(), "screencast-sheet-"));
|
|
61
|
+
try {
|
|
62
|
+
const font = bundledFontPath("bold");
|
|
63
|
+
for (const [i, t] of times.entries()) {
|
|
64
|
+
const labelFile = join(work, `label_${i}.txt`);
|
|
65
|
+
writeFileSync(labelFile, formatTimecode(t));
|
|
66
|
+
const tile = join(work, `tile_${String(i).padStart(3, "0")}.png`);
|
|
67
|
+
await runFfmpeg(buildTileArgs(input, t, tile, opts.tileWidth, font, labelFile), 60_000, { signal });
|
|
68
|
+
}
|
|
69
|
+
await runFfmpeg(buildSheetArgs(sequencePattern(work, "tile_%03d.png"), grid, output), 60_000, { signal });
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
rmSync(work, { recursive: true, force: true });
|
|
73
|
+
}
|
|
74
|
+
return grid;
|
|
75
|
+
}
|
|
59
76
|
export function register(server) {
|
|
60
|
-
server.
|
|
61
|
-
|
|
62
|
-
"
|
|
63
|
-
|
|
77
|
+
server.registerTool("contact_sheet", {
|
|
78
|
+
title: "Contact Sheet",
|
|
79
|
+
description: "Tile timestamped frames of a video into one image to see a whole recording at a glance " +
|
|
80
|
+
"(the cheapest first look).",
|
|
81
|
+
inputSchema,
|
|
82
|
+
outputSchema: looseOutput({ outputPath: z.string(), inlineImages: z.number().int() }),
|
|
83
|
+
annotations: WRITES_FILE,
|
|
84
|
+
}, async (args, extra) => {
|
|
64
85
|
try {
|
|
65
86
|
const { ffmpeg } = requireFfmpeg();
|
|
66
87
|
if (!existsSync(args.input)) {
|
|
@@ -74,14 +95,16 @@ export function register(server) {
|
|
|
74
95
|
const tileWidth = args.tileWidth ?? DEFAULT_TILE_WIDTH;
|
|
75
96
|
let result;
|
|
76
97
|
if (args.poster) {
|
|
77
|
-
await runFfmpeg(buildPosterArgs(args.input, durationSec, output, Math.max(tileWidth, 1280)), jobTimeoutMs(durationSec)
|
|
98
|
+
await runFfmpeg(buildPosterArgs(args.input, durationSec, output, Math.max(tileWidth, 1280)), jobTimeoutMs(durationSec), {
|
|
99
|
+
signal: extra.signal,
|
|
100
|
+
});
|
|
78
101
|
result = { outputPath: output, poster: true };
|
|
79
102
|
}
|
|
80
103
|
else {
|
|
81
104
|
const count = args.count ?? DEFAULT_SHEET_COUNT;
|
|
82
105
|
let times;
|
|
83
106
|
if (args.mode === "scenes") {
|
|
84
|
-
const scan = await runCapture(ffmpeg, buildSceneScanArgs(args.input, args.sceneThreshold ?? DEFAULT_SCENE_THRESHOLD), jobTimeoutMs(durationSec));
|
|
107
|
+
const scan = await runCapture(ffmpeg, buildSceneScanArgs(args.input, args.sceneThreshold ?? DEFAULT_SCENE_THRESHOLD), jobTimeoutMs(durationSec), { signal: extra.signal });
|
|
85
108
|
if (scan.code !== 0) {
|
|
86
109
|
throw new ScreencastError(`Scene scan failed (exit ${scan.code}): ${scan.stderr.trim().slice(-400)}`);
|
|
87
110
|
}
|
|
@@ -90,23 +113,7 @@ export function register(server) {
|
|
|
90
113
|
else {
|
|
91
114
|
times = evenTimes(durationSec, count);
|
|
92
115
|
}
|
|
93
|
-
const grid =
|
|
94
|
-
// Tiles and their label files live in a private temp dir, removed
|
|
95
|
-
// whatever happens.
|
|
96
|
-
const work = mkdtempSync(join(tmpdir(), "screencast-sheet-"));
|
|
97
|
-
try {
|
|
98
|
-
const font = bundledFontPath("bold");
|
|
99
|
-
for (let i = 0; i < times.length; i++) {
|
|
100
|
-
const labelFile = join(work, `label_${i}.txt`);
|
|
101
|
-
writeFileSync(labelFile, formatTimecode(times[i]));
|
|
102
|
-
const tile = join(work, `tile_${String(i).padStart(3, "0")}.png`);
|
|
103
|
-
await runFfmpeg(buildTileArgs(args.input, times[i], tile, tileWidth, font, labelFile), 60_000);
|
|
104
|
-
}
|
|
105
|
-
await runFfmpeg(buildSheetArgs(sequencePattern(work, "tile_%03d.png"), grid, output), 60_000);
|
|
106
|
-
}
|
|
107
|
-
finally {
|
|
108
|
-
rmSync(work, { recursive: true, force: true });
|
|
109
|
-
}
|
|
116
|
+
const grid = await renderContactSheet(args.input, times, output, { tileWidth, columns: args.columns }, extra.signal);
|
|
110
117
|
result = {
|
|
111
118
|
outputPath: output,
|
|
112
119
|
mode: args.mode ?? "even",
|
|
@@ -125,4 +132,3 @@ export function register(server) {
|
|
|
125
132
|
}
|
|
126
133
|
});
|
|
127
134
|
}
|
|
128
|
-
//# sourceMappingURL=contactSheet.js.map
|