@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.
Files changed (344) hide show
  1. package/README.md +95 -17
  2. package/assets/icon.png +0 -0
  3. package/assets/ui/player.html +47 -302
  4. package/assets/ui/player.js +402 -0
  5. package/dist/context.js +0 -5
  6. package/dist/index.js +17 -21
  7. package/dist/prompts.js +18 -8
  8. package/dist/resources.js +2 -14
  9. package/dist/server.js +49 -11
  10. package/dist/tools/addMarker.js +89 -0
  11. package/dist/tools/assembleHighlights.js +12 -7
  12. package/dist/tools/backdrop.js +89 -0
  13. package/dist/tools/bugReport.js +266 -0
  14. package/dist/tools/burnSubtitles.js +12 -6
  15. package/dist/tools/callout.js +32 -16
  16. package/dist/tools/chapters.js +156 -0
  17. package/dist/tools/clip.js +12 -9
  18. package/dist/tools/compress.js +10 -5
  19. package/dist/tools/concat.js +16 -15
  20. package/dist/tools/contactSheet.js +39 -33
  21. package/dist/tools/convert.js +12 -6
  22. package/dist/tools/crop.js +12 -7
  23. package/dist/tools/cutIdle.js +15 -9
  24. package/dist/tools/denoise.js +12 -6
  25. package/dist/tools/doctor.js +133 -0
  26. package/dist/tools/exportGif.js +14 -10
  27. package/dist/tools/exportPreset.js +11 -8
  28. package/dist/tools/extractAudio.js +10 -8
  29. package/dist/tools/findText.js +52 -98
  30. package/dist/tools/getMediaInfo.js +17 -3
  31. package/dist/tools/getSession.js +15 -3
  32. package/dist/tools/keystrokeOverlay.js +131 -0
  33. package/dist/tools/listAudioDevices.js +14 -7
  34. package/dist/tools/listSessions.js +13 -3
  35. package/dist/tools/listTargets.js +76 -0
  36. package/dist/tools/musicBed.js +14 -10
  37. package/dist/tools/normalizeAudio.js +12 -8
  38. package/dist/tools/overlay.js +16 -12
  39. package/dist/tools/pipeline.js +86 -25
  40. package/dist/tools/readEvents.js +21 -12
  41. package/dist/tools/redactRegion.js +19 -17
  42. package/dist/tools/reframe.js +9 -5
  43. package/dist/tools/reviewRecording.js +75 -22
  44. package/dist/tools/sampleFrames.js +33 -40
  45. package/dist/tools/saveReplay.js +90 -0
  46. package/dist/tools/scale.js +9 -3
  47. package/dist/tools/screenDiff.js +23 -17
  48. package/dist/tools/screenshot.js +21 -17
  49. package/dist/tools/speed.js +15 -4
  50. package/dist/tools/startRecording.js +96 -59
  51. package/dist/tools/stopRecording.js +35 -10
  52. package/dist/tools/titleCard.js +19 -11
  53. package/dist/tools/transcribe.js +13 -7
  54. package/dist/tools/trim.js +11 -10
  55. package/dist/tools/waitForChange.js +37 -22
  56. package/dist/tools/xfadeTransition.js +12 -8
  57. package/dist/tools/zoom.js +26 -29
  58. package/dist/utils/anim.js +1 -21
  59. package/dist/utils/animExport.js +5 -10
  60. package/dist/utils/audio.js +4 -33
  61. package/dist/utils/audioDevices.js +1 -48
  62. package/dist/utils/backdrop.js +151 -0
  63. package/dist/utils/bugReport.js +246 -0
  64. package/dist/utils/callout.js +1 -19
  65. package/dist/utils/calloutAssets.js +21 -11
  66. package/dist/utils/capabilities.js +95 -0
  67. package/dist/utils/captions.js +9 -26
  68. package/dist/utils/chapters.js +222 -0
  69. package/dist/utils/consent.js +29 -0
  70. package/dist/utils/diff.js +0 -46
  71. package/dist/utils/errors.js +5 -13
  72. package/dist/utils/events.js +21 -77
  73. package/dist/utils/expr.js +11 -0
  74. package/dist/utils/ffmpeg.js +119 -48
  75. package/dist/utils/fontCoverage.js +177 -0
  76. package/dist/utils/fonts.js +139 -23
  77. package/dist/utils/idle.js +12 -24
  78. package/dist/utils/images.js +0 -17
  79. package/dist/utils/jobs.js +42 -41
  80. package/dist/utils/keystrokes.js +170 -0
  81. package/dist/utils/lifecycle.js +11 -31
  82. package/dist/utils/logging.js +75 -0
  83. package/dist/utils/media.js +16 -124
  84. package/dist/utils/monitors.js +7 -43
  85. package/dist/utils/ocr.js +53 -71
  86. package/dist/utils/ocrScan.js +77 -0
  87. package/dist/utils/paths.js +68 -31
  88. package/dist/utils/pipeline.js +39 -25
  89. package/dist/utils/player.js +50 -27
  90. package/dist/utils/produce.js +6 -66
  91. package/dist/utils/replay.js +278 -0
  92. package/dist/utils/resolveTarget.js +0 -19
  93. package/dist/utils/retention.js +1 -15
  94. package/dist/utils/roots.js +42 -0
  95. package/dist/utils/sessions.js +195 -160
  96. package/dist/utils/sheet.js +0 -19
  97. package/dist/utils/still.js +0 -15
  98. package/dist/utils/targetList.js +63 -0
  99. package/dist/utils/targets.js +5 -70
  100. package/dist/utils/toolSpec.js +25 -0
  101. package/dist/utils/toolsets.js +122 -0
  102. package/dist/utils/validate.js +0 -22
  103. package/dist/utils/wgc.js +0 -46
  104. package/dist/utils/windows.js +5 -50
  105. package/dist/utils/zoom.js +55 -85
  106. package/dist/wgcRecorder.js +1 -30
  107. package/package.json +7 -3
  108. package/dist/context.d.ts +0 -9
  109. package/dist/context.d.ts.map +0 -1
  110. package/dist/context.js.map +0 -1
  111. package/dist/index.d.ts +0 -3
  112. package/dist/index.d.ts.map +0 -1
  113. package/dist/index.js.map +0 -1
  114. package/dist/prompts.d.ts +0 -10
  115. package/dist/prompts.d.ts.map +0 -1
  116. package/dist/prompts.js.map +0 -1
  117. package/dist/resources.d.ts +0 -3
  118. package/dist/resources.d.ts.map +0 -1
  119. package/dist/resources.js.map +0 -1
  120. package/dist/server.d.ts +0 -3
  121. package/dist/server.d.ts.map +0 -1
  122. package/dist/server.js.map +0 -1
  123. package/dist/tools/assembleHighlights.d.ts +0 -3
  124. package/dist/tools/assembleHighlights.d.ts.map +0 -1
  125. package/dist/tools/assembleHighlights.js.map +0 -1
  126. package/dist/tools/burnSubtitles.d.ts +0 -3
  127. package/dist/tools/burnSubtitles.d.ts.map +0 -1
  128. package/dist/tools/burnSubtitles.js.map +0 -1
  129. package/dist/tools/callout.d.ts +0 -37
  130. package/dist/tools/callout.d.ts.map +0 -1
  131. package/dist/tools/callout.js.map +0 -1
  132. package/dist/tools/clip.d.ts +0 -3
  133. package/dist/tools/clip.d.ts.map +0 -1
  134. package/dist/tools/clip.js.map +0 -1
  135. package/dist/tools/compress.d.ts +0 -3
  136. package/dist/tools/compress.d.ts.map +0 -1
  137. package/dist/tools/compress.js.map +0 -1
  138. package/dist/tools/concat.d.ts +0 -3
  139. package/dist/tools/concat.d.ts.map +0 -1
  140. package/dist/tools/concat.js.map +0 -1
  141. package/dist/tools/contactSheet.d.ts +0 -3
  142. package/dist/tools/contactSheet.d.ts.map +0 -1
  143. package/dist/tools/contactSheet.js.map +0 -1
  144. package/dist/tools/convert.d.ts +0 -3
  145. package/dist/tools/convert.d.ts.map +0 -1
  146. package/dist/tools/convert.js.map +0 -1
  147. package/dist/tools/crop.d.ts +0 -3
  148. package/dist/tools/crop.d.ts.map +0 -1
  149. package/dist/tools/crop.js.map +0 -1
  150. package/dist/tools/cutIdle.d.ts +0 -3
  151. package/dist/tools/cutIdle.d.ts.map +0 -1
  152. package/dist/tools/cutIdle.js.map +0 -1
  153. package/dist/tools/denoise.d.ts +0 -3
  154. package/dist/tools/denoise.d.ts.map +0 -1
  155. package/dist/tools/denoise.js.map +0 -1
  156. package/dist/tools/exportGif.d.ts +0 -3
  157. package/dist/tools/exportGif.d.ts.map +0 -1
  158. package/dist/tools/exportGif.js.map +0 -1
  159. package/dist/tools/exportPreset.d.ts +0 -3
  160. package/dist/tools/exportPreset.d.ts.map +0 -1
  161. package/dist/tools/exportPreset.js.map +0 -1
  162. package/dist/tools/extractAudio.d.ts +0 -3
  163. package/dist/tools/extractAudio.d.ts.map +0 -1
  164. package/dist/tools/extractAudio.js.map +0 -1
  165. package/dist/tools/findText.d.ts +0 -6
  166. package/dist/tools/findText.d.ts.map +0 -1
  167. package/dist/tools/findText.js.map +0 -1
  168. package/dist/tools/getMediaInfo.d.ts +0 -3
  169. package/dist/tools/getMediaInfo.d.ts.map +0 -1
  170. package/dist/tools/getMediaInfo.js.map +0 -1
  171. package/dist/tools/getSession.d.ts +0 -3
  172. package/dist/tools/getSession.d.ts.map +0 -1
  173. package/dist/tools/getSession.js.map +0 -1
  174. package/dist/tools/listAudioDevices.d.ts +0 -3
  175. package/dist/tools/listAudioDevices.d.ts.map +0 -1
  176. package/dist/tools/listAudioDevices.js.map +0 -1
  177. package/dist/tools/listSessions.d.ts +0 -3
  178. package/dist/tools/listSessions.d.ts.map +0 -1
  179. package/dist/tools/listSessions.js.map +0 -1
  180. package/dist/tools/musicBed.d.ts +0 -3
  181. package/dist/tools/musicBed.d.ts.map +0 -1
  182. package/dist/tools/musicBed.js.map +0 -1
  183. package/dist/tools/normalizeAudio.d.ts +0 -3
  184. package/dist/tools/normalizeAudio.d.ts.map +0 -1
  185. package/dist/tools/normalizeAudio.js.map +0 -1
  186. package/dist/tools/overlay.d.ts +0 -3
  187. package/dist/tools/overlay.d.ts.map +0 -1
  188. package/dist/tools/overlay.js.map +0 -1
  189. package/dist/tools/pipeline.d.ts +0 -3
  190. package/dist/tools/pipeline.d.ts.map +0 -1
  191. package/dist/tools/pipeline.js.map +0 -1
  192. package/dist/tools/readEvents.d.ts +0 -6
  193. package/dist/tools/readEvents.d.ts.map +0 -1
  194. package/dist/tools/readEvents.js.map +0 -1
  195. package/dist/tools/redactRegion.d.ts +0 -13
  196. package/dist/tools/redactRegion.d.ts.map +0 -1
  197. package/dist/tools/redactRegion.js.map +0 -1
  198. package/dist/tools/reframe.d.ts +0 -3
  199. package/dist/tools/reframe.d.ts.map +0 -1
  200. package/dist/tools/reframe.js.map +0 -1
  201. package/dist/tools/reviewRecording.d.ts +0 -5
  202. package/dist/tools/reviewRecording.d.ts.map +0 -1
  203. package/dist/tools/reviewRecording.js.map +0 -1
  204. package/dist/tools/sampleFrames.d.ts +0 -3
  205. package/dist/tools/sampleFrames.d.ts.map +0 -1
  206. package/dist/tools/sampleFrames.js.map +0 -1
  207. package/dist/tools/scale.d.ts +0 -3
  208. package/dist/tools/scale.d.ts.map +0 -1
  209. package/dist/tools/scale.js.map +0 -1
  210. package/dist/tools/screenDiff.d.ts +0 -3
  211. package/dist/tools/screenDiff.d.ts.map +0 -1
  212. package/dist/tools/screenDiff.js.map +0 -1
  213. package/dist/tools/screenshot.d.ts +0 -3
  214. package/dist/tools/screenshot.d.ts.map +0 -1
  215. package/dist/tools/screenshot.js.map +0 -1
  216. package/dist/tools/speed.d.ts +0 -3
  217. package/dist/tools/speed.d.ts.map +0 -1
  218. package/dist/tools/speed.js.map +0 -1
  219. package/dist/tools/startRecording.d.ts +0 -3
  220. package/dist/tools/startRecording.d.ts.map +0 -1
  221. package/dist/tools/startRecording.js.map +0 -1
  222. package/dist/tools/stopRecording.d.ts +0 -3
  223. package/dist/tools/stopRecording.d.ts.map +0 -1
  224. package/dist/tools/stopRecording.js.map +0 -1
  225. package/dist/tools/titleCard.d.ts +0 -3
  226. package/dist/tools/titleCard.d.ts.map +0 -1
  227. package/dist/tools/titleCard.js.map +0 -1
  228. package/dist/tools/transcribe.d.ts +0 -3
  229. package/dist/tools/transcribe.d.ts.map +0 -1
  230. package/dist/tools/transcribe.js.map +0 -1
  231. package/dist/tools/trim.d.ts +0 -3
  232. package/dist/tools/trim.d.ts.map +0 -1
  233. package/dist/tools/trim.js.map +0 -1
  234. package/dist/tools/waitForChange.d.ts +0 -3
  235. package/dist/tools/waitForChange.d.ts.map +0 -1
  236. package/dist/tools/waitForChange.js.map +0 -1
  237. package/dist/tools/xfadeTransition.d.ts +0 -3
  238. package/dist/tools/xfadeTransition.d.ts.map +0 -1
  239. package/dist/tools/xfadeTransition.js.map +0 -1
  240. package/dist/tools/zoom.d.ts +0 -15
  241. package/dist/tools/zoom.d.ts.map +0 -1
  242. package/dist/tools/zoom.js.map +0 -1
  243. package/dist/utils/anim.d.ts +0 -33
  244. package/dist/utils/anim.d.ts.map +0 -1
  245. package/dist/utils/anim.js.map +0 -1
  246. package/dist/utils/animExport.d.ts +0 -27
  247. package/dist/utils/animExport.d.ts.map +0 -1
  248. package/dist/utils/animExport.js.map +0 -1
  249. package/dist/utils/audio.d.ts +0 -49
  250. package/dist/utils/audio.d.ts.map +0 -1
  251. package/dist/utils/audio.js.map +0 -1
  252. package/dist/utils/audioDevices.d.ts +0 -33
  253. package/dist/utils/audioDevices.d.ts.map +0 -1
  254. package/dist/utils/audioDevices.js.map +0 -1
  255. package/dist/utils/callout.d.ts +0 -72
  256. package/dist/utils/callout.d.ts.map +0 -1
  257. package/dist/utils/callout.js.map +0 -1
  258. package/dist/utils/calloutAssets.d.ts +0 -3
  259. package/dist/utils/calloutAssets.d.ts.map +0 -1
  260. package/dist/utils/calloutAssets.js.map +0 -1
  261. package/dist/utils/captions.d.ts +0 -26
  262. package/dist/utils/captions.d.ts.map +0 -1
  263. package/dist/utils/captions.js.map +0 -1
  264. package/dist/utils/diff.d.ts +0 -112
  265. package/dist/utils/diff.d.ts.map +0 -1
  266. package/dist/utils/diff.js.map +0 -1
  267. package/dist/utils/errors.d.ts +0 -33
  268. package/dist/utils/errors.d.ts.map +0 -1
  269. package/dist/utils/errors.js.map +0 -1
  270. package/dist/utils/events.d.ts +0 -143
  271. package/dist/utils/events.d.ts.map +0 -1
  272. package/dist/utils/events.js.map +0 -1
  273. package/dist/utils/ffmpeg.d.ts +0 -50
  274. package/dist/utils/ffmpeg.d.ts.map +0 -1
  275. package/dist/utils/ffmpeg.js.map +0 -1
  276. package/dist/utils/fonts.d.ts +0 -17
  277. package/dist/utils/fonts.d.ts.map +0 -1
  278. package/dist/utils/fonts.js.map +0 -1
  279. package/dist/utils/idle.d.ts +0 -23
  280. package/dist/utils/idle.d.ts.map +0 -1
  281. package/dist/utils/idle.js.map +0 -1
  282. package/dist/utils/images.d.ts +0 -21
  283. package/dist/utils/images.d.ts.map +0 -1
  284. package/dist/utils/images.js.map +0 -1
  285. package/dist/utils/jobs.d.ts +0 -44
  286. package/dist/utils/jobs.d.ts.map +0 -1
  287. package/dist/utils/jobs.js.map +0 -1
  288. package/dist/utils/lifecycle.d.ts +0 -29
  289. package/dist/utils/lifecycle.d.ts.map +0 -1
  290. package/dist/utils/lifecycle.js.map +0 -1
  291. package/dist/utils/media.d.ts +0 -272
  292. package/dist/utils/media.d.ts.map +0 -1
  293. package/dist/utils/media.js.map +0 -1
  294. package/dist/utils/monitors.d.ts +0 -47
  295. package/dist/utils/monitors.d.ts.map +0 -1
  296. package/dist/utils/monitors.js.map +0 -1
  297. package/dist/utils/ocr.d.ts +0 -50
  298. package/dist/utils/ocr.d.ts.map +0 -1
  299. package/dist/utils/ocr.js.map +0 -1
  300. package/dist/utils/paths.d.ts +0 -28
  301. package/dist/utils/paths.d.ts.map +0 -1
  302. package/dist/utils/paths.js.map +0 -1
  303. package/dist/utils/pipeline.d.ts +0 -69
  304. package/dist/utils/pipeline.d.ts.map +0 -1
  305. package/dist/utils/pipeline.js.map +0 -1
  306. package/dist/utils/player.d.ts +0 -30
  307. package/dist/utils/player.d.ts.map +0 -1
  308. package/dist/utils/player.js.map +0 -1
  309. package/dist/utils/produce.d.ts +0 -126
  310. package/dist/utils/produce.d.ts.map +0 -1
  311. package/dist/utils/produce.js.map +0 -1
  312. package/dist/utils/resolveTarget.d.ts +0 -32
  313. package/dist/utils/resolveTarget.d.ts.map +0 -1
  314. package/dist/utils/resolveTarget.js.map +0 -1
  315. package/dist/utils/retention.d.ts +0 -10
  316. package/dist/utils/retention.d.ts.map +0 -1
  317. package/dist/utils/retention.js.map +0 -1
  318. package/dist/utils/sessions.d.ts +0 -154
  319. package/dist/utils/sessions.d.ts.map +0 -1
  320. package/dist/utils/sessions.js.map +0 -1
  321. package/dist/utils/sheet.d.ts +0 -26
  322. package/dist/utils/sheet.d.ts.map +0 -1
  323. package/dist/utils/sheet.js.map +0 -1
  324. package/dist/utils/still.d.ts +0 -7
  325. package/dist/utils/still.d.ts.map +0 -1
  326. package/dist/utils/still.js.map +0 -1
  327. package/dist/utils/targets.d.ts +0 -113
  328. package/dist/utils/targets.d.ts.map +0 -1
  329. package/dist/utils/targets.js.map +0 -1
  330. package/dist/utils/validate.d.ts +0 -15
  331. package/dist/utils/validate.d.ts.map +0 -1
  332. package/dist/utils/validate.js.map +0 -1
  333. package/dist/utils/wgc.d.ts +0 -46
  334. package/dist/utils/wgc.d.ts.map +0 -1
  335. package/dist/utils/wgc.js.map +0 -1
  336. package/dist/utils/windows.d.ts +0 -94
  337. package/dist/utils/windows.d.ts.map +0 -1
  338. package/dist/utils/windows.js.map +0 -1
  339. package/dist/utils/zoom.d.ts +0 -95
  340. package/dist/utils/zoom.d.ts.map +0 -1
  341. package/dist/utils/zoom.js.map +0 -1
  342. package/dist/wgcRecorder.d.ts +0 -2
  343. package/dist/wgcRecorder.d.ts.map +0 -1
  344. package/dist/wgcRecorder.js.map +0 -1
@@ -0,0 +1,151 @@
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
+ }
@@ -0,0 +1,246 @@
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
+ const DOUBLE_CLICK_SEC = 0.5;
46
+ const DOUBLE_CLICK_PX = 6;
47
+ const SCROLL_JOIN_SEC = 1;
48
+ const GAP_WHY = {
49
+ input_not_seen: "input went to an elevated window or the lock screen, or the hook was removed",
50
+ helper_stalled: "the event logger paused",
51
+ helper_stopped: "the event logger stopped",
52
+ };
53
+ function clickText(button, double, e) {
54
+ const verb = double ? "double-click" : "click";
55
+ const which = button && button !== "left" ? `${button.charAt(0).toUpperCase()}${button.slice(1)} ${verb}` : `${verb.charAt(0).toUpperCase()}${verb.slice(1)}`;
56
+ return e.inFrame ? `${which} at (${e.x}, ${e.y})` : `${which} outside the recorded area`;
57
+ }
58
+ export function reconstructSteps(events) {
59
+ const steps = [];
60
+ const sorted = [...events].sort((a, b) => a.t - b.t);
61
+ let lastDown = null;
62
+ let scroll = null;
63
+ const scrollText = (axis, notches) => {
64
+ const dir = axis === "vertical" ? (notches >= 0 ? "up" : "down") : notches >= 0 ? "right" : "left";
65
+ const n = Math.abs(notches);
66
+ return `Scroll ${dir} ${n} notch${n === 1 ? "" : "es"}`;
67
+ };
68
+ for (const e of sorted) {
69
+ if (e.type === "move" || e.type === "up")
70
+ continue;
71
+ if (e.type !== "wheel")
72
+ scroll = null;
73
+ if (e.type === "down") {
74
+ const prev = lastDown;
75
+ if (prev &&
76
+ prev.e.button === e.button &&
77
+ e.t - prev.e.t <= DOUBLE_CLICK_SEC &&
78
+ Math.abs(e.x - prev.e.x) <= DOUBLE_CLICK_PX &&
79
+ Math.abs(e.y - prev.e.y) <= DOUBLE_CLICK_PX &&
80
+ prev.step.action === "click" &&
81
+ steps.at(-1) === prev.step) {
82
+ prev.step.action = "double_click";
83
+ prev.step.text = clickText(e.button, true, prev.e);
84
+ lastDown = null;
85
+ continue;
86
+ }
87
+ const step = { t: e.t, action: "click", text: clickText(e.button, false, e), x: e.x, y: e.y };
88
+ steps.push(step);
89
+ lastDown = { e, step };
90
+ continue;
91
+ }
92
+ lastDown = null;
93
+ if (e.type === "wheel") {
94
+ const axis = e.axis ?? "vertical";
95
+ const delta = e.delta ?? 0;
96
+ if (scroll && scroll.axis === axis && e.t - scroll.last <= SCROLL_JOIN_SEC && Math.sign(delta) === Math.sign(scroll.notches)) {
97
+ scroll.notches += delta;
98
+ scroll.last = e.t;
99
+ scroll.step.text = scrollText(axis, scroll.notches);
100
+ continue;
101
+ }
102
+ const step = { t: e.t, action: "scroll", text: scrollText(axis, delta), x: e.x, y: e.y };
103
+ steps.push(step);
104
+ scroll = { step, axis, notches: delta, last: e.t };
105
+ }
106
+ else if (e.type === "key") {
107
+ steps.push({ t: e.t, action: "shortcut", text: `Press ${e.keys ?? "a shortcut"}` });
108
+ }
109
+ else if (e.type === "typing") {
110
+ const d = e.durationSec ?? 0;
111
+ steps.push({ t: e.t, action: "typing", text: `Type${d > 0 ? ` for ${r3(d)} s` : ""} (keys are not logged)` });
112
+ }
113
+ else if (e.type === "gap") {
114
+ const why = GAP_WHY[e.reason ?? "input_not_seen"];
115
+ steps.push({ t: e.t, action: "gap", text: `Input may be missing for ${r3(e.durationSec ?? 0)} s (${why})` });
116
+ }
117
+ }
118
+ return steps;
119
+ }
120
+ function mostlyOverlap(a, b) {
121
+ const w = Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x);
122
+ const h = Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y);
123
+ if (w <= 0 || h <= 0)
124
+ return false;
125
+ return w * h >= 0.5 * Math.min(a.width * a.height, b.width * b.height);
126
+ }
127
+ export function mergeRedactions(regions) {
128
+ const out = [];
129
+ for (const r of [...regions].sort((a, b) => a.start - b.start)) {
130
+ const into = out.find((o) => r.start <= o.end && mostlyOverlap(o, r));
131
+ if (!into) {
132
+ out.push({ ...r });
133
+ continue;
134
+ }
135
+ const x = Math.min(into.x, r.x);
136
+ const y = Math.min(into.y, r.y);
137
+ into.width = Math.max(into.x + into.width, r.x + r.width) - x;
138
+ into.height = Math.max(into.y + into.height, r.y + r.height) - y;
139
+ into.x = x;
140
+ into.y = y;
141
+ into.start = Math.min(into.start, r.start);
142
+ into.end = Math.max(into.end, r.end);
143
+ }
144
+ return out;
145
+ }
146
+ export const MASK = "[REDACTED]";
147
+ export function maskSecrets(texts, pattern) {
148
+ if (texts.length === 0)
149
+ return [];
150
+ const ranges = regexRanges(texts, pattern);
151
+ return texts.map((text, i) => {
152
+ const spans = [...(ranges[i] ?? [])].sort((a, b) => a[0] - b[0]);
153
+ let out = "";
154
+ let at = 0;
155
+ for (const [s, e] of spans) {
156
+ if (e <= at)
157
+ continue;
158
+ out += text.slice(at, Math.max(at, s)) + (s >= at ? MASK : "");
159
+ at = e;
160
+ }
161
+ return out + text.slice(at);
162
+ });
163
+ }
164
+ export function errorFindings(frames, errorPattern, secretPattern) {
165
+ const found = new Map();
166
+ for (const frame of frames) {
167
+ const hitLines = new Set(findMatches(frame.lines, errorPattern, true).map((m) => m.line));
168
+ for (const line of hitLines) {
169
+ const key = normalizeForMatch(line);
170
+ const seen = found.get(key);
171
+ if (seen)
172
+ seen.lastSeen = frame.t;
173
+ else
174
+ found.set(key, { text: line, firstSeen: frame.t, lastSeen: frame.t });
175
+ }
176
+ }
177
+ const lastT = frames.at(-1)?.t;
178
+ const list = [...found.values()].sort((a, b) => Number(b.lastSeen === lastT) - Number(a.lastSeen === lastT) || a.firstSeen - b.firstSeen).slice(0, MAX_ERROR_LINES);
179
+ if (!secretPattern)
180
+ return list;
181
+ const masked = maskSecrets(list.map((f) => f.text), secretPattern);
182
+ return list.map((f, i) => ({ ...f, text: masked[i] ?? f.text }));
183
+ }
184
+ const code = (s) => `\`${s.replace(/`/g, "'").replace(/\s+/g, " ").trim()}\``;
185
+ const cell = (s) => s.replace(/\|/g, "\\|").replace(/\s*\n\s*/g, " ");
186
+ export function buildReportMarkdown(r) {
187
+ const out = [`# ${r.title.replace(/\s*\n\s*/g, " ")}`, ""];
188
+ const span = `${formatTimecode(r.clip.start)}-${formatTimecode(r.clip.end)}`;
189
+ out.push(`Recorded repro: ${r.clip.width}x${r.clip.height}, clip ${span} of a ${formatTimecode(r.clip.recordingDurationSec)} recording.`, "");
190
+ if (r.actual || r.expected) {
191
+ if (r.actual)
192
+ out.push("**Actual:** " + r.actual.trim(), "");
193
+ if (r.expected)
194
+ out.push("**Expected:** " + r.expected.trim(), "");
195
+ }
196
+ out.push("## Steps to reproduce", "");
197
+ if (r.steps.length === 0) {
198
+ out.push(`_${r.stepsNote ?? "No input events in the recording."} Add the steps by hand._`, "");
199
+ }
200
+ else {
201
+ out.push("From the recording's input event log; times are on the recording's clock, positions in video pixels.", "");
202
+ r.steps.forEach((s, i) => out.push(`${i + 1}. \`${formatTimecode(s.t)}\` ${s.text}`));
203
+ if (r.stepsOmitted)
204
+ out.push("", `_${r.stepsOmitted} more steps not shown (see report.json)._`);
205
+ out.push("");
206
+ }
207
+ out.push("## Error text on screen", "");
208
+ if (r.ocr !== "read") {
209
+ out.push("_Not read: Windows OCR is unavailable here._", "");
210
+ }
211
+ else if (r.errors.length === 0) {
212
+ out.push("_None found by OCR in the clip._", "");
213
+ }
214
+ else {
215
+ out.push("Read by OCR (best-effort, may contain misreads); times from the clip start.", "");
216
+ for (const e of r.errors) {
217
+ const when = e.firstSeen === e.lastSeen ? formatTimecode(e.firstSeen) : `${formatTimecode(e.firstSeen)}-${formatTimecode(e.lastSeen)}`;
218
+ out.push(`- \`${when}\` ${code(e.text)}`);
219
+ }
220
+ out.push("");
221
+ }
222
+ out.push("## Recording", "");
223
+ if (r.files.gif) {
224
+ out.push("<!-- GitHub does not upload local files from --body-file: drag the GIF and clip into the issue, " +
225
+ "or replace these links with the uploaded URLs. -->", `![Repro](${r.files.gif})`, "");
226
+ }
227
+ out.push(`- Clip: [${r.files.clip}](${r.files.clip}) (${r3(r.clip.end - r.clip.start)} s)`);
228
+ if (r.files.gif && r.gif) {
229
+ const mb = (r.gif.sizeBytes / 1_000_000).toFixed(1);
230
+ out.push(`- ${r.gif.format === "gif" ? "GIF" : "WebP"}: [${r.files.gif}](${r.files.gif}) (${mb} MB${r.gif.withinBudget ? "" : ", over the size budget"})`);
231
+ }
232
+ if (r.files.contactSheet)
233
+ out.push(`- Contact sheet: [${r.files.contactSheet}](${r.files.contactSheet})`);
234
+ out.push("");
235
+ out.push("## Environment", "", "| | |", "|---|---|");
236
+ for (const [k, v] of r.environment)
237
+ out.push(`| ${cell(k)} | ${cell(v)} |`);
238
+ out.push("");
239
+ const red = r.redaction;
240
+ const boxes = red.found + red.manual;
241
+ out.push("<sub>", red.scanned
242
+ ? `Secret scan: OCR every ${red.everySec} s over ${red.framesScanned} frames; ${boxes} region${boxes === 1 ? "" : "s"} boxed out of the media. ` +
243
+ "OCR is best-effort: review the clip before posting."
244
+ : `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>", "");
245
+ return out.join("\n");
246
+ }
@@ -1,10 +1,3 @@
1
- /**
2
- * Timed annotations (#121): boxes, text labels, and arrows that appear over a
3
- * video between two timestamps. Boxes and text are drawbox / drawtext with an
4
- * `enable` window. ffmpeg cannot draw an arbitrary line, so an arrow is drawn
5
- * as an image (a shaft plus a triangular head, via geq), rotated to its angle,
6
- * and overlaid centred on the arrow's midpoint. Builders are pure.
7
- */
8
1
  import { ScreencastError } from "./errors.js";
9
2
  import { escapeFilterPath } from "./fonts.js";
10
3
  import { enableExpr } from "./media.js";
@@ -20,8 +13,6 @@ function enable(c) {
20
13
  const e = enableExpr(c.from, c.to);
21
14
  return e ? `:enable='${e}'` : "";
22
15
  }
23
- /** Geometry of an arrow image: its length, thickness, rotation (radians,
24
- * clockwise in screen coordinates), and centre. Pure. */
25
16
  export function arrowGeometry(a) {
26
17
  const dx = a.x2 - a.x1;
27
18
  const dy = a.y2 - a.y1;
@@ -31,14 +22,11 @@ export function arrowGeometry(a) {
31
22
  throw new ScreencastError("An arrow must be at least three times as long as it is thick.");
32
23
  return { length, thickness, angle: Math.atan2(dy, dx), cx: (a.x1 + a.x2) / 2, cy: (a.y1 + a.y2) / 2 };
33
24
  }
34
- /** Render one arrow, already rotated, as a transparent PNG. Pure args. */
35
25
  export function buildArrowImageArgs(a, output) {
36
26
  const { length, thickness, angle } = arrowGeometry(a);
37
27
  const color = validateColor(a.color ?? "red");
38
28
  const head = thickness * 3;
39
29
  const ang = angle.toFixed(6);
40
- // Opaque where: the shaft (|y - mid| < t/2 before the head), or inside the
41
- // triangular head (|y - mid| < remaining length / 2).
42
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))`;
43
31
  return [
44
32
  "-y", "-v", "error",
@@ -48,10 +36,6 @@ export function buildArrowImageArgs(a, output) {
48
36
  ...stillOutput(output),
49
37
  ];
50
38
  }
51
- /** Filter steps that draw every callout over the stream labelled `input`
52
- * (later items on top). Arrow images become extra inputs numbered from
53
- * `firstInput`; labels are prefixed with `tag`. Shared by callout and
54
- * pipeline. Pure. */
55
39
  export function calloutSteps(items, assets, input, firstInput, tag) {
56
40
  if (items.length === 0)
57
41
  throw new ScreencastError("Give at least one callout.");
@@ -73,7 +57,7 @@ export function calloutSteps(items, assets, input, firstInput, tag) {
73
57
  const color = validateColor(c.color ?? "white");
74
58
  const size = Math.max(8, Math.round(c.size ?? 32));
75
59
  const panel = c.background === false ? "" : `:box=1:boxcolor=black@0.6:boxborderw=${Math.round(size / 3)}`;
76
- steps.push(`${cur}drawtext=fontfile=${escapeFilterPath(assets.fontFile)}:textfile=${escapeFilterPath(file)}:expansion=none` +
60
+ steps.push(`${cur}drawtext=fontfile=${escapeFilterPath(assets.fontFiles?.[i] ?? assets.fontFile)}:textfile=${escapeFilterPath(file)}:expansion=none` +
77
61
  `:x=${nonNeg(c.x, "x")}:y=${nonNeg(c.y, "y")}:fontsize=${size}:fontcolor=${color}${panel}${enable(c)}${out}`);
78
62
  }
79
63
  else {
@@ -89,7 +73,6 @@ export function calloutSteps(items, assets, input, firstInput, tag) {
89
73
  });
90
74
  return { steps, out: cur, extraInputs };
91
75
  }
92
- /** Draw every callout in order (later items on top). Pure. */
93
76
  export function buildCalloutArgs(input, output, items, assets, quality = "standard") {
94
77
  const { steps, out, extraInputs } = calloutSteps(items, assets, "[0:v]", 1, "");
95
78
  return [
@@ -101,4 +84,3 @@ export function buildCalloutArgs(input, output, items, assets, quality = "standa
101
84
  output,
102
85
  ];
103
86
  }
104
- //# sourceMappingURL=callout.js.map
@@ -1,14 +1,26 @@
1
- /**
2
- * Files a callout render needs: each text item's text (drawtext reads it from a
3
- * file, so no escaping is needed) and each arrow rendered to a PNG. Shared by
4
- * callout and pipeline; the caller owns and removes `workDir`.
5
- */
6
1
  import { join } from "node:path";
7
2
  import { writeFileSync } from "node:fs";
8
3
  import { runFfmpeg } from "./ffmpeg.js";
9
4
  import { buildArrowImageArgs } from "./callout.js";
10
- import { bundledFontPath } from "./fonts.js";
11
- export async function prepareCalloutAssets(items, workDir, tag = "") {
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);
12
24
  const textFiles = items.map((c, i) => {
13
25
  if (c.type !== "text")
14
26
  return null;
@@ -17,8 +29,7 @@ export async function prepareCalloutAssets(items, workDir, tag = "") {
17
29
  return f;
18
30
  });
19
31
  const arrowFiles = [];
20
- for (let i = 0; i < items.length; i++) {
21
- const c = items[i];
32
+ for (const [i, c] of items.entries()) {
22
33
  if (c.type !== "arrow") {
23
34
  arrowFiles.push(null);
24
35
  continue;
@@ -27,6 +38,5 @@ export async function prepareCalloutAssets(items, workDir, tag = "") {
27
38
  await runFfmpeg(buildArrowImageArgs(c, f), 30_000);
28
39
  arrowFiles.push(f);
29
40
  }
30
- return { fontFile: bundledFontPath("bold"), textFiles, arrowFiles };
41
+ return { fontFile: bundledFontPath("bold"), textFiles, arrowFiles, ...fonts };
31
42
  }
32
- //# sourceMappingURL=calloutAssets.js.map
@@ -0,0 +1,95 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { isAbsolute } from "node:path";
3
+ import { runPowerShell, psTimeoutMs } from "./monitors.js";
4
+ export const FFMPEG_FEATURE_MAJOR = 8;
5
+ export function parseFfmpegVersion(text) {
6
+ const version = /^ff(?:mpeg|probe) version (\S+)/m.exec(text)?.[1] ?? null;
7
+ const release = version ? /^n?(\d+)\.\d+/.exec(version) : null;
8
+ if (release)
9
+ return { version, major: Number(release[1]), inferred: false };
10
+ const avutil = /^\s*libavutil\s+(\d+)\./m.exec(text);
11
+ if (avutil && Number(avutil[1]) >= 56)
12
+ return { version, major: Number(avutil[1]) - 52, inferred: true };
13
+ return { version, major: null, inferred: false };
14
+ }
15
+ export function parseDevices(text) {
16
+ const out = new Set();
17
+ const body = text.split(/^\s*---\s*$/m).slice(1).join("\n") || text;
18
+ for (const line of body.split(/\r?\n/)) {
19
+ const m = /^\s{0,2}[D ][E ]\s?[d ]?\s+([a-z0-9_,]+)\s/i.exec(line);
20
+ if (m?.[1])
21
+ for (const name of m[1].split(","))
22
+ out.add(name);
23
+ }
24
+ return [...out];
25
+ }
26
+ function run(bin, args) {
27
+ try {
28
+ const res = spawnSync(bin, args, { encoding: "utf8", windowsHide: true, timeout: 10_000 });
29
+ if (res.status !== 0)
30
+ return null;
31
+ return `${res.stdout ?? ""}${res.stderr ?? ""}`;
32
+ }
33
+ catch {
34
+ return null;
35
+ }
36
+ }
37
+ export function versionText(bin) {
38
+ return run(bin, ["-version"]);
39
+ }
40
+ export function devicesText(ffmpeg) {
41
+ return run(ffmpeg, ["-hide_banner", "-devices"]);
42
+ }
43
+ export function locate(bin) {
44
+ if (isAbsolute(bin))
45
+ return bin;
46
+ const out = run(process.platform === "win32" ? "where" : "which", [bin]);
47
+ return out?.split(/\r?\n/).map((l) => l.trim()).find((l) => l.length > 0) ?? null;
48
+ }
49
+ const PS_OCR_STATUS = `
50
+ $ErrorActionPreference = 'Stop'
51
+ $null = [Windows.Media.Ocr.OcrEngine, Windows.Foundation, ContentType = WindowsRuntime]
52
+ $e = [Windows.Media.Ocr.OcrEngine]::TryCreateFromUserProfileLanguages()
53
+ [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
54
+ `;
55
+ export async function ocrStatus() {
56
+ if (process.platform !== "win32") {
57
+ return { available: false, language: null, languages: [], error: "The Windows OCR engine is available on Windows only." };
58
+ }
59
+ try {
60
+ const raw = JSON.parse(await runPowerShell(PS_OCR_STATUS, "OCR languages", { timeoutMs: psTimeoutMs(15_000) }));
61
+ const languages = Array.isArray(raw.languages) ? raw.languages : raw.languages ? [raw.languages] : [];
62
+ return { available: raw.available === true, language: raw.language ?? null, languages };
63
+ }
64
+ catch (err) {
65
+ return { available: false, language: null, languages: [], error: err.message };
66
+ }
67
+ }
68
+ export const ENV_SETTINGS = [
69
+ "SCREENCAST_HOME",
70
+ "SCREENCAST_ALLOWED_DIRS",
71
+ "FFMPEG_PATH",
72
+ "FFPROBE_PATH",
73
+ "SCREENCAST_WHISPER_MODEL",
74
+ "SCREENCAST_MAX_RECORDING_SEC",
75
+ "SCREENCAST_JOB_TIMEOUT_MS",
76
+ "SCREENCAST_PS_TIMEOUT_MS",
77
+ "SCREENCAST_RETENTION_DAYS",
78
+ "SCREENCAST_CONFIRM_CAPTURE",
79
+ "SCREENCAST_TOOLSETS",
80
+ ];
81
+ export function envSettings(env = process.env) {
82
+ return Object.fromEntries(ENV_SETTINGS.map((name) => {
83
+ const value = env[name];
84
+ return [name, value && value.trim().length > 0 ? value : null];
85
+ }));
86
+ }
87
+ export const KEY_FILTERS = [
88
+ { filter: "whisper", tools: "transcribe", why: `FFmpeg ${FFMPEG_FEATURE_MAJOR}+ built with whisper.cpp` },
89
+ { filter: "gfxcapture", tools: 'backend: "wgc" (screenshot, start_recording, find_text)', why: `FFmpeg ${FFMPEG_FEATURE_MAJOR}+ on Windows` },
90
+ { filter: "subtitles", tools: "burn_subtitles", why: "libass" },
91
+ { filter: "drawtext", tools: "title_card, callout, contact_sheet labels, produce", why: "libfreetype" },
92
+ { filter: "afftdn", tools: "denoise", why: "a standard build" },
93
+ { filter: "loudnorm", tools: "normalize_audio", why: "a standard build" },
94
+ { filter: "xfade", tools: "xfade_transition, assemble_highlights", why: "FFmpeg 4.3+" },
95
+ ];