@tmhs/screencast-mcp 0.49.0 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -8
- package/dist/index.js +550 -106
- package/dist/wgcRecorder.js +15 -139
- package/package.json +8 -4
- package/assets/.gitkeep +0 -0
- package/assets/icon.png +0 -0
- package/dist/cli.js +0 -516
- package/dist/context.js +0 -50
- package/dist/prompts.js +0 -95
- package/dist/resources.js +0 -93
- package/dist/server.js +0 -174
- package/dist/setup.js +0 -438
- package/dist/tools/addMarker.js +0 -93
- package/dist/tools/assembleHighlights.js +0 -69
- package/dist/tools/backdrop.js +0 -89
- package/dist/tools/bugReport.js +0 -266
- package/dist/tools/burnSubtitles.js +0 -56
- package/dist/tools/callout.js +0 -103
- package/dist/tools/chapters.js +0 -156
- package/dist/tools/clip.js +0 -52
- package/dist/tools/compress.js +0 -51
- package/dist/tools/concat.js +0 -67
- package/dist/tools/contactSheet.js +0 -135
- package/dist/tools/convert.js +0 -46
- package/dist/tools/crop.js +0 -43
- package/dist/tools/cursor.js +0 -87
- package/dist/tools/cutByTranscript.js +0 -86
- package/dist/tools/cutIdle.js +0 -84
- package/dist/tools/deleteRecording.js +0 -119
- package/dist/tools/denoise.js +0 -60
- package/dist/tools/doctor.js +0 -146
- package/dist/tools/exportGif.js +0 -57
- package/dist/tools/exportPreset.js +0 -48
- package/dist/tools/extractAudio.js +0 -65
- package/dist/tools/findText.js +0 -196
- package/dist/tools/getMediaInfo.js +0 -36
- package/dist/tools/getSession.js +0 -40
- package/dist/tools/indexRecording.js +0 -195
- package/dist/tools/keystrokeOverlay.js +0 -131
- package/dist/tools/listAudioDevices.js +0 -35
- package/dist/tools/listSessions.js +0 -28
- package/dist/tools/listTargets.js +0 -76
- package/dist/tools/listVideoDevices.js +0 -26
- package/dist/tools/musicBed.js +0 -55
- package/dist/tools/narrate.js +0 -86
- package/dist/tools/normalizeAudio.js +0 -60
- package/dist/tools/overlay.js +0 -62
- package/dist/tools/pauseRecording.js +0 -44
- package/dist/tools/pipeline.js +0 -400
- package/dist/tools/readEvents.js +0 -98
- package/dist/tools/redactRegion.js +0 -70
- package/dist/tools/reframe.js +0 -46
- package/dist/tools/resumeRecording.js +0 -46
- package/dist/tools/reviewRecording.js +0 -163
- package/dist/tools/sampleFrames.js +0 -200
- package/dist/tools/saveReplay.js +0 -90
- package/dist/tools/scale.js +0 -44
- package/dist/tools/screenDiff.js +0 -86
- package/dist/tools/screenshot.js +0 -76
- package/dist/tools/searchRecording.js +0 -79
- package/dist/tools/speed.js +0 -46
- package/dist/tools/startRecording.js +0 -398
- package/dist/tools/stepGuide.js +0 -250
- package/dist/tools/stopRecording.js +0 -132
- package/dist/tools/titleCard.js +0 -67
- package/dist/tools/transcribe.js +0 -66
- package/dist/tools/trim.js +0 -57
- package/dist/tools/waitForChange.js +0 -128
- package/dist/tools/xfadeTransition.js +0 -58
- package/dist/tools/zoom.js +0 -149
- package/dist/utils/anim.js +0 -54
- package/dist/utils/animExport.js +0 -56
- package/dist/utils/argPaths.js +0 -39
- package/dist/utils/audio.js +0 -113
- package/dist/utils/audioDevices.js +0 -107
- package/dist/utils/backdrop.js +0 -151
- package/dist/utils/bugReport.js +0 -172
- package/dist/utils/callout.js +0 -90
- package/dist/utils/calloutAssets.js +0 -42
- package/dist/utils/capabilities.js +0 -96
- package/dist/utils/captions.js +0 -103
- package/dist/utils/chapters.js +0 -227
- package/dist/utils/consent.js +0 -29
- package/dist/utils/cursor.js +0 -317
- package/dist/utils/diff.js +0 -184
- package/dist/utils/errors.js +0 -29
- package/dist/utils/events.js +0 -403
- package/dist/utils/expr.js +0 -11
- package/dist/utils/ffmpeg.js +0 -285
- package/dist/utils/fontCoverage.js +0 -177
- package/dist/utils/fonts.js +0 -154
- package/dist/utils/gpu.js +0 -219
- package/dist/utils/idle.js +0 -91
- package/dist/utils/images.js +0 -38
- package/dist/utils/jobs.js +0 -129
- package/dist/utils/keystrokes.js +0 -155
- package/dist/utils/lifecycle.js +0 -233
- package/dist/utils/logging.js +0 -75
- package/dist/utils/media.js +0 -574
- package/dist/utils/monitors.js +0 -124
- package/dist/utils/narrate.js +0 -233
- package/dist/utils/ocr.js +0 -222
- package/dist/utils/ocrScan.js +0 -91
- package/dist/utils/paths.js +0 -155
- package/dist/utils/pause.js +0 -190
- package/dist/utils/pipeline.js +0 -361
- package/dist/utils/player.js +0 -85
- package/dist/utils/pool.js +0 -29
- package/dist/utils/produce.js +0 -298
- package/dist/utils/recipes.js +0 -71
- package/dist/utils/recorder.js +0 -173
- package/dist/utils/recordingFiles.js +0 -32
- package/dist/utils/recordingIndex.js +0 -312
- package/dist/utils/replay.js +0 -283
- package/dist/utils/resolveTarget.js +0 -25
- package/dist/utils/retention.js +0 -48
- package/dist/utils/roots.js +0 -43
- package/dist/utils/sessions.js +0 -499
- package/dist/utils/sheet.js +0 -59
- package/dist/utils/stepGuide.js +0 -231
- package/dist/utils/steps.js +0 -88
- package/dist/utils/still.js +0 -38
- package/dist/utils/targetList.js +0 -64
- package/dist/utils/targets.js +0 -265
- package/dist/utils/timeline.js +0 -85
- package/dist/utils/toolSpec.js +0 -31
- package/dist/utils/toolsets.js +0 -134
- package/dist/utils/transcriptCut.js +0 -149
- package/dist/utils/validate.js +0 -23
- package/dist/utils/waitLoop.js +0 -50
- package/dist/utils/wgc.js +0 -84
- package/dist/utils/windows.js +0 -192
- package/dist/utils/zoom.js +0 -234
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { errorMessage, ScreencastError } from "./errors.js";
|
|
2
|
-
import { requireFfmpeg, runCapture } from "./ffmpeg.js";
|
|
3
|
-
export const LOOPBACK_HINTS = [
|
|
4
|
-
"virtual-audio-capturer",
|
|
5
|
-
"stereo mix",
|
|
6
|
-
"what u hear",
|
|
7
|
-
"wave out mix",
|
|
8
|
-
"cable output",
|
|
9
|
-
"voicemeeter output",
|
|
10
|
-
];
|
|
11
|
-
export const NO_LOOPBACK_HINT = "System audio capture needs a virtual-audio loopback device, which Windows " +
|
|
12
|
-
"does not provide natively. Enable 'Stereo Mix' in Sound settings, or install " +
|
|
13
|
-
"a loopback driver (for example screen-capture-recorder's " +
|
|
14
|
-
"virtual-audio-capturer, or VB-CABLE). Then pass its name as `device`, or run " +
|
|
15
|
-
"list_audio_devices to see what is available. Microphone capture is not supported.";
|
|
16
|
-
export function parseDshowAudioDevices(stderr) {
|
|
17
|
-
return parseDshowDevices(stderr, "audio");
|
|
18
|
-
}
|
|
19
|
-
export function parseDshowVideoDevices(stderr) {
|
|
20
|
-
return parseDshowDevices(stderr, "video");
|
|
21
|
-
}
|
|
22
|
-
function parseDshowDevices(stderr, kind) {
|
|
23
|
-
const names = [];
|
|
24
|
-
let section = null;
|
|
25
|
-
for (const line of stderr.split(/\r?\n/)) {
|
|
26
|
-
if (/DirectShow audio devices/i.test(line)) {
|
|
27
|
-
section = "audio";
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (/DirectShow video devices/i.test(line)) {
|
|
31
|
-
section = "video";
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
if (/Alternative name/i.test(line))
|
|
35
|
-
continue;
|
|
36
|
-
const quoted = line.match(/"([^"]+)"/);
|
|
37
|
-
if (!quoted)
|
|
38
|
-
continue;
|
|
39
|
-
const inlineAudio = /\(audio\)/i.test(line);
|
|
40
|
-
const inlineVideo = /\(video\)/i.test(line);
|
|
41
|
-
const isAudio = inlineAudio || (!inlineVideo && section === "audio");
|
|
42
|
-
const isVideo = inlineVideo || (!inlineAudio && section === "video");
|
|
43
|
-
if ((kind === "audio" ? isAudio : isVideo) && quoted[1])
|
|
44
|
-
names.push(quoted[1]);
|
|
45
|
-
}
|
|
46
|
-
return [...new Set(names)];
|
|
47
|
-
}
|
|
48
|
-
export function pickLoopbackDevice(devices, explicit) {
|
|
49
|
-
if (explicit && explicit.trim().length > 0) {
|
|
50
|
-
return devices.includes(explicit) ? explicit : null;
|
|
51
|
-
}
|
|
52
|
-
const lower = (s) => s.toLowerCase();
|
|
53
|
-
return (devices.find((d) => LOOPBACK_HINTS.some((h) => lower(d).includes(h))) ?? null);
|
|
54
|
-
}
|
|
55
|
-
export const ENUM_TIMEOUT_MS = 12_000;
|
|
56
|
-
const ENUM_FAILED_HINT = "Enumerating DirectShow audio devices timed out or failed - usually a " +
|
|
57
|
-
"misbehaving audio driver, or no audio device present. Record without system " +
|
|
58
|
-
"audio, or fix the device, then retry. " + NO_LOOPBACK_HINT;
|
|
59
|
-
let cachedDevices = null;
|
|
60
|
-
let cachedVideo = null;
|
|
61
|
-
export async function listDshowAudioDevices(forceRefresh = false) {
|
|
62
|
-
if (!forceRefresh && cachedDevices)
|
|
63
|
-
return cachedDevices;
|
|
64
|
-
await enumerateDshow();
|
|
65
|
-
return cachedDevices ?? [];
|
|
66
|
-
}
|
|
67
|
-
export async function listDshowVideoDevices(forceRefresh = false) {
|
|
68
|
-
if (!forceRefresh && cachedVideo)
|
|
69
|
-
return cachedVideo;
|
|
70
|
-
await enumerateDshow();
|
|
71
|
-
return cachedVideo ?? [];
|
|
72
|
-
}
|
|
73
|
-
export async function resolveVideoDevice(explicit) {
|
|
74
|
-
const devices = await listDshowVideoDevices();
|
|
75
|
-
if (explicit && explicit.trim().length > 0) {
|
|
76
|
-
if (devices.includes(explicit))
|
|
77
|
-
return explicit;
|
|
78
|
-
throw new ScreencastError(`Video device "${explicit}" not found. Available dshow video devices: ${devices.join(", ") || "none"}.`);
|
|
79
|
-
}
|
|
80
|
-
const first = devices[0];
|
|
81
|
-
if (!first)
|
|
82
|
-
throw new ScreencastError("No webcam (dshow video device) found.", "Connect a camera, then run list_video_devices.");
|
|
83
|
-
return first;
|
|
84
|
-
}
|
|
85
|
-
async function enumerateDshow() {
|
|
86
|
-
const { ffmpeg } = requireFfmpeg();
|
|
87
|
-
let res;
|
|
88
|
-
try {
|
|
89
|
-
res = await runCapture(ffmpeg, ["-hide_banner", "-list_devices", "true", "-f", "dshow", "-i", "dummy"], ENUM_TIMEOUT_MS, { closeStdin: true });
|
|
90
|
-
}
|
|
91
|
-
catch (err) {
|
|
92
|
-
throw new ScreencastError(`Could not enumerate audio devices (${errorMessage(err)}).`, ENUM_FAILED_HINT);
|
|
93
|
-
}
|
|
94
|
-
cachedDevices = parseDshowAudioDevices(res.stderr);
|
|
95
|
-
cachedVideo = parseDshowVideoDevices(res.stderr);
|
|
96
|
-
}
|
|
97
|
-
export async function resolveLoopbackDevice(explicit) {
|
|
98
|
-
const devices = await listDshowAudioDevices();
|
|
99
|
-
const picked = pickLoopbackDevice(devices, explicit);
|
|
100
|
-
if (picked)
|
|
101
|
-
return picked;
|
|
102
|
-
if (explicit && explicit.trim().length > 0) {
|
|
103
|
-
const available = devices.length > 0 ? devices.join(", ") : "none";
|
|
104
|
-
throw new ScreencastError(`Audio device "${explicit}" not found. Available dshow audio devices: ${available}.`, NO_LOOPBACK_HINT);
|
|
105
|
-
}
|
|
106
|
-
throw new ScreencastError("No system-audio loopback device found.", NO_LOOPBACK_HINT);
|
|
107
|
-
}
|
package/dist/utils/backdrop.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { ScreencastError } from "./errors.js";
|
|
2
|
-
import { validateColor } from "./validate.js";
|
|
3
|
-
import { ASPECT_DIMS } from "./produce.js";
|
|
4
|
-
import { resolveQuality } from "./targets.js";
|
|
5
|
-
import { stillOutput } from "./paths.js";
|
|
6
|
-
export const BACKDROP_PRESETS = {
|
|
7
|
-
desktop: ["#1B2330", "#0A0D12"],
|
|
8
|
-
rec: ["#FF4545", "#5C0F1A"],
|
|
9
|
-
amber: ["#FFB454", "#FF4545"],
|
|
10
|
-
light: ["#F4F7FA", "#B9C4D0"],
|
|
11
|
-
};
|
|
12
|
-
export const BACKDROP_PRESET_NAMES = Object.keys(BACKDROP_PRESETS);
|
|
13
|
-
export const DEFAULT_BACKDROP_PRESET = "desktop";
|
|
14
|
-
export const MAX_BACKDROP_COLORS = 4;
|
|
15
|
-
export const DEFAULT_SHADOW_OPACITY = 0.5;
|
|
16
|
-
const even = (n) => 2 * Math.round(n / 2);
|
|
17
|
-
const evenDown = (n) => 2 * Math.floor(n / 2);
|
|
18
|
-
function nonNegInt(v, label, max) {
|
|
19
|
-
if (v === undefined)
|
|
20
|
-
return undefined;
|
|
21
|
-
if (!Number.isFinite(v) || v < 0 || v > max)
|
|
22
|
-
throw new ScreencastError(`${label} must be between 0 and ${max}.`);
|
|
23
|
-
return Math.round(v);
|
|
24
|
-
}
|
|
25
|
-
export function backdropLayout(W, H, opts = {}) {
|
|
26
|
-
if (!(W > 0 && H > 0))
|
|
27
|
-
throw new ScreencastError("The input has no frame size.");
|
|
28
|
-
const padOpt = nonNegInt(opts.padding, "padding", 2000);
|
|
29
|
-
const radiusOpt = nonNegInt(opts.radius, "radius", 1000);
|
|
30
|
-
const shadowOpt = nonNegInt(opts.shadow, "shadow", 200);
|
|
31
|
-
let canvasW;
|
|
32
|
-
let canvasH;
|
|
33
|
-
let contentW = W;
|
|
34
|
-
let contentH = H;
|
|
35
|
-
let x;
|
|
36
|
-
let y;
|
|
37
|
-
let padding;
|
|
38
|
-
let scaled = false;
|
|
39
|
-
if (opts.aspect) {
|
|
40
|
-
const dim = ASPECT_DIMS[opts.aspect];
|
|
41
|
-
if (!dim)
|
|
42
|
-
throw new ScreencastError(`Unknown aspect "${opts.aspect}".`);
|
|
43
|
-
canvasW = dim.w;
|
|
44
|
-
canvasH = dim.h;
|
|
45
|
-
padding = even(padOpt ?? Math.max(canvasW, canvasH) * 0.06);
|
|
46
|
-
const availW = canvasW - 2 * padding;
|
|
47
|
-
const availH = canvasH - 2 * padding;
|
|
48
|
-
if (availW < 16 || availH < 16)
|
|
49
|
-
throw new ScreencastError(`padding ${padding} leaves no room on a ${opts.aspect} canvas.`);
|
|
50
|
-
const s = Math.min(availW / W, availH / H);
|
|
51
|
-
contentW = Math.max(2, evenDown(W * s));
|
|
52
|
-
contentH = Math.max(2, evenDown(H * s));
|
|
53
|
-
scaled = contentW !== W || contentH !== H;
|
|
54
|
-
x = evenDown((canvasW - contentW) / 2);
|
|
55
|
-
y = evenDown((canvasH - contentH) / 2);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
padding = even(padOpt ?? Math.max(W, H) * 0.06);
|
|
59
|
-
canvasW = W + 2 * padding + (W % 2);
|
|
60
|
-
canvasH = H + 2 * padding + (H % 2);
|
|
61
|
-
x = padding;
|
|
62
|
-
y = padding;
|
|
63
|
-
}
|
|
64
|
-
const longer = Math.max(contentW, contentH);
|
|
65
|
-
const radius = Math.min(radiusOpt ?? Math.round(longer * 0.012), Math.floor(Math.min(contentW, contentH) / 2));
|
|
66
|
-
const shadow = shadowOpt ?? Math.round(longer * 0.025);
|
|
67
|
-
const below = canvasH - y - contentH;
|
|
68
|
-
const shadowOffset = shadow > 0 ? Math.max(0, Math.min(Math.round(shadow / 2), below)) : 0;
|
|
69
|
-
return { canvasW, canvasH, contentW, contentH, x, y, padding, radius, shadow, shadowOffset, scaled };
|
|
70
|
-
}
|
|
71
|
-
export function backdropColors(opts) {
|
|
72
|
-
if (opts.colors !== undefined) {
|
|
73
|
-
if (opts.colors.length < 1 || opts.colors.length > MAX_BACKDROP_COLORS) {
|
|
74
|
-
throw new ScreencastError(`colors takes 1 to ${MAX_BACKDROP_COLORS} colors.`);
|
|
75
|
-
}
|
|
76
|
-
return opts.colors.map((c, i) => validateColor(c, `colors[${i}]`));
|
|
77
|
-
}
|
|
78
|
-
const preset = opts.preset ?? DEFAULT_BACKDROP_PRESET;
|
|
79
|
-
const colors = BACKDROP_PRESETS[preset];
|
|
80
|
-
if (!colors)
|
|
81
|
-
throw new ScreencastError(`Unknown backdrop preset "${preset}".`);
|
|
82
|
-
return [...colors];
|
|
83
|
-
}
|
|
84
|
-
export function roundedMaskExpr(radius, invert = false) {
|
|
85
|
-
const r = radius;
|
|
86
|
-
const dx = `max(max(${r}-X-0.5,X+0.5-(W-${r})),0)`;
|
|
87
|
-
const dy = `max(max(${r}-Y-0.5,Y+0.5-(H-${r})),0)`;
|
|
88
|
-
const inside = `clip(${r}+0.5-hypot(${dx},${dy}),0,1)`;
|
|
89
|
-
return invert ? `255-255*${inside}` : `255*${inside}`;
|
|
90
|
-
}
|
|
91
|
-
export function backdropSteps(opts, src, input, firstInput, tag, still = false) {
|
|
92
|
-
const L = backdropLayout(src.width, src.height, opts);
|
|
93
|
-
if (opts.shadowOpacity !== undefined && !(opts.shadowOpacity >= 0 && opts.shadowOpacity <= 1)) {
|
|
94
|
-
throw new ScreencastError("shadowOpacity must be between 0 and 1.");
|
|
95
|
-
}
|
|
96
|
-
const opacity = opts.shadowOpacity ?? DEFAULT_SHADOW_OPACITY;
|
|
97
|
-
const { canvasW: CW, canvasH: CH, contentW: w, contentH: h, x, y } = L;
|
|
98
|
-
const one = ":r=1:d=1";
|
|
99
|
-
const steps = [];
|
|
100
|
-
const extraInputs = [];
|
|
101
|
-
const bg = `[${tag}bg]`;
|
|
102
|
-
if (opts.image) {
|
|
103
|
-
extraInputs.push("-i", opts.image);
|
|
104
|
-
steps.push(`[${firstInput}:v]scale=${CW}:${CH}:force_original_aspect_ratio=increase,crop=${CW}:${CH},setsar=1,trim=end_frame=1,format=rgba${bg}`);
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
const colors = backdropColors(opts);
|
|
108
|
-
if (colors.length === 1) {
|
|
109
|
-
steps.push(`color=c=${colors[0]}:s=${CW}x${CH}${one},format=rgba${bg}`);
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
const cs = colors.map((c, i) => `c${i}=${c}`).join(":");
|
|
113
|
-
steps.push(`gradients=s=${CW}x${CH}:${cs}:n=${colors.length}:x0=0:y0=0:x1=${CW}:y1=${CH}:r=1,trim=end_frame=1,format=rgba${bg}`);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
let base = bg;
|
|
117
|
-
if (L.shadow > 0 && opacity > 0) {
|
|
118
|
-
const sa = `[${tag}sa]`;
|
|
119
|
-
const sc = `[${tag}sc]`;
|
|
120
|
-
const sh = `[${tag}sh]`;
|
|
121
|
-
const bs = `[${tag}bs]`;
|
|
122
|
-
const shape = L.radius > 0 ? `format=gray,geq=lum='${roundedMaskExpr(L.radius)}'` : "format=gray";
|
|
123
|
-
steps.push(`color=c=white:s=${w}x${h}${one},${shape},pad=${CW}:${CH}:${x}:${y + L.shadowOffset}:color=black,` +
|
|
124
|
-
`gblur=sigma=${(L.shadow / 2).toFixed(2)}${sa}`);
|
|
125
|
-
steps.push(`color=c=black:s=${CW}x${CH}${one}${sc}`);
|
|
126
|
-
steps.push(`${sc}${sa}alphamerge,format=rgba,colorchannelmixer=aa=${opacity}${sh}`);
|
|
127
|
-
steps.push(`${base}${sh}overlay=0:0:format=rgb${bs}`);
|
|
128
|
-
base = bs;
|
|
129
|
-
}
|
|
130
|
-
const hole = `[${tag}hole]`;
|
|
131
|
-
const frame = `[${tag}frame]`;
|
|
132
|
-
const holeShape = L.radius > 0 ? `format=gray,geq=lum='${roundedMaskExpr(L.radius, true)}'` : "format=gray";
|
|
133
|
-
steps.push(`color=c=black:s=${w}x${h}${one},${holeShape},pad=${CW}:${CH}:${x}:${y}:color=white${hole}`);
|
|
134
|
-
steps.push(`${base}${hole}alphamerge,format=rgba${frame}`);
|
|
135
|
-
const padded = `[${tag}pad]`;
|
|
136
|
-
const out = `[${tag}bd]`;
|
|
137
|
-
const fit = L.scaled ? `scale=${w}:${h},setsar=1,` : "";
|
|
138
|
-
steps.push(`${input}${fit}pad=${CW}:${CH}:${x}:${y}:color=black${padded}`);
|
|
139
|
-
steps.push(`${padded}${frame}overlay=0:0${still ? ":format=rgb" : ""}${out}`);
|
|
140
|
-
return { steps, out, extraInputs, layout: L };
|
|
141
|
-
}
|
|
142
|
-
export function buildBackdropArgs(input, output, opts, src, still = false, quality = "standard") {
|
|
143
|
-
const { steps, out, extraInputs, layout } = backdropSteps(opts, src, "[0:v]", 1, "", still);
|
|
144
|
-
const final = "[vout]";
|
|
145
|
-
steps.push(`${out}format=${still ? "rgb24" : "yuv420p"}${final}`);
|
|
146
|
-
const head = ["-y", "-i", input, ...extraInputs, "-filter_complex", steps.join(";"), "-map", final];
|
|
147
|
-
const args = still
|
|
148
|
-
? [...head, "-frames:v", "1", ...stillOutput(output)]
|
|
149
|
-
: [...head, "-map", "0:a?", ...resolveQuality(quality), "-c:a", "copy", "-movflags", "+faststart", output];
|
|
150
|
-
return { args, layout };
|
|
151
|
-
}
|
package/dist/utils/bugReport.js
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { ScreencastError } from "./errors.js";
|
|
2
|
-
import { findMatches, normalizeForMatch, regexRanges } from "./ocr.js";
|
|
3
|
-
import { formatTimecode } from "./sheet.js";
|
|
4
|
-
export const DEFAULT_CLIP_SEC = 30;
|
|
5
|
-
export const MAX_CLIP_SEC = 600;
|
|
6
|
-
export const DEFAULT_SCAN_EVERY_SEC = 1;
|
|
7
|
-
export const MAX_STEPS = 100;
|
|
8
|
-
export const MAX_ERROR_LINES = 20;
|
|
9
|
-
export const DEFAULT_SECRET_PATTERN = [
|
|
10
|
-
"\\b(?:sk|pk|rk)-[a-z0-9_-]{8,}",
|
|
11
|
-
"\\bgh[pousr]_[a-z0-9]{10,}",
|
|
12
|
-
"\\bgithub_pat_[a-z0-9_]{10,}",
|
|
13
|
-
"\\bxox[abprs]-[a-z0-9-]{8,}",
|
|
14
|
-
"\\bAKIA[0-9A-Z]{12,}",
|
|
15
|
-
"\\bAIza[0-9a-z_-]{20,}",
|
|
16
|
-
"\\beyJ[a-z0-9_-]{8,}\\.[a-z0-9_-]{8,}",
|
|
17
|
-
"(?:api.?key|secret|token|passw(?:or)?d|bearer|authorization)\\s*[:=]?\\s*\\S+",
|
|
18
|
-
].join("|");
|
|
19
|
-
export const DEFAULT_ERROR_PATTERN = "error|exception|fail(?:ed|ure)?|fatal|crash|denied|refused|not found|cannot|can't|unable|invalid|" +
|
|
20
|
-
"timed? ?out|traceback|panic|unhandled|warning";
|
|
21
|
-
export const REPORT_FILES = {
|
|
22
|
-
markdown: "report.md",
|
|
23
|
-
json: "report.json",
|
|
24
|
-
clip: "clip.mp4",
|
|
25
|
-
contactSheet: "contact-sheet.png",
|
|
26
|
-
gif: (format) => `repro.${format}`,
|
|
27
|
-
};
|
|
28
|
-
const r3 = (n) => Math.round(n * 1000) / 1000;
|
|
29
|
-
export function clipWindow(durationSec, opts = {}) {
|
|
30
|
-
if (!(durationSec > 0))
|
|
31
|
-
throw new ScreencastError("Could not read the recording's duration.");
|
|
32
|
-
const end = Math.min(opts.end ?? durationSec, durationSec);
|
|
33
|
-
const clipSec = opts.clipSec ?? DEFAULT_CLIP_SEC;
|
|
34
|
-
const start = opts.start ?? Math.max(0, end - clipSec);
|
|
35
|
-
if (start >= durationSec) {
|
|
36
|
-
throw new ScreencastError(`start ${start}s is past the end of the ${r3(durationSec)}s recording.`);
|
|
37
|
-
}
|
|
38
|
-
if (!(end > start))
|
|
39
|
-
throw new ScreencastError("end must be after start.");
|
|
40
|
-
if (end - start > MAX_CLIP_SEC) {
|
|
41
|
-
throw new ScreencastError(`The clip would be ${r3(end - start)}s; at most ${MAX_CLIP_SEC}s. Narrow start/end.`);
|
|
42
|
-
}
|
|
43
|
-
return { start: r3(start), end: r3(end) };
|
|
44
|
-
}
|
|
45
|
-
export { reconstructSteps } from "./steps.js";
|
|
46
|
-
function mostlyOverlap(a, b) {
|
|
47
|
-
const w = Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x);
|
|
48
|
-
const h = Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y);
|
|
49
|
-
if (w <= 0 || h <= 0)
|
|
50
|
-
return false;
|
|
51
|
-
return w * h >= 0.5 * Math.min(a.width * a.height, b.width * b.height);
|
|
52
|
-
}
|
|
53
|
-
export function mergeRedactions(regions) {
|
|
54
|
-
const out = [];
|
|
55
|
-
for (const r of [...regions].sort((a, b) => a.start - b.start)) {
|
|
56
|
-
const into = out.find((o) => r.start <= o.end && mostlyOverlap(o, r));
|
|
57
|
-
if (!into) {
|
|
58
|
-
out.push({ ...r });
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
const x = Math.min(into.x, r.x);
|
|
62
|
-
const y = Math.min(into.y, r.y);
|
|
63
|
-
into.width = Math.max(into.x + into.width, r.x + r.width) - x;
|
|
64
|
-
into.height = Math.max(into.y + into.height, r.y + r.height) - y;
|
|
65
|
-
into.x = x;
|
|
66
|
-
into.y = y;
|
|
67
|
-
into.start = Math.min(into.start, r.start);
|
|
68
|
-
into.end = Math.max(into.end, r.end);
|
|
69
|
-
}
|
|
70
|
-
return out;
|
|
71
|
-
}
|
|
72
|
-
export const MASK = "[REDACTED]";
|
|
73
|
-
export function maskSecrets(texts, pattern) {
|
|
74
|
-
if (texts.length === 0)
|
|
75
|
-
return [];
|
|
76
|
-
const ranges = regexRanges(texts, pattern);
|
|
77
|
-
return texts.map((text, i) => {
|
|
78
|
-
const spans = [...(ranges[i] ?? [])].sort((a, b) => a[0] - b[0]);
|
|
79
|
-
let out = "";
|
|
80
|
-
let at = 0;
|
|
81
|
-
for (const [s, e] of spans) {
|
|
82
|
-
if (e <= at)
|
|
83
|
-
continue;
|
|
84
|
-
out += text.slice(at, Math.max(at, s)) + (s >= at ? MASK : "");
|
|
85
|
-
at = e;
|
|
86
|
-
}
|
|
87
|
-
return out + text.slice(at);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
export function errorFindings(frames, errorPattern, secretPattern) {
|
|
91
|
-
const found = new Map();
|
|
92
|
-
for (const frame of frames) {
|
|
93
|
-
const hitLines = new Set(findMatches(frame.lines, errorPattern, true).map((m) => m.line));
|
|
94
|
-
for (const line of hitLines) {
|
|
95
|
-
const key = normalizeForMatch(line);
|
|
96
|
-
const seen = found.get(key);
|
|
97
|
-
if (seen)
|
|
98
|
-
seen.lastSeen = frame.t;
|
|
99
|
-
else
|
|
100
|
-
found.set(key, { text: line, firstSeen: frame.t, lastSeen: frame.t });
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
const lastT = frames.at(-1)?.t;
|
|
104
|
-
const list = [...found.values()].sort((a, b) => Number(b.lastSeen === lastT) - Number(a.lastSeen === lastT) || a.firstSeen - b.firstSeen).slice(0, MAX_ERROR_LINES);
|
|
105
|
-
if (!secretPattern)
|
|
106
|
-
return list;
|
|
107
|
-
const masked = maskSecrets(list.map((f) => f.text), secretPattern);
|
|
108
|
-
return list.map((f, i) => ({ ...f, text: masked[i] ?? f.text }));
|
|
109
|
-
}
|
|
110
|
-
const code = (s) => `\`${s.replace(/`/g, "'").replace(/\s+/g, " ").trim()}\``;
|
|
111
|
-
const cell = (s) => s.replace(/\|/g, "\\|").replace(/\s*\n\s*/g, " ");
|
|
112
|
-
export function buildReportMarkdown(r) {
|
|
113
|
-
const out = [`# ${r.title.replace(/\s*\n\s*/g, " ")}`, ""];
|
|
114
|
-
const span = `${formatTimecode(r.clip.start)}-${formatTimecode(r.clip.end)}`;
|
|
115
|
-
out.push(`Recorded repro: ${r.clip.width}x${r.clip.height}, clip ${span} of a ${formatTimecode(r.clip.recordingDurationSec)} recording.`, "");
|
|
116
|
-
if (r.actual || r.expected) {
|
|
117
|
-
if (r.actual)
|
|
118
|
-
out.push("**Actual:** " + r.actual.trim(), "");
|
|
119
|
-
if (r.expected)
|
|
120
|
-
out.push("**Expected:** " + r.expected.trim(), "");
|
|
121
|
-
}
|
|
122
|
-
out.push("## Steps to reproduce", "");
|
|
123
|
-
if (r.steps.length === 0) {
|
|
124
|
-
out.push(`_${r.stepsNote ?? "No input events in the recording."} Add the steps by hand._`, "");
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
out.push("From the recording's input event log; times are on the recording's clock, positions in video pixels.", "");
|
|
128
|
-
r.steps.forEach((s, i) => out.push(`${i + 1}. \`${formatTimecode(s.t)}\` ${s.text}`));
|
|
129
|
-
if (r.stepsOmitted)
|
|
130
|
-
out.push("", `_${r.stepsOmitted} more steps not shown (see report.json)._`);
|
|
131
|
-
out.push("");
|
|
132
|
-
}
|
|
133
|
-
out.push("## Error text on screen", "");
|
|
134
|
-
if (r.ocr !== "read") {
|
|
135
|
-
out.push("_Not read: Windows OCR is unavailable here._", "");
|
|
136
|
-
}
|
|
137
|
-
else if (r.errors.length === 0) {
|
|
138
|
-
out.push("_None found by OCR in the clip._", "");
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
out.push("Read by OCR (best-effort, may contain misreads); times from the clip start.", "");
|
|
142
|
-
for (const e of r.errors) {
|
|
143
|
-
const when = e.firstSeen === e.lastSeen ? formatTimecode(e.firstSeen) : `${formatTimecode(e.firstSeen)}-${formatTimecode(e.lastSeen)}`;
|
|
144
|
-
out.push(`- \`${when}\` ${code(e.text)}`);
|
|
145
|
-
}
|
|
146
|
-
out.push("");
|
|
147
|
-
}
|
|
148
|
-
out.push("## Recording", "");
|
|
149
|
-
if (r.files.gif) {
|
|
150
|
-
out.push("<!-- GitHub does not upload local files from --body-file: drag the GIF and clip into the issue, " +
|
|
151
|
-
"or replace these links with the uploaded URLs. -->", ``, "");
|
|
152
|
-
}
|
|
153
|
-
out.push(`- Clip: [${r.files.clip}](${r.files.clip}) (${r3(r.clip.end - r.clip.start)} s)`);
|
|
154
|
-
if (r.files.gif && r.gif) {
|
|
155
|
-
const mb = (r.gif.sizeBytes / 1_000_000).toFixed(1);
|
|
156
|
-
out.push(`- ${r.gif.format === "gif" ? "GIF" : "WebP"}: [${r.files.gif}](${r.files.gif}) (${mb} MB${r.gif.withinBudget ? "" : ", over the size budget"})`);
|
|
157
|
-
}
|
|
158
|
-
if (r.files.contactSheet)
|
|
159
|
-
out.push(`- Contact sheet: [${r.files.contactSheet}](${r.files.contactSheet})`);
|
|
160
|
-
out.push("");
|
|
161
|
-
out.push("## Environment", "", "| | |", "|---|---|");
|
|
162
|
-
for (const [k, v] of r.environment)
|
|
163
|
-
out.push(`| ${cell(k)} | ${cell(v)} |`);
|
|
164
|
-
out.push("");
|
|
165
|
-
const red = r.redaction;
|
|
166
|
-
const boxes = red.found + red.manual;
|
|
167
|
-
out.push("<sub>", red.scanned
|
|
168
|
-
? `Secret scan: OCR every ${red.everySec} s over ${red.framesScanned} frames; ${boxes} region${boxes === 1 ? "" : "s"} boxed out of the media. ` +
|
|
169
|
-
"OCR is best-effort: review the clip before posting."
|
|
170
|
-
: `Not scanned for secrets${red.manual > 0 ? ` (${red.manual} region${red.manual === 1 ? "" : "s"} boxed out by hand)` : ""}: review the clip before posting.`, `Generated by screencast-mcp bug_report, ${r.createdAt}.`, "</sub>", "");
|
|
171
|
-
return out.join("\n");
|
|
172
|
-
}
|
package/dist/utils/callout.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { ScreencastError } from "./errors.js";
|
|
2
|
-
import { escapeFilterPath } from "./fonts.js";
|
|
3
|
-
import { enableExpr } from "./media.js";
|
|
4
|
-
import { resolveQuality } from "./targets.js";
|
|
5
|
-
import { validateColor } from "./validate.js";
|
|
6
|
-
import { stillOutput } from "./paths.js";
|
|
7
|
-
const nonNeg = (v, label) => {
|
|
8
|
-
if (!Number.isFinite(v) || v < 0)
|
|
9
|
-
throw new ScreencastError(`${label} must be a non-negative number.`);
|
|
10
|
-
return Math.round(v);
|
|
11
|
-
};
|
|
12
|
-
function enable(c) {
|
|
13
|
-
const e = enableExpr(c.from, c.to);
|
|
14
|
-
return e ? `:enable='${e}'` : "";
|
|
15
|
-
}
|
|
16
|
-
export function arrowGeometry(a) {
|
|
17
|
-
const dx = a.x2 - a.x1;
|
|
18
|
-
const dy = a.y2 - a.y1;
|
|
19
|
-
const length = Math.round(Math.hypot(dx, dy));
|
|
20
|
-
const thickness = Math.max(2, Math.round(a.thickness ?? 8));
|
|
21
|
-
if (length < thickness * 3)
|
|
22
|
-
throw new ScreencastError("An arrow must be at least three times as long as it is thick.");
|
|
23
|
-
return { length, thickness, angle: Math.atan2(dy, dx), cx: (a.x1 + a.x2) / 2, cy: (a.y1 + a.y2) / 2 };
|
|
24
|
-
}
|
|
25
|
-
export function buildArrowImageArgs(a, output) {
|
|
26
|
-
const { length, thickness, angle } = arrowGeometry(a);
|
|
27
|
-
const color = validateColor(a.color ?? "red");
|
|
28
|
-
const head = thickness * 3;
|
|
29
|
-
const ang = angle.toFixed(6);
|
|
30
|
-
const alpha = `if(lt(X,W-H),if(lt(abs(Y-H/2),${thickness}/2),255,0),if(lt(abs(Y-H/2),(W-X)/2),255,0))`;
|
|
31
|
-
return [
|
|
32
|
-
"-y", "-v", "error",
|
|
33
|
-
"-f", "lavfi", "-i", `color=c=${color}:s=${length}x${head}`,
|
|
34
|
-
"-vf", `format=rgba,geq=r='r(X,Y)':g='g(X,Y)':b='b(X,Y)':a='${alpha}',rotate=a=${ang}:ow=rotw(${ang}):oh=roth(${ang}):c=none`,
|
|
35
|
-
"-frames:v", "1",
|
|
36
|
-
...stillOutput(output),
|
|
37
|
-
];
|
|
38
|
-
}
|
|
39
|
-
export function calloutSteps(items, assets, input, firstInput, tag) {
|
|
40
|
-
if (items.length === 0)
|
|
41
|
-
throw new ScreencastError("Give at least one callout.");
|
|
42
|
-
const extraInputs = [];
|
|
43
|
-
const steps = [];
|
|
44
|
-
let cur = input;
|
|
45
|
-
items.forEach((c, i) => {
|
|
46
|
-
const out = `[${tag}c${i}]`;
|
|
47
|
-
if (c.type === "box") {
|
|
48
|
-
const color = validateColor(c.color ?? "red");
|
|
49
|
-
const t = c.fill ? "fill" : String(Math.max(1, Math.round(c.thickness ?? 4)));
|
|
50
|
-
steps.push(`${cur}drawbox=x=${nonNeg(c.x, "x")}:y=${nonNeg(c.y, "y")}:w=${nonNeg(c.width, "width")}:h=${nonNeg(c.height, "height")}` +
|
|
51
|
-
`:color=${color}:t=${t}${enable(c)}${out}`);
|
|
52
|
-
}
|
|
53
|
-
else if (c.type === "text") {
|
|
54
|
-
const file = assets.textFiles[i];
|
|
55
|
-
if (!file)
|
|
56
|
-
throw new ScreencastError("Internal: missing text file for a text callout.");
|
|
57
|
-
const color = validateColor(c.color ?? "white");
|
|
58
|
-
const size = Math.max(8, Math.round(c.size ?? 32));
|
|
59
|
-
const panel = c.background === false ? "" : `:box=1:boxcolor=black@0.6:boxborderw=${Math.round(size / 3)}`;
|
|
60
|
-
steps.push(`${cur}drawtext=fontfile=${escapeFilterPath(assets.fontFiles?.[i] ?? assets.fontFile)}:textfile=${escapeFilterPath(file)}:expansion=none` +
|
|
61
|
-
`:x=${nonNeg(c.x, "x")}:y=${nonNeg(c.y, "y")}:fontsize=${size}:fontcolor=${color}${panel}${enable(c)}${out}`);
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
const file = assets.arrowFiles[i];
|
|
65
|
-
if (!file)
|
|
66
|
-
throw new ScreencastError("Internal: missing image for an arrow callout.");
|
|
67
|
-
const { cx, cy } = arrowGeometry(c);
|
|
68
|
-
const n = firstInput + extraInputs.length / 4;
|
|
69
|
-
extraInputs.push("-loop", "1", "-i", file);
|
|
70
|
-
steps.push(`${cur}[${n}:v]overlay=x=${cx.toFixed(1)}-w/2:y=${cy.toFixed(1)}-h/2:shortest=1${enable(c)}${out}`);
|
|
71
|
-
}
|
|
72
|
-
cur = out;
|
|
73
|
-
});
|
|
74
|
-
return { steps, out: cur, extraInputs };
|
|
75
|
-
}
|
|
76
|
-
export function buildCalloutArgs(input, output, items, assets, quality = "standard", still = false) {
|
|
77
|
-
const drawn = still ? items.map(({ from: _f, to: _t, ...c }) => c) : items;
|
|
78
|
-
const { steps, out, extraInputs } = calloutSteps(drawn, assets, "[0:v]", 1, "");
|
|
79
|
-
if (still) {
|
|
80
|
-
return ["-y", "-i", input, ...extraInputs, "-filter_complex", steps.join(";"), "-map", out, "-frames:v", "1", ...stillOutput(output)];
|
|
81
|
-
}
|
|
82
|
-
return [
|
|
83
|
-
"-y", "-i", input, ...extraInputs,
|
|
84
|
-
"-filter_complex", steps.join(";"),
|
|
85
|
-
"-map", out, "-map", "0:a?",
|
|
86
|
-
...resolveQuality(quality),
|
|
87
|
-
"-c:a", "copy",
|
|
88
|
-
output,
|
|
89
|
-
];
|
|
90
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import { writeFileSync } from "node:fs";
|
|
3
|
-
import { runFfmpeg } from "./ffmpeg.js";
|
|
4
|
-
import { buildArrowImageArgs } from "./callout.js";
|
|
5
|
-
import { bundledFontPath, resolveTextFont } from "./fonts.js";
|
|
6
|
-
export function calloutFonts(items, fontFile) {
|
|
7
|
-
const out = { fontFiles: [], fallbackFonts: [], warnings: [] };
|
|
8
|
-
items.forEach((c, i) => {
|
|
9
|
-
if (c.type !== "text") {
|
|
10
|
-
out.fontFiles.push(null);
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
const font = resolveTextFont(c.text, { weight: "bold", fontFile });
|
|
14
|
-
out.fontFiles.push(font.fontFile);
|
|
15
|
-
if (font.fallback)
|
|
16
|
-
out.fallbackFonts.push({ item: i, fontFile: font.fontFile });
|
|
17
|
-
if (font.warning)
|
|
18
|
-
out.warnings.push(`Item ${i}: ${font.warning}`);
|
|
19
|
-
});
|
|
20
|
-
return out;
|
|
21
|
-
}
|
|
22
|
-
export async function prepareCalloutAssets(items, workDir, tag = "", fontFile) {
|
|
23
|
-
const fonts = calloutFonts(items, fontFile);
|
|
24
|
-
const textFiles = items.map((c, i) => {
|
|
25
|
-
if (c.type !== "text")
|
|
26
|
-
return null;
|
|
27
|
-
const f = join(workDir, `${tag}text_${i}.txt`);
|
|
28
|
-
writeFileSync(f, c.text);
|
|
29
|
-
return f;
|
|
30
|
-
});
|
|
31
|
-
const arrowFiles = [];
|
|
32
|
-
for (const [i, c] of items.entries()) {
|
|
33
|
-
if (c.type !== "arrow") {
|
|
34
|
-
arrowFiles.push(null);
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
const f = join(workDir, `${tag}arrow_${i}.png`);
|
|
38
|
-
await runFfmpeg(buildArrowImageArgs(c, f), 30_000);
|
|
39
|
-
arrowFiles.push(f);
|
|
40
|
-
}
|
|
41
|
-
return { fontFile: bundledFontPath("bold"), textFiles, arrowFiles, ...fonts };
|
|
42
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from "node:child_process";
|
|
2
|
-
import { isAbsolute } from "node:path";
|
|
3
|
-
import { runPowerShell, psTimeoutMs } from "./monitors.js";
|
|
4
|
-
import { errorMessage } from "./errors.js";
|
|
5
|
-
export const FFMPEG_FEATURE_MAJOR = 8;
|
|
6
|
-
export function parseFfmpegVersion(text) {
|
|
7
|
-
const version = /^ff(?:mpeg|probe) version (\S+)/m.exec(text)?.[1] ?? null;
|
|
8
|
-
const release = version ? /^n?(\d+)\.\d+/.exec(version) : null;
|
|
9
|
-
if (release)
|
|
10
|
-
return { version, major: Number(release[1]), inferred: false };
|
|
11
|
-
const avutil = /^\s*libavutil\s+(\d+)\./m.exec(text);
|
|
12
|
-
if (avutil && Number(avutil[1]) >= 56)
|
|
13
|
-
return { version, major: Number(avutil[1]) - 52, inferred: true };
|
|
14
|
-
return { version, major: null, inferred: false };
|
|
15
|
-
}
|
|
16
|
-
export function parseDevices(text) {
|
|
17
|
-
const out = new Set();
|
|
18
|
-
const body = text.split(/^\s*---\s*$/m).slice(1).join("\n") || text;
|
|
19
|
-
for (const line of body.split(/\r?\n/)) {
|
|
20
|
-
const m = /^\s{0,2}[D ][E ]\s?[d ]?\s+([a-z0-9_,]+)\s/i.exec(line);
|
|
21
|
-
if (m?.[1])
|
|
22
|
-
for (const name of m[1].split(","))
|
|
23
|
-
out.add(name);
|
|
24
|
-
}
|
|
25
|
-
return [...out];
|
|
26
|
-
}
|
|
27
|
-
function run(bin, args) {
|
|
28
|
-
try {
|
|
29
|
-
const res = spawnSync(bin, args, { encoding: "utf8", windowsHide: true, timeout: 10_000 });
|
|
30
|
-
if (res.status !== 0)
|
|
31
|
-
return null;
|
|
32
|
-
return `${res.stdout ?? ""}${res.stderr ?? ""}`;
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
export function versionText(bin) {
|
|
39
|
-
return run(bin, ["-version"]);
|
|
40
|
-
}
|
|
41
|
-
export function devicesText(ffmpeg) {
|
|
42
|
-
return run(ffmpeg, ["-hide_banner", "-devices"]);
|
|
43
|
-
}
|
|
44
|
-
export function locate(bin) {
|
|
45
|
-
if (isAbsolute(bin))
|
|
46
|
-
return bin;
|
|
47
|
-
const out = run(process.platform === "win32" ? "where" : "which", [bin]);
|
|
48
|
-
return out?.split(/\r?\n/).map((l) => l.trim()).find((l) => l.length > 0) ?? null;
|
|
49
|
-
}
|
|
50
|
-
const PS_OCR_STATUS = `
|
|
51
|
-
$ErrorActionPreference = 'Stop'
|
|
52
|
-
$null = [Windows.Media.Ocr.OcrEngine, Windows.Foundation, ContentType = WindowsRuntime]
|
|
53
|
-
$e = [Windows.Media.Ocr.OcrEngine]::TryCreateFromUserProfileLanguages()
|
|
54
|
-
[pscustomobject]@{ available = ($null -ne $e); language = $(if ($e) { $e.RecognizerLanguage.LanguageTag } else { $null }); languages = @([Windows.Media.Ocr.OcrEngine]::AvailableRecognizerLanguages | ForEach-Object { $_.LanguageTag }) } | ConvertTo-Json -Compress
|
|
55
|
-
`;
|
|
56
|
-
export async function ocrStatus() {
|
|
57
|
-
if (process.platform !== "win32") {
|
|
58
|
-
return { available: false, language: null, languages: [], error: "The Windows OCR engine is available on Windows only." };
|
|
59
|
-
}
|
|
60
|
-
try {
|
|
61
|
-
const raw = JSON.parse(await runPowerShell(PS_OCR_STATUS, "OCR languages", { timeoutMs: psTimeoutMs(15_000) }));
|
|
62
|
-
const languages = Array.isArray(raw.languages) ? raw.languages : raw.languages ? [raw.languages] : [];
|
|
63
|
-
return { available: raw.available === true, language: raw.language ?? null, languages };
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
return { available: false, language: null, languages: [], error: errorMessage(err) };
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
export const ENV_SETTINGS = [
|
|
70
|
-
"SCREENCAST_HOME",
|
|
71
|
-
"SCREENCAST_ALLOWED_DIRS",
|
|
72
|
-
"FFMPEG_PATH",
|
|
73
|
-
"FFPROBE_PATH",
|
|
74
|
-
"SCREENCAST_WHISPER_MODEL",
|
|
75
|
-
"SCREENCAST_MAX_RECORDING_SEC",
|
|
76
|
-
"SCREENCAST_JOB_TIMEOUT_MS",
|
|
77
|
-
"SCREENCAST_PS_TIMEOUT_MS",
|
|
78
|
-
"SCREENCAST_RETENTION_DAYS",
|
|
79
|
-
"SCREENCAST_CONFIRM_CAPTURE",
|
|
80
|
-
"SCREENCAST_TOOLSETS",
|
|
81
|
-
];
|
|
82
|
-
export function envSettings(env = process.env) {
|
|
83
|
-
return Object.fromEntries(ENV_SETTINGS.map((name) => {
|
|
84
|
-
const value = env[name];
|
|
85
|
-
return [name, value && value.trim().length > 0 ? value : null];
|
|
86
|
-
}));
|
|
87
|
-
}
|
|
88
|
-
export const KEY_FILTERS = [
|
|
89
|
-
{ filter: "whisper", tools: "transcribe", why: `FFmpeg ${FFMPEG_FEATURE_MAJOR}+ built with whisper.cpp` },
|
|
90
|
-
{ filter: "gfxcapture", tools: 'backend: "wgc" (screenshot, start_recording, find_text)', why: `FFmpeg ${FFMPEG_FEATURE_MAJOR}+ on Windows` },
|
|
91
|
-
{ filter: "subtitles", tools: "burn_subtitles", why: "libass" },
|
|
92
|
-
{ filter: "drawtext", tools: "title_card, callout, contact_sheet labels, produce", why: "libfreetype" },
|
|
93
|
-
{ filter: "afftdn", tools: "denoise", why: "a standard build" },
|
|
94
|
-
{ filter: "loudnorm", tools: "normalize_audio", why: "a standard build" },
|
|
95
|
-
{ filter: "xfade", tools: "xfade_transition, assemble_highlights", why: "FFmpeg 4.3+" },
|
|
96
|
-
];
|