@tmhs/screencast-mcp 0.38.0 → 0.44.2

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 (329) hide show
  1. package/README.md +58 -14
  2. package/assets/icon.png +0 -0
  3. package/assets/ui/player.html +38 -302
  4. package/assets/ui/player.js +382 -0
  5. package/dist/context.js +0 -5
  6. package/dist/index.js +7 -115
  7. package/dist/prompts.js +0 -7
  8. package/dist/resources.js +2 -14
  9. package/dist/server.js +129 -0
  10. package/dist/tools/assembleHighlights.js +12 -7
  11. package/dist/tools/burnSubtitles.js +12 -6
  12. package/dist/tools/callout.js +32 -16
  13. package/dist/tools/clip.js +12 -9
  14. package/dist/tools/compress.js +10 -5
  15. package/dist/tools/concat.js +16 -15
  16. package/dist/tools/contactSheet.js +26 -22
  17. package/dist/tools/convert.js +12 -6
  18. package/dist/tools/crop.js +12 -7
  19. package/dist/tools/cutIdle.js +15 -9
  20. package/dist/tools/denoise.js +12 -6
  21. package/dist/tools/doctor.js +133 -0
  22. package/dist/tools/exportGif.js +14 -10
  23. package/dist/tools/exportPreset.js +11 -8
  24. package/dist/tools/extractAudio.js +10 -8
  25. package/dist/tools/findText.js +69 -65
  26. package/dist/tools/getMediaInfo.js +17 -3
  27. package/dist/tools/getSession.js +15 -3
  28. package/dist/tools/listAudioDevices.js +14 -7
  29. package/dist/tools/listSessions.js +13 -3
  30. package/dist/tools/listTargets.js +76 -0
  31. package/dist/tools/musicBed.js +14 -10
  32. package/dist/tools/normalizeAudio.js +12 -8
  33. package/dist/tools/overlay.js +16 -12
  34. package/dist/tools/pipeline.js +31 -22
  35. package/dist/tools/readEvents.js +21 -12
  36. package/dist/tools/redactRegion.js +19 -17
  37. package/dist/tools/reframe.js +9 -5
  38. package/dist/tools/reviewRecording.js +63 -22
  39. package/dist/tools/sampleFrames.js +33 -40
  40. package/dist/tools/scale.js +9 -3
  41. package/dist/tools/screenDiff.js +23 -17
  42. package/dist/tools/screenshot.js +21 -17
  43. package/dist/tools/speed.js +15 -4
  44. package/dist/tools/startRecording.js +48 -52
  45. package/dist/tools/stopRecording.js +10 -9
  46. package/dist/tools/titleCard.js +19 -11
  47. package/dist/tools/transcribe.js +13 -7
  48. package/dist/tools/trim.js +11 -10
  49. package/dist/tools/waitForChange.js +37 -22
  50. package/dist/tools/xfadeTransition.js +12 -8
  51. package/dist/tools/zoom.js +26 -29
  52. package/dist/utils/anim.js +1 -21
  53. package/dist/utils/animExport.js +5 -10
  54. package/dist/utils/audio.js +4 -33
  55. package/dist/utils/audioDevices.js +1 -48
  56. package/dist/utils/callout.js +1 -19
  57. package/dist/utils/calloutAssets.js +21 -11
  58. package/dist/utils/capabilities.js +95 -0
  59. package/dist/utils/captions.js +9 -26
  60. package/dist/utils/consent.js +29 -0
  61. package/dist/utils/diff.js +0 -46
  62. package/dist/utils/errors.js +5 -13
  63. package/dist/utils/events.js +21 -77
  64. package/dist/utils/expr.js +11 -0
  65. package/dist/utils/ffmpeg.js +119 -48
  66. package/dist/utils/fontCoverage.js +177 -0
  67. package/dist/utils/fonts.js +139 -23
  68. package/dist/utils/idle.js +12 -24
  69. package/dist/utils/images.js +0 -17
  70. package/dist/utils/jobs.js +42 -41
  71. package/dist/utils/lifecycle.js +0 -29
  72. package/dist/utils/logging.js +75 -0
  73. package/dist/utils/media.js +11 -122
  74. package/dist/utils/monitors.js +7 -43
  75. package/dist/utils/ocr.js +53 -71
  76. package/dist/utils/paths.js +68 -31
  77. package/dist/utils/pipeline.js +0 -23
  78. package/dist/utils/player.js +50 -27
  79. package/dist/utils/produce.js +6 -66
  80. package/dist/utils/resolveTarget.js +0 -19
  81. package/dist/utils/retention.js +1 -15
  82. package/dist/utils/roots.js +42 -0
  83. package/dist/utils/sessions.js +195 -160
  84. package/dist/utils/sheet.js +0 -19
  85. package/dist/utils/still.js +0 -15
  86. package/dist/utils/targetList.js +63 -0
  87. package/dist/utils/targets.js +5 -70
  88. package/dist/utils/toolSpec.js +25 -0
  89. package/dist/utils/toolsets.js +102 -0
  90. package/dist/utils/validate.js +0 -22
  91. package/dist/utils/wgc.js +0 -46
  92. package/dist/utils/windows.js +5 -50
  93. package/dist/utils/zoom.js +55 -85
  94. package/dist/wgcRecorder.js +1 -30
  95. package/package.json +7 -3
  96. package/dist/context.d.ts +0 -9
  97. package/dist/context.d.ts.map +0 -1
  98. package/dist/context.js.map +0 -1
  99. package/dist/index.d.ts +0 -3
  100. package/dist/index.d.ts.map +0 -1
  101. package/dist/index.js.map +0 -1
  102. package/dist/prompts.d.ts +0 -10
  103. package/dist/prompts.d.ts.map +0 -1
  104. package/dist/prompts.js.map +0 -1
  105. package/dist/resources.d.ts +0 -3
  106. package/dist/resources.d.ts.map +0 -1
  107. package/dist/resources.js.map +0 -1
  108. package/dist/tools/assembleHighlights.d.ts +0 -3
  109. package/dist/tools/assembleHighlights.d.ts.map +0 -1
  110. package/dist/tools/assembleHighlights.js.map +0 -1
  111. package/dist/tools/burnSubtitles.d.ts +0 -3
  112. package/dist/tools/burnSubtitles.d.ts.map +0 -1
  113. package/dist/tools/burnSubtitles.js.map +0 -1
  114. package/dist/tools/callout.d.ts +0 -37
  115. package/dist/tools/callout.d.ts.map +0 -1
  116. package/dist/tools/callout.js.map +0 -1
  117. package/dist/tools/clip.d.ts +0 -3
  118. package/dist/tools/clip.d.ts.map +0 -1
  119. package/dist/tools/clip.js.map +0 -1
  120. package/dist/tools/compress.d.ts +0 -3
  121. package/dist/tools/compress.d.ts.map +0 -1
  122. package/dist/tools/compress.js.map +0 -1
  123. package/dist/tools/concat.d.ts +0 -3
  124. package/dist/tools/concat.d.ts.map +0 -1
  125. package/dist/tools/concat.js.map +0 -1
  126. package/dist/tools/contactSheet.d.ts +0 -3
  127. package/dist/tools/contactSheet.d.ts.map +0 -1
  128. package/dist/tools/contactSheet.js.map +0 -1
  129. package/dist/tools/convert.d.ts +0 -3
  130. package/dist/tools/convert.d.ts.map +0 -1
  131. package/dist/tools/convert.js.map +0 -1
  132. package/dist/tools/crop.d.ts +0 -3
  133. package/dist/tools/crop.d.ts.map +0 -1
  134. package/dist/tools/crop.js.map +0 -1
  135. package/dist/tools/cutIdle.d.ts +0 -3
  136. package/dist/tools/cutIdle.d.ts.map +0 -1
  137. package/dist/tools/cutIdle.js.map +0 -1
  138. package/dist/tools/denoise.d.ts +0 -3
  139. package/dist/tools/denoise.d.ts.map +0 -1
  140. package/dist/tools/denoise.js.map +0 -1
  141. package/dist/tools/exportGif.d.ts +0 -3
  142. package/dist/tools/exportGif.d.ts.map +0 -1
  143. package/dist/tools/exportGif.js.map +0 -1
  144. package/dist/tools/exportPreset.d.ts +0 -3
  145. package/dist/tools/exportPreset.d.ts.map +0 -1
  146. package/dist/tools/exportPreset.js.map +0 -1
  147. package/dist/tools/extractAudio.d.ts +0 -3
  148. package/dist/tools/extractAudio.d.ts.map +0 -1
  149. package/dist/tools/extractAudio.js.map +0 -1
  150. package/dist/tools/findText.d.ts +0 -6
  151. package/dist/tools/findText.d.ts.map +0 -1
  152. package/dist/tools/findText.js.map +0 -1
  153. package/dist/tools/getMediaInfo.d.ts +0 -3
  154. package/dist/tools/getMediaInfo.d.ts.map +0 -1
  155. package/dist/tools/getMediaInfo.js.map +0 -1
  156. package/dist/tools/getSession.d.ts +0 -3
  157. package/dist/tools/getSession.d.ts.map +0 -1
  158. package/dist/tools/getSession.js.map +0 -1
  159. package/dist/tools/listAudioDevices.d.ts +0 -3
  160. package/dist/tools/listAudioDevices.d.ts.map +0 -1
  161. package/dist/tools/listAudioDevices.js.map +0 -1
  162. package/dist/tools/listSessions.d.ts +0 -3
  163. package/dist/tools/listSessions.d.ts.map +0 -1
  164. package/dist/tools/listSessions.js.map +0 -1
  165. package/dist/tools/musicBed.d.ts +0 -3
  166. package/dist/tools/musicBed.d.ts.map +0 -1
  167. package/dist/tools/musicBed.js.map +0 -1
  168. package/dist/tools/normalizeAudio.d.ts +0 -3
  169. package/dist/tools/normalizeAudio.d.ts.map +0 -1
  170. package/dist/tools/normalizeAudio.js.map +0 -1
  171. package/dist/tools/overlay.d.ts +0 -3
  172. package/dist/tools/overlay.d.ts.map +0 -1
  173. package/dist/tools/overlay.js.map +0 -1
  174. package/dist/tools/pipeline.d.ts +0 -3
  175. package/dist/tools/pipeline.d.ts.map +0 -1
  176. package/dist/tools/pipeline.js.map +0 -1
  177. package/dist/tools/readEvents.d.ts +0 -6
  178. package/dist/tools/readEvents.d.ts.map +0 -1
  179. package/dist/tools/readEvents.js.map +0 -1
  180. package/dist/tools/redactRegion.d.ts +0 -13
  181. package/dist/tools/redactRegion.d.ts.map +0 -1
  182. package/dist/tools/redactRegion.js.map +0 -1
  183. package/dist/tools/reframe.d.ts +0 -3
  184. package/dist/tools/reframe.d.ts.map +0 -1
  185. package/dist/tools/reframe.js.map +0 -1
  186. package/dist/tools/reviewRecording.d.ts +0 -5
  187. package/dist/tools/reviewRecording.d.ts.map +0 -1
  188. package/dist/tools/reviewRecording.js.map +0 -1
  189. package/dist/tools/sampleFrames.d.ts +0 -3
  190. package/dist/tools/sampleFrames.d.ts.map +0 -1
  191. package/dist/tools/sampleFrames.js.map +0 -1
  192. package/dist/tools/scale.d.ts +0 -3
  193. package/dist/tools/scale.d.ts.map +0 -1
  194. package/dist/tools/scale.js.map +0 -1
  195. package/dist/tools/screenDiff.d.ts +0 -3
  196. package/dist/tools/screenDiff.d.ts.map +0 -1
  197. package/dist/tools/screenDiff.js.map +0 -1
  198. package/dist/tools/screenshot.d.ts +0 -3
  199. package/dist/tools/screenshot.d.ts.map +0 -1
  200. package/dist/tools/screenshot.js.map +0 -1
  201. package/dist/tools/speed.d.ts +0 -3
  202. package/dist/tools/speed.d.ts.map +0 -1
  203. package/dist/tools/speed.js.map +0 -1
  204. package/dist/tools/startRecording.d.ts +0 -3
  205. package/dist/tools/startRecording.d.ts.map +0 -1
  206. package/dist/tools/startRecording.js.map +0 -1
  207. package/dist/tools/stopRecording.d.ts +0 -3
  208. package/dist/tools/stopRecording.d.ts.map +0 -1
  209. package/dist/tools/stopRecording.js.map +0 -1
  210. package/dist/tools/titleCard.d.ts +0 -3
  211. package/dist/tools/titleCard.d.ts.map +0 -1
  212. package/dist/tools/titleCard.js.map +0 -1
  213. package/dist/tools/transcribe.d.ts +0 -3
  214. package/dist/tools/transcribe.d.ts.map +0 -1
  215. package/dist/tools/transcribe.js.map +0 -1
  216. package/dist/tools/trim.d.ts +0 -3
  217. package/dist/tools/trim.d.ts.map +0 -1
  218. package/dist/tools/trim.js.map +0 -1
  219. package/dist/tools/waitForChange.d.ts +0 -3
  220. package/dist/tools/waitForChange.d.ts.map +0 -1
  221. package/dist/tools/waitForChange.js.map +0 -1
  222. package/dist/tools/xfadeTransition.d.ts +0 -3
  223. package/dist/tools/xfadeTransition.d.ts.map +0 -1
  224. package/dist/tools/xfadeTransition.js.map +0 -1
  225. package/dist/tools/zoom.d.ts +0 -15
  226. package/dist/tools/zoom.d.ts.map +0 -1
  227. package/dist/tools/zoom.js.map +0 -1
  228. package/dist/utils/anim.d.ts +0 -33
  229. package/dist/utils/anim.d.ts.map +0 -1
  230. package/dist/utils/anim.js.map +0 -1
  231. package/dist/utils/animExport.d.ts +0 -27
  232. package/dist/utils/animExport.d.ts.map +0 -1
  233. package/dist/utils/animExport.js.map +0 -1
  234. package/dist/utils/audio.d.ts +0 -49
  235. package/dist/utils/audio.d.ts.map +0 -1
  236. package/dist/utils/audio.js.map +0 -1
  237. package/dist/utils/audioDevices.d.ts +0 -33
  238. package/dist/utils/audioDevices.d.ts.map +0 -1
  239. package/dist/utils/audioDevices.js.map +0 -1
  240. package/dist/utils/callout.d.ts +0 -72
  241. package/dist/utils/callout.d.ts.map +0 -1
  242. package/dist/utils/callout.js.map +0 -1
  243. package/dist/utils/calloutAssets.d.ts +0 -3
  244. package/dist/utils/calloutAssets.d.ts.map +0 -1
  245. package/dist/utils/calloutAssets.js.map +0 -1
  246. package/dist/utils/captions.d.ts +0 -26
  247. package/dist/utils/captions.d.ts.map +0 -1
  248. package/dist/utils/captions.js.map +0 -1
  249. package/dist/utils/diff.d.ts +0 -112
  250. package/dist/utils/diff.d.ts.map +0 -1
  251. package/dist/utils/diff.js.map +0 -1
  252. package/dist/utils/errors.d.ts +0 -33
  253. package/dist/utils/errors.d.ts.map +0 -1
  254. package/dist/utils/errors.js.map +0 -1
  255. package/dist/utils/events.d.ts +0 -143
  256. package/dist/utils/events.d.ts.map +0 -1
  257. package/dist/utils/events.js.map +0 -1
  258. package/dist/utils/ffmpeg.d.ts +0 -50
  259. package/dist/utils/ffmpeg.d.ts.map +0 -1
  260. package/dist/utils/ffmpeg.js.map +0 -1
  261. package/dist/utils/fonts.d.ts +0 -17
  262. package/dist/utils/fonts.d.ts.map +0 -1
  263. package/dist/utils/fonts.js.map +0 -1
  264. package/dist/utils/idle.d.ts +0 -23
  265. package/dist/utils/idle.d.ts.map +0 -1
  266. package/dist/utils/idle.js.map +0 -1
  267. package/dist/utils/images.d.ts +0 -21
  268. package/dist/utils/images.d.ts.map +0 -1
  269. package/dist/utils/images.js.map +0 -1
  270. package/dist/utils/jobs.d.ts +0 -44
  271. package/dist/utils/jobs.d.ts.map +0 -1
  272. package/dist/utils/jobs.js.map +0 -1
  273. package/dist/utils/lifecycle.d.ts +0 -29
  274. package/dist/utils/lifecycle.d.ts.map +0 -1
  275. package/dist/utils/lifecycle.js.map +0 -1
  276. package/dist/utils/media.d.ts +0 -272
  277. package/dist/utils/media.d.ts.map +0 -1
  278. package/dist/utils/media.js.map +0 -1
  279. package/dist/utils/monitors.d.ts +0 -47
  280. package/dist/utils/monitors.d.ts.map +0 -1
  281. package/dist/utils/monitors.js.map +0 -1
  282. package/dist/utils/ocr.d.ts +0 -50
  283. package/dist/utils/ocr.d.ts.map +0 -1
  284. package/dist/utils/ocr.js.map +0 -1
  285. package/dist/utils/paths.d.ts +0 -28
  286. package/dist/utils/paths.d.ts.map +0 -1
  287. package/dist/utils/paths.js.map +0 -1
  288. package/dist/utils/pipeline.d.ts +0 -69
  289. package/dist/utils/pipeline.d.ts.map +0 -1
  290. package/dist/utils/pipeline.js.map +0 -1
  291. package/dist/utils/player.d.ts +0 -30
  292. package/dist/utils/player.d.ts.map +0 -1
  293. package/dist/utils/player.js.map +0 -1
  294. package/dist/utils/produce.d.ts +0 -126
  295. package/dist/utils/produce.d.ts.map +0 -1
  296. package/dist/utils/produce.js.map +0 -1
  297. package/dist/utils/resolveTarget.d.ts +0 -32
  298. package/dist/utils/resolveTarget.d.ts.map +0 -1
  299. package/dist/utils/resolveTarget.js.map +0 -1
  300. package/dist/utils/retention.d.ts +0 -10
  301. package/dist/utils/retention.d.ts.map +0 -1
  302. package/dist/utils/retention.js.map +0 -1
  303. package/dist/utils/sessions.d.ts +0 -154
  304. package/dist/utils/sessions.d.ts.map +0 -1
  305. package/dist/utils/sessions.js.map +0 -1
  306. package/dist/utils/sheet.d.ts +0 -26
  307. package/dist/utils/sheet.d.ts.map +0 -1
  308. package/dist/utils/sheet.js.map +0 -1
  309. package/dist/utils/still.d.ts +0 -7
  310. package/dist/utils/still.d.ts.map +0 -1
  311. package/dist/utils/still.js.map +0 -1
  312. package/dist/utils/targets.d.ts +0 -113
  313. package/dist/utils/targets.d.ts.map +0 -1
  314. package/dist/utils/targets.js.map +0 -1
  315. package/dist/utils/validate.d.ts +0 -15
  316. package/dist/utils/validate.d.ts.map +0 -1
  317. package/dist/utils/validate.js.map +0 -1
  318. package/dist/utils/wgc.d.ts +0 -46
  319. package/dist/utils/wgc.d.ts.map +0 -1
  320. package/dist/utils/wgc.js.map +0 -1
  321. package/dist/utils/windows.d.ts +0 -94
  322. package/dist/utils/windows.d.ts.map +0 -1
  323. package/dist/utils/windows.js.map +0 -1
  324. package/dist/utils/zoom.d.ts +0 -95
  325. package/dist/utils/zoom.d.ts.map +0 -1
  326. package/dist/utils/zoom.js.map +0 -1
  327. package/dist/wgcRecorder.d.ts +0 -2
  328. package/dist/wgcRecorder.d.ts.map +0 -1
  329. package/dist/wgcRecorder.js.map +0 -1
@@ -1,15 +1,14 @@
1
1
  import { z } from "zod";
2
2
  import { existsSync, readFileSync } from "node:fs";
3
3
  import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
4
- import { requireFfmpeg, runFfmpegBuffer, probeMedia } from "../utils/ffmpeg.js";
4
+ import { WRITES_FILE, looseOutput } from "../utils/toolSpec.js";
5
+ import { requireFfmpeg, runFfmpegFrames, probeMedia } from "../utils/ffmpeg.js";
5
6
  import { runEditJob, jobTimeoutMs } from "../utils/jobs.js";
6
7
  import { analysisSize } from "../utils/diff.js";
7
- import { keyframesToViews, buildZoomArgs, planAutoZoom, planClickZoom, buildAnalysisArgs, DEFAULT_TRANSITION_SEC, DEFAULT_AUTO_MAX_ZOOM, DEFAULT_RING_COLOR, MAX_ZOOM, } from "../utils/zoom.js";
8
+ import { keyframesToViews, buildZoomArgs, createAutoZoomPlanner, planClickZoom, buildAnalysisArgs, DEFAULT_TRANSITION_SEC, DEFAULT_AUTO_MAX_ZOOM, DEFAULT_RING_COLOR, MAX_ZOOM, } from "../utils/zoom.js";
8
9
  import { eventPaths, parseEventsJsonl } from "../utils/events.js";
9
10
  import { validateColor } from "../utils/validate.js";
10
- /** Most clicks one render will ring; more would make a very long filter graph. */
11
11
  export const MAX_RINGS = 200;
12
- /** In-frame clicks (mouse down) from an event log, or null if there is none. */
13
12
  function readClicks(path) {
14
13
  if (!existsSync(path))
15
14
  return null;
@@ -19,14 +18,13 @@ function readClicks(path) {
19
18
  }
20
19
  import { editOutputExt, assertEditContainer } from "../utils/media.js";
21
20
  import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
22
- /** One zoom keyframe; shared with pipeline. */
23
21
  export const zoomKeyframeSchema = z.object({
24
- t: z.number().nonnegative().describe("Seconds: the view is fully reached at this time."),
22
+ t: z.number().nonnegative(),
25
23
  x: z.number().optional(),
26
24
  y: z.number().optional(),
27
25
  width: z.number().positive().optional(),
28
26
  height: z.number().positive().optional(),
29
- full: z.boolean().optional().describe("Zoom back out to the whole frame."),
27
+ full: z.boolean().optional(),
30
28
  });
31
29
  const inputSchema = {
32
30
  input: z.string().min(1).describe("Path to the source video."),
@@ -34,24 +32,23 @@ const inputSchema = {
34
32
  .array(zoomKeyframeSchema)
35
33
  .max(100)
36
34
  .optional()
37
- .describe("Views to animate between: each fills the frame with a source rectangle (x, y, width, height) " +
38
- "by time t, or { t, full: true } to zoom out. Omit to plan them automatically (see follow)."),
35
+ .describe("Views reached by time t: a source rectangle (x, y, width, height), or { t, full: true } to " +
36
+ "zoom out. Omit to plan them (see follow)."),
39
37
  follow: z
40
38
  .enum(["auto", "clicks", "changes"])
41
39
  .optional()
42
- .describe("Without keyframes: clicks zooms toward each click in the recording's input event log " +
43
- "(start_recording events: true), panning between clicks close together; changes zooms toward " +
44
- "where the screen changed. auto (default) uses clicks when the log has any, else changes."),
40
+ .describe("Without keyframes: clicks (from the events log of start_recording events: true) or changes " +
41
+ "(where the screen changed). auto (default): clicks if logged, else changes."),
45
42
  events: z
46
43
  .string()
47
44
  .optional()
48
- .describe("Event log to read clicks from (default: the input's sibling .events.jsonl). Its times and " +
49
- "pixels must match the input, so use the original recording, not a trimmed or scaled copy."),
45
+ .describe("Events log (default: the input's .events.jsonl); must match the input's timing and size, so " +
46
+ "use the original recording."),
50
47
  highlightClicks: z
51
48
  .boolean()
52
49
  .optional()
53
- .describe("Draw an expanding ring at each click from the event log (default false). Rings move with the zoom."),
54
- highlightColor: z.string().optional().describe("Ring color: name, #RRGGBB, or name@alpha (default #FF4545)."),
50
+ .describe("Ring each logged click (default false)."),
51
+ highlightColor: z.string().optional().describe("Ring color (default #FF4545)."),
55
52
  transitionSec: z
56
53
  .number()
57
54
  .positive()
@@ -64,16 +61,20 @@ const inputSchema = {
64
61
  .max(MAX_ZOOM)
65
62
  .optional()
66
63
  .describe(`Auto mode: the furthest it zooms in (default ${DEFAULT_AUTO_MAX_ZOOM}).`),
67
- holdSec: z.number().positive().max(30).optional().describe("Auto mode: stay zoomed this long after activity stops (default 2)."),
68
- dryRun: z.boolean().optional().describe("Only return the planned keyframes (edit them and pass them back); write nothing."),
64
+ holdSec: z.number().positive().max(30).optional().describe("Auto mode: stay zoomed this long after activity (default 2)."),
65
+ dryRun: z.boolean().optional().describe("Return the planned keyframes only (editable, pass back)."),
69
66
  output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
70
67
  overwrite: z.boolean().optional().describe("Allow replacing an existing file at the output path (default false)."),
71
68
  };
72
69
  export function register(server) {
73
- server.tool("zoom", "Smooth animated zoom-and-pan, Screen Studio style: zoom into where the action is and back " +
74
- "out. Give keyframes (rectangles by time), or let it plan them from the clicks in the " +
75
- "recording's input event log or from where the screen changes. highlightClicks rings each " +
76
- "click. dryRun returns the plan so it can be adjusted. Returns the output path.", inputSchema, async (args, extra) => {
70
+ server.registerTool("zoom", {
71
+ title: "Zoom and Pan",
72
+ description: "Smooth animated zoom-and-pan into the action and back out, from keyframes or planned from " +
73
+ "logged clicks or screen changes.",
74
+ inputSchema,
75
+ outputSchema: looseOutput({ keyframes: z.array(z.unknown()) }),
76
+ annotations: WRITES_FILE,
77
+ }, async (args, extra) => {
77
78
  try {
78
79
  requireFfmpeg();
79
80
  if (!existsSync(args.input))
@@ -105,17 +106,14 @@ export function register(server) {
105
106
  if (!keyframes) {
106
107
  const size = analysisSize(W, H);
107
108
  const step = 0.25;
108
- const raw = await runFfmpegBuffer(buildAnalysisArgs(args.input, size, step), jobTimeoutMs(durationSec));
109
- const frameBytes = size.width * size.height;
110
- const frames = [];
111
- for (let o = 0; o + frameBytes <= raw.length; o += frameBytes)
112
- frames.push(raw.subarray(o, o + frameBytes));
113
- keyframes = planAutoZoom(frames, size.width, size.height, W, H, {
109
+ const planner = createAutoZoomPlanner(size.width, size.height, W, H, {
114
110
  step,
115
111
  holdSec: args.holdSec,
116
112
  maxZoom: args.maxZoom,
117
113
  transition,
118
114
  });
115
+ await runFfmpegFrames(buildAnalysisArgs(args.input, size, step), size.width * size.height, (f) => planner.push(f), jobTimeoutMs(durationSec), { signal: extra.signal });
116
+ keyframes = planner.finish();
119
117
  if (keyframes.length === 0) {
120
118
  return okResponse({ keyframes: [], note: "No localised changes found to zoom into; nothing written." });
121
119
  }
@@ -149,4 +147,3 @@ export function register(server) {
149
147
  }
150
148
  });
151
149
  }
152
- //# sourceMappingURL=zoom.js.map
@@ -1,22 +1,8 @@
1
- /**
2
- * Animated GIF / WebP export with a file-size budget (#124).
3
- *
4
- * The usual home for a developer's screen recording is an animated image in a
5
- * PR, issue, or README. A plain GIF conversion bands and balloons, so export
6
- * uses a two-stage palette (diff stats, sierra dithering, rectangle diff mode)
7
- * or animated WebP, and steps down a quality ladder until the file fits
8
- * `maxBytes` (GitHub's limit for images is 10 MB). Builders here are pure.
9
- */
10
1
  import { ScreencastError } from "./errors.js";
11
2
  export const DEFAULT_ANIM_FPS = 12;
12
3
  export const DEFAULT_ANIM_WIDTH = 960;
13
- /** Fits under GitHub's 10 MB limit for images in issues, PRs, and READMEs. */
14
4
  export const DEFAULT_MAX_BYTES = 10_000_000;
15
- /** Most encode attempts before settling for the smallest one made. */
16
5
  export const MAX_ATTEMPTS = 5;
17
- /** Quality ladder from the caller's fps/width. Each step roughly halves the
18
- * file size (measured on a high-motion 960 px clip: 6.0 -> 3.4 -> 1.7 ->
19
- * 0.7 MB for GIF). */
20
6
  export function animLadder(format, fps, width) {
21
7
  const steps = format === "gif"
22
8
  ? [[1, 1, 256], [0.83, 0.8, 256], [0.67, 0.67, 128], [0.5, 0.5, 64], [0.4, 0.4, 32], [0.33, 0.33, 16]]
@@ -27,9 +13,6 @@ export function animLadder(format, fps, width) {
27
13
  ...(format === "gif" ? { colors: q } : { quality: q }),
28
14
  }));
29
15
  }
30
- /** Which ladder step to try next after an attempt of `size` bytes at step
31
- * `index` missed the budget: one step per ~1.8x over, at least one, but never
32
- * past the last (smallest) step. Returns null when that step was just tried. */
33
16
  export function nextLadderIndex(index, size, maxBytes, ladderLength) {
34
17
  const last = ladderLength - 1;
35
18
  if (index >= last)
@@ -37,8 +20,6 @@ export function nextLadderIndex(index, size, maxBytes, ladderLength) {
37
20
  const jump = Math.max(1, Math.ceil(Math.log(size / maxBytes) / Math.log(1.8)));
38
21
  return Math.min(last, index + jump);
39
22
  }
40
- /** Encode one attempt. GIF uses a palette built from frame differences
41
- * (stats_mode=diff), which suits screen recordings where little changes. */
42
23
  export function buildAnimArgs(input, output, format, s, clip = {}) {
43
24
  if (!(s.fps > 0) || !Number.isInteger(s.width) || s.width < 16) {
44
25
  throw new ScreencastError("fps must be positive and width an integer of at least 16.");
@@ -51,7 +32,7 @@ export function buildAnimArgs(input, output, format, s, clip = {}) {
51
32
  ...(clip.start ? ["-ss", String(clip.start)] : []),
52
33
  ...(clip.duration ? ["-t", String(clip.duration)] : []),
53
34
  ];
54
- const base = `fps=${s.fps},scale=${s.width}:-1:flags=lanczos`;
35
+ const base = `fps=${s.fps},scale='min(${s.width},iw)':-1:flags=lanczos`;
55
36
  if (format === "gif") {
56
37
  const colors = s.colors ?? 256;
57
38
  return [
@@ -71,4 +52,3 @@ export function buildAnimArgs(input, output, format, s, clip = {}) {
71
52
  output,
72
53
  ];
73
54
  }
74
- //# sourceMappingURL=anim.js.map
@@ -1,8 +1,3 @@
1
- /**
2
- * Export an animated GIF or WebP under a size budget (#124): encode, measure,
3
- * step down the settings ladder, and keep the first attempt that fits (or the
4
- * smallest). Shared by export_gif and pipeline.
5
- */
6
1
  import { basename, dirname, extname, join } from "node:path";
7
2
  import { renameSync, rmSync, statSync } from "node:fs";
8
3
  import { runEditJob, probeDuration } from "./jobs.js";
@@ -13,23 +8,24 @@ export async function exportAnimation(input, output, opts, extra) {
13
8
  const full = await probeDuration(input);
14
9
  const clipSec = opts.duration ?? (full !== null ? full - (opts.start ?? 0) : null);
15
10
  const ladder = animLadder(format, opts.fps ?? DEFAULT_ANIM_FPS, opts.width ?? DEFAULT_ANIM_WIDTH);
16
- // Each attempt is its own sibling file so a later, smaller attempt never
17
- // has to overwrite an earlier one; the winner is renamed onto output.
18
11
  const ext = extname(output);
19
12
  const attemptPath = (i) => join(dirname(output), `${basename(output, ext)}.try${i}${ext}`);
20
13
  const attempts = [];
21
14
  try {
22
15
  let index = 0;
23
16
  while (index !== null && attempts.length < MAX_ATTEMPTS) {
17
+ const settings = ladder[index];
18
+ if (!settings)
19
+ break;
24
20
  const path = attemptPath(attempts.length);
25
21
  const clip = { start: opts.start, duration: opts.duration };
26
- await runEditJob(buildAnimArgs(input, path, format, ladder[index], clip), {
22
+ await runEditJob(buildAnimArgs(input, path, format, settings, clip), {
27
23
  output: path,
28
24
  durationSec: clipSec,
29
25
  extra,
30
26
  });
31
27
  const size = statSync(path).size;
32
- attempts.push({ path, size, settings: ladder[index] });
28
+ attempts.push({ path, size, settings });
33
29
  if (size <= maxBytes)
34
30
  break;
35
31
  index = nextLadderIndex(index, size, maxBytes, ladder.length);
@@ -58,4 +54,3 @@ export async function exportAnimation(input, output, opts, extra) {
58
54
  rmSync(a.path, { force: true });
59
55
  }
60
56
  }
61
- //# sourceMappingURL=animExport.js.map
@@ -1,22 +1,11 @@
1
- /**
2
- * Audio polish (#123): EBU R128 loudness normalization and noise reduction.
3
- *
4
- * Normalization is two-pass loudnorm: the first pass measures the input, the
5
- * second applies a linear gain using those measurements, so the result hits
6
- * the target without the pumping of single-pass (dynamic) mode. Video, when
7
- * present, is stream-copied. Builders and the parser are pure.
8
- */
9
1
  import { extname } from "node:path";
10
2
  import { ScreencastError } from "./errors.js";
11
3
  import { isAudioOnlyPath } from "./media.js";
12
- /** Common delivery targets: YouTube/streaming, spoken-word podcasts, and EBU
13
- * R128 broadcast. */
14
4
  export const LOUDNESS_PRESETS = {
15
5
  youtube: { i: -14, tp: -1, lra: 11 },
16
6
  podcast: { i: -16, tp: -1.5, lra: 11 },
17
7
  broadcast: { i: -23, tp: -1, lra: 7 },
18
8
  };
19
- /** Resolve a preset name or a LUFS number to a full target. Pure. */
20
9
  export function loudnessTarget(target) {
21
10
  if (target === undefined)
22
11
  return LOUDNESS_PRESETS.youtube;
@@ -32,16 +21,15 @@ export function loudnessTarget(target) {
32
21
  return p;
33
22
  }
34
23
  const filterTarget = (t) => `I=${t.i}:TP=${t.tp}:LRA=${t.lra}`;
35
- /** Pass 1: measure the input; the JSON block lands on stderr. */
36
24
  export function buildLoudnessMeasureArgs(input, t) {
37
25
  return ["-hide_banner", "-nostats", "-i", input, "-vn", "-af", `loudnorm=${filterTarget(t)}:print_format=json`, "-f", "null", "-"];
38
26
  }
39
- /** Pull the last loudnorm JSON block out of ffmpeg's stderr. Pure. */
40
27
  export function parseLoudnorm(stderr) {
41
28
  const blocks = stderr.match(/\{[^{}]*"input_i"[^{}]*\}/g);
42
- if (!blocks)
29
+ const lastBlock = blocks?.at(-1);
30
+ if (lastBlock === undefined)
43
31
  throw new ScreencastError("Could not measure loudness (no loudnorm report). Does the file have audio?");
44
- const raw = JSON.parse(blocks[blocks.length - 1]);
32
+ const raw = JSON.parse(lastBlock);
45
33
  const num = (k) => Number(raw[k]);
46
34
  const m = {
47
35
  input_i: num("input_i"),
@@ -56,14 +44,11 @@ export function parseLoudnorm(stderr) {
56
44
  }
57
45
  return m;
58
46
  }
59
- /** Copy the video through, unless the output is audio-only (.wav/.mp3/.m4a),
60
- * where a video map makes the muxer fail (#187). */
61
47
  function keepVideoArgs(output) {
62
48
  return isAudioOnlyPath(output)
63
49
  ? ["-map", "0:a:0", "-vn"]
64
50
  : ["-map", "0:v?", "-map", "0:a:0", "-c:v", "copy"];
65
51
  }
66
- /** Audio encoder for an output path: PCM for .wav, MP3 for .mp3, else AAC. */
67
52
  export function audioCodecFor(output) {
68
53
  switch (extname(output).toLowerCase()) {
69
54
  case ".wav":
@@ -74,8 +59,6 @@ export function audioCodecFor(output) {
74
59
  return ["-c:a", "aac", "-b:a", "192k"];
75
60
  }
76
61
  }
77
- /** Pass 2: apply a linear correction from the measurement. loudnorm works at
78
- * 192 kHz internally, so the output rate is set back to 48 kHz. */
79
62
  export function buildLoudnessApplyArgs(input, output, t, m) {
80
63
  const measured = `measured_I=${m.input_i}:measured_TP=${m.input_tp}:measured_LRA=${m.input_lra}:` +
81
64
  `measured_thresh=${m.input_thresh}:offset=${m.target_offset}`;
@@ -88,10 +71,7 @@ export function buildLoudnessApplyArgs(input, output, t, m) {
88
71
  output,
89
72
  ];
90
73
  }
91
- /** afftdn noise-reduction amount (dB) per strength. */
92
74
  export const DENOISE_NR = { light: 6, medium: 12, strong: 20 };
93
- /** Measure the audio's RMS level in 100 ms windows (printed to stdout), to
94
- * estimate its noise floor. */
95
75
  export function buildNoiseFloorArgs(input) {
96
76
  return [
97
77
  "-hide_banner", "-nostats", "-i", input, "-vn",
@@ -99,26 +79,18 @@ export function buildNoiseFloorArgs(input) {
99
79
  "-f", "null", "-",
100
80
  ];
101
81
  }
102
- /** The noise floor: the 10th-percentile window RMS (dBFS), i.e. the level of
103
- * the quietest moments, which are mostly noise. Null for silence. Pure. */
104
82
  export function parseNoiseFloor(stdout) {
105
83
  const levels = [...stdout.matchAll(/RMS_level=(-?[\d.]+)/g)].map((m) => Number(m[1])).filter(Number.isFinite);
106
84
  if (levels.length === 0)
107
85
  return null;
108
86
  levels.sort((a, b) => a - b);
109
- return levels[Math.floor(levels.length * 0.1)];
87
+ return levels[Math.floor(levels.length * 0.1)] ?? null;
110
88
  }
111
- /** afftdn's `nf` for a measured floor. afftdn only removes what it believes is
112
- * at or under nf, so a fixed value misses most real noise: white noise at
113
- * -25 dBFS was untouched with nf=-25 but cut 12-20 dB with nf set 5 dB above
114
- * the measured floor. Clamped to afftdn's range [-80, -20]. Pure. */
115
89
  export function noiseFloorSetting(floorDb) {
116
90
  if (floorDb === null)
117
91
  return -50;
118
92
  return Math.max(-80, Math.min(-20, Math.round(floorDb + 5)));
119
93
  }
120
- /** Reduce steady background noise (fans, hum, hiss) with afftdn, using the
121
- * floor measured by buildNoiseFloorArgs. Pure. */
122
94
  export function buildDenoiseArgs(input, output, strength = "medium", noiseFloorDb = null) {
123
95
  const nr = DENOISE_NR[strength];
124
96
  if (nr === undefined)
@@ -131,4 +103,3 @@ export function buildDenoiseArgs(input, output, strength = "medium", noiseFloorD
131
103
  output,
132
104
  ];
133
105
  }
134
- //# sourceMappingURL=audio.js.map
@@ -1,21 +1,5 @@
1
- /**
2
- * DirectShow audio device discovery for system-audio capture.
3
- *
4
- * gdigrab is video-only, so capturing what is playing on the machine needs a
5
- * separate dshow audio input. Windows has no native loopback device, so system
6
- * audio requires a virtual-audio device (Stereo Mix, or a driver such as
7
- * screen-capture-recorder's virtual-audio-capturer or VB-CABLE). This module
8
- * enumerates the dshow audio devices ffmpeg can see and picks a loopback one.
9
- *
10
- * Microphone capture is intentionally not supported.
11
- *
12
- * The parsing and selection helpers are pure (string in, names out) so they are
13
- * unit-tested without ffmpeg or Windows present.
14
- */
15
1
  import { ScreencastError } from "./errors.js";
16
2
  import { requireFfmpeg, runCapture } from "./ffmpeg.js";
17
- /** Names that identify a system-audio loopback device, matched case-insensitively
18
- * as a substring. */
19
3
  export const LOOPBACK_HINTS = [
20
4
  "virtual-audio-capturer",
21
5
  "stereo mix",
@@ -29,11 +13,6 @@ export const NO_LOOPBACK_HINT = "System audio capture needs a virtual-audio loop
29
13
  "a loopback driver (for example screen-capture-recorder's " +
30
14
  "virtual-audio-capturer, or VB-CABLE). Then pass its name as `device`, or run " +
31
15
  "list_audio_devices to see what is available. Microphone capture is not supported.";
32
- /**
33
- * Parse the stderr of `ffmpeg -list_devices true -f dshow -i dummy` into the
34
- * list of audio device names. Handles both the sectioned layout (a "DirectShow
35
- * audio devices" header) and the inline "(audio)" tag used by newer ffmpeg.
36
- */
37
16
  export function parseDshowAudioDevices(stderr) {
38
17
  const names = [];
39
18
  let section = null;
@@ -46,7 +25,6 @@ export function parseDshowAudioDevices(stderr) {
46
25
  section = "video";
47
26
  continue;
48
27
  }
49
- // The "Alternative name" lines also carry a quoted string; skip them.
50
28
  if (/Alternative name/i.test(line))
51
29
  continue;
52
30
  const quoted = line.match(/"([^"]+)"/);
@@ -55,16 +33,11 @@ export function parseDshowAudioDevices(stderr) {
55
33
  const inlineAudio = /\(audio\)/i.test(line);
56
34
  const inlineVideo = /\(video\)/i.test(line);
57
35
  const isAudio = inlineAudio || (!inlineVideo && section === "audio");
58
- if (isAudio)
36
+ if (isAudio && quoted[1])
59
37
  names.push(quoted[1]);
60
38
  }
61
39
  return [...new Set(names)];
62
40
  }
63
- /**
64
- * Choose a loopback device. With an explicit name, return it only if ffmpeg
65
- * actually lists it (so a typo fails loudly). Otherwise return the first device
66
- * whose name matches a known loopback hint, or null when none qualifies.
67
- */
68
41
  export function pickLoopbackDevice(devices, explicit) {
69
42
  if (explicit && explicit.trim().length > 0) {
70
43
  return devices.includes(explicit) ? explicit : null;
@@ -72,24 +45,11 @@ export function pickLoopbackDevice(devices, explicit) {
72
45
  const lower = (s) => s.toLowerCase();
73
46
  return (devices.find((d) => LOOPBACK_HINTS.some((h) => lower(d).includes(h))) ?? null);
74
47
  }
75
- /**
76
- * Device enumeration must not block a recording start for long. The dshow
77
- * `-list_devices` probe hangs on some setups (a misbehaving audio driver, no
78
- * audio hardware), so it is capped well below the normal ffmpeg job timeout.
79
- */
80
48
  export const ENUM_TIMEOUT_MS = 12_000;
81
49
  const ENUM_FAILED_HINT = "Enumerating DirectShow audio devices timed out or failed - usually a " +
82
50
  "misbehaving audio driver, or no audio device present. Record without system " +
83
51
  "audio, or fix the device, then retry. " + NO_LOOPBACK_HINT;
84
- // A successful enumeration is cached for the process lifetime so an audio
85
- // recording does not re-pay the cost (or risk the hang) on every start. The
86
- // list_audio_devices tool forces a refresh, so a device enabled mid-session is
87
- // still discoverable.
88
52
  let cachedDevices = null;
89
- /** Run ffmpeg's device list and return the audio device names. ffmpeg exits
90
- * non-zero for the dummy input by design, so the exit code is ignored and the
91
- * names are read from stderr. A timeout or spawn failure becomes a clear,
92
- * actionable error rather than the raw "ffmpeg timed out" text. */
93
53
  export async function listDshowAudioDevices(forceRefresh = false) {
94
54
  if (!forceRefresh && cachedDevices)
95
55
  return cachedDevices;
@@ -99,21 +59,15 @@ export async function listDshowAudioDevices(forceRefresh = false) {
99
59
  res = await runCapture(ffmpeg, ["-hide_banner", "-list_devices", "true", "-f", "dshow", "-i", "dummy"], ENUM_TIMEOUT_MS, { closeStdin: true });
100
60
  }
101
61
  catch (err) {
102
- // runCapture rejects on timeout (and on spawn error); ffmpeg's by-design
103
- // non-zero exit for the dummy input resolves instead, so reaching here is a
104
- // genuine failure, not the expected exit code.
105
62
  throw new ScreencastError(`Could not enumerate audio devices (${err.message}).`, ENUM_FAILED_HINT);
106
63
  }
107
64
  const devices = parseDshowAudioDevices(res.stderr);
108
65
  cachedDevices = devices;
109
66
  return devices;
110
67
  }
111
- /** Drop the cached device list (test seam; also lets a caller force a re-probe). */
112
68
  export function clearAudioDeviceCache() {
113
69
  cachedDevices = null;
114
70
  }
115
- /** Resolve the loopback device to use, throwing a clear, actionable error when
116
- * an explicit name is not present or no loopback device exists. */
117
71
  export async function resolveLoopbackDevice(explicit) {
118
72
  const devices = await listDshowAudioDevices();
119
73
  const picked = pickLoopbackDevice(devices, explicit);
@@ -125,4 +79,3 @@ export async function resolveLoopbackDevice(explicit) {
125
79
  }
126
80
  throw new ScreencastError("No system-audio loopback device found.", NO_LOOPBACK_HINT);
127
81
  }
128
- //# sourceMappingURL=audioDevices.js.map
@@ -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
+ ];