@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,42 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import { RootsListChangedNotificationSchema } from "@modelcontextprotocol/sdk/types.js";
3
+ import { setClientRoots } from "./paths.js";
4
+ export function rootDirs(roots) {
5
+ const dirs = [];
6
+ for (const { uri } of roots) {
7
+ if (!uri.startsWith("file:"))
8
+ continue;
9
+ try {
10
+ dirs.push(fileURLToPath(uri));
11
+ }
12
+ catch {
13
+ }
14
+ }
15
+ return dirs;
16
+ }
17
+ export function trackClientRoots(server) {
18
+ const low = server.server;
19
+ const refresh = async (initial) => {
20
+ if (!low.getClientCapabilities()?.roots) {
21
+ setClientRoots(null);
22
+ return;
23
+ }
24
+ if (initial)
25
+ setClientRoots("pending");
26
+ try {
27
+ const { roots } = await low.listRoots();
28
+ setClientRoots(rootDirs(roots));
29
+ }
30
+ catch (err) {
31
+ if (initial)
32
+ setClientRoots(null);
33
+ process.stderr.write(`roots/list failed: ${err instanceof Error ? err.message : String(err)}\n`);
34
+ }
35
+ };
36
+ const previous = low.oninitialized;
37
+ low.oninitialized = () => {
38
+ previous?.();
39
+ void refresh(true);
40
+ };
41
+ low.setNotificationHandler(RootsListChangedNotificationSchema, () => refresh(false));
42
+ }
@@ -1,23 +1,9 @@
1
- /**
2
- * Recording session registry.
3
- *
4
- * Sessions are tracked both in memory (with a live child-process handle for
5
- * graceful stop) and on disk (sessions.json) so that:
6
- * - stop/list/get survive within a server run, and
7
- * - a crash leaves a durable record the next boot can reconcile (orphan
8
- * reaping), ensuring no ffmpeg child silently outlives the server.
9
- *
10
- * The child handle is intentionally NOT persisted; only the pid is. Reaping
11
- * logic (classifyOrphan) is pure so it is unit-tested without real processes.
12
- */
13
1
  import { spawnSync } from "node:child_process";
14
- import { readFileSync, writeFileSync, renameSync, existsSync, copyFileSync, openSync, closeSync, unlinkSync, statSync, } from "node:fs";
2
+ import { readFileSync, writeFileSync, renameSync, existsSync, copyFileSync, openSync, closeSync, unlinkSync, statSync, linkSync, } from "node:fs";
3
+ import { basename } from "node:path";
4
+ import { ScreencastError } from "./errors.js";
15
5
  import { WGC_WINDOW_CLOSED_EXIT } from "./wgc.js";
16
- /** Cap on retained finished records, so the registry does not grow without
17
- * bound. Active ("recording") records are always kept. */
18
6
  export const MAX_FINISHED_RECORDS = 100;
19
- /** Decide what an in-progress session becomes at boot, given liveness.
20
- * Pure: a still-alive pid is an orphan to be reaped; a dead one simply ended. */
21
7
  export function classifyOrphan(record, alive) {
22
8
  if (record.status !== "recording") {
23
9
  return { status: record.status, reaped: false };
@@ -26,22 +12,45 @@ export function classifyOrphan(record, alive) {
26
12
  ? { status: "orphaned", reaped: true }
27
13
  : { status: "stopped", reaped: false };
28
14
  }
29
- /**
30
- * True if a "recording" record is owned by a DIFFERENT, still-live server
31
- * instance. Such a record must be left alone: another running server is actively
32
- * recording it, so reaping would kill that server's live capture. Pure so the
33
- * ownership rule is unit-tested without real processes.
34
- *
35
- * Records with no `serverPid` (older registries) are not treated as foreign, so
36
- * genuine orphans there still get reaped.
37
- */
38
15
  export function isForeignLiveRecording(record, currentServerPid, ownerAlive) {
39
16
  return (record.status === "recording" &&
40
17
  record.serverPid !== undefined &&
41
18
  record.serverPid !== currentServerPid &&
42
19
  ownerAlive);
43
20
  }
44
- /** True if a pid exists. `process.kill(pid, 0)` throws ESRCH when it does not. */
21
+ export function serverIdentity() {
22
+ return {
23
+ serverPid: process.pid,
24
+ serverStartedAt: new Date(Date.now() - process.uptime() * 1000).toISOString(),
25
+ serverImage: basename(process.execPath).toLowerCase(),
26
+ };
27
+ }
28
+ export const OWNER_START_SLACK_MS = 5_000;
29
+ export function isSameServer(record, running) {
30
+ if (!running)
31
+ return true;
32
+ if (record.serverImage && running.image.toLowerCase() !== record.serverImage.toLowerCase())
33
+ return false;
34
+ const ref = Date.parse(record.serverStartedAt ?? record.startedAt);
35
+ return !(Number.isFinite(ref) && running.startMs > ref + OWNER_START_SLACK_MS);
36
+ }
37
+ export function parseProcessInfo(stdout) {
38
+ const m = /^(.+)\|(\d+)\s*$/m.exec(stdout.trim());
39
+ return m?.[1] && m[2] ? { image: m[1].trim(), startMs: Number(m[2]) } : null;
40
+ }
41
+ export function processInfo(pid) {
42
+ if (process.platform !== "win32" || !Number.isInteger(pid) || pid <= 0)
43
+ return null;
44
+ const script = `$p = Get-CimInstance Win32_Process -Filter "ProcessId=${pid}"; ` +
45
+ `if ($p) { "{0}|{1}" -f $p.Name, ([DateTimeOffset]$p.CreationDate).ToUnixTimeMilliseconds() }`;
46
+ const res = spawnSync("powershell", ["-NoProfile", "-NonInteractive", "-Command", script], {
47
+ encoding: "utf8",
48
+ windowsHide: true,
49
+ timeout: 10_000,
50
+ killSignal: "SIGKILL",
51
+ });
52
+ return res.status === 0 && res.stdout ? parseProcessInfo(res.stdout) : null;
53
+ }
45
54
  export function isAlive(pid) {
46
55
  if (pid === null || !Number.isInteger(pid) || pid <= 0)
47
56
  return false;
@@ -53,19 +62,13 @@ export function isAlive(pid) {
53
62
  return err.code === "EPERM";
54
63
  }
55
64
  }
56
- /** The process image a record's pid should belong to: what it stored, else
57
- * what its backend spawns (the wgc recorder runs under node, #182). Pure. */
58
65
  export function expectedImage(record) {
59
66
  return record.processImage ?? (record.backend === "wgc" ? "node.exe" : "ffmpeg.exe");
60
67
  }
61
- /** True when a `tasklist /FO CSV` line names the given image. Pure. */
62
68
  export function tasklistHasImage(stdout, image) {
63
69
  const first = stdout.split(/\r?\n/)[0] ?? "";
64
70
  return first.toLowerCase().startsWith(`"${image.toLowerCase()}"`);
65
71
  }
66
- /** On Windows, confirm a pid is still the expected recorder image before
67
- * killing it, so a recycled pid belonging to an unrelated process is never
68
- * terminated. */
69
72
  export function isRecorderProcess(pid, image) {
70
73
  if (pid === null || process.platform !== "win32")
71
74
  return false;
@@ -74,13 +77,9 @@ export function isRecorderProcess(pid, image) {
74
77
  return false;
75
78
  return tasklistHasImage(res.stdout, image);
76
79
  }
77
- /** isRecorderProcess for an ffmpeg.exe. */
78
80
  export function isFfmpegProcess(pid) {
79
81
  return isRecorderProcess(pid, "ffmpeg.exe");
80
82
  }
81
- /** Classify a recorder exit nobody asked for. Non-zero is a crash; the wgc
82
- * window-closed code is its own reason; a clean exit is the maxDurationSec cap
83
- * only once the cap could actually have been reached (#240). Pure. */
84
83
  export function classifyUnrequestedExit(opts) {
85
84
  const { code, backend, maxDurationSec, elapsedMs } = opts;
86
85
  if (backend === "wgc" && code === WGC_WINDOW_CLOSED_EXIT)
@@ -90,7 +89,6 @@ export function classifyUnrequestedExit(opts) {
90
89
  const capReached = maxDurationSec > 0 && elapsedMs >= maxDurationSec * 1000 - 2000;
91
90
  return { status: "stopped", endReason: capReached ? "max_duration" : "stopped" };
92
91
  }
93
- /** Forcefully terminate a pid tree (used only for orphan reaping). */
94
92
  export function killPid(pid) {
95
93
  if (process.platform === "win32") {
96
94
  spawnSync("taskkill", ["/PID", String(pid), "/T", "/F"], {
@@ -103,12 +101,9 @@ export function killPid(pid) {
103
101
  process.kill(pid, "SIGKILL");
104
102
  }
105
103
  catch {
106
- /* already gone */
107
104
  }
108
105
  }
109
106
  }
110
- /** Keep every active recording plus the most recent MAX_FINISHED_RECORDS
111
- * finished records (newest first), so the registry stays bounded. Pure. */
112
107
  export function pruneRecords(records) {
113
108
  const active = records.filter((r) => r.status === "recording");
114
109
  const finished = records
@@ -117,16 +112,8 @@ export function pruneRecords(records) {
117
112
  .slice(0, MAX_FINISHED_RECORDS);
118
113
  return [...active, ...finished];
119
114
  }
120
- /** A lock older than this is assumed abandoned even if its pid looks alive
121
- * (pids are recycled). A read-merge-write takes milliseconds. */
122
- export const LOCK_STALE_MS = 10_000;
123
- /** Give up waiting for the lock after this long and write anyway: a stuck
124
- * lock must not stop a recording from being registered. */
125
- export const LOCK_WAIT_MS = 2_000;
126
- /** True when a registry lock can be taken over: it is older than
127
- * LOCK_STALE_MS, or it names a holder pid that is no longer alive. A lock with
128
- * no readable pid (just created, not yet written) is judged by age alone.
129
- * Pure so the rule is unit-tested. */
115
+ export const LOCK_STALE_MS = 30_000;
116
+ export const LOCK_WAIT_MS = 15_000;
130
117
  export function isLockStale(holder, now, holderAlive) {
131
118
  if (!holder || typeof holder.at !== "number")
132
119
  return true;
@@ -134,13 +121,9 @@ export function isLockStale(holder, now, holderAlive) {
134
121
  return true;
135
122
  return typeof holder.pid === "number" && !holderAlive;
136
123
  }
137
- /** Synchronous sleep for the lock retry loop (persist() is synchronous). */
138
124
  function sleepSync(ms) {
139
125
  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
140
126
  }
141
- /** renameSync, retried briefly on Windows sharing errors. A rename over a file
142
- * that another process (an unlocked reader, antivirus, the search indexer)
143
- * momentarily holds open fails with EPERM/EBUSY rather than waiting. */
144
127
  function renameWithRetry(from, to) {
145
128
  const deadline = Date.now() + 1_000;
146
129
  for (;;) {
@@ -156,106 +139,113 @@ function renameWithRetry(from, to) {
156
139
  }
157
140
  }
158
141
  }
159
- /** Run `fn` holding an exclusive lockfile next to the registry (#55), so two
160
- * server instances cannot interleave a read-merge-write. The lock is an
161
- * O_EXCL-created file holding the owner's pid and a timestamp; a stale lock
162
- * (dead owner or older than LOCK_STALE_MS) is taken over. */
163
- function withRegistryLock(registry, fn) {
142
+ export function breakStaleLock(lock, raw) {
143
+ const aside = `${lock}.${process.pid}.${Date.now()}.stale`;
144
+ try {
145
+ renameSync(lock, aside);
146
+ }
147
+ catch {
148
+ return false;
149
+ }
150
+ let removed = true;
151
+ try {
152
+ if (readFileSync(aside, "utf8") !== raw) {
153
+ removed = false;
154
+ linkSync(aside, lock);
155
+ }
156
+ }
157
+ catch {
158
+ }
159
+ try {
160
+ unlinkSync(aside);
161
+ }
162
+ catch {
163
+ }
164
+ return removed;
165
+ }
166
+ export function withRegistryLock(registry, fn, waitMs = LOCK_WAIT_MS) {
164
167
  const lock = `${registry}.lock`;
165
- const deadline = Date.now() + LOCK_WAIT_MS;
166
- let held = false;
167
- while (!held) {
168
+ const deadline = Date.now() + waitMs;
169
+ let holderPid;
170
+ let mine;
171
+ for (let attempt = 0;; attempt++) {
168
172
  try {
169
173
  const fd = openSync(lock, "wx");
170
- writeFileSync(fd, JSON.stringify({ pid: process.pid, at: Date.now() }));
174
+ mine = JSON.stringify({ pid: process.pid, at: Date.now(), nonce: Math.random().toString(36).slice(2) });
175
+ writeFileSync(fd, mine);
171
176
  closeSync(fd);
172
- held = true;
177
+ break;
173
178
  }
174
179
  catch (err) {
175
180
  const code = err.code;
176
- if (Date.now() >= deadline) {
177
- process.stderr.write(`Session registry lock ${lock} is busy; writing without it.\n`);
178
- break;
179
- }
180
- // On Windows a lock that its holder just deleted, while another process
181
- // still had it open, lingers as "delete pending": creating it again fails
182
- // with EPERM/EACCES/EBUSY, not EEXIST. That means busy, so wait.
183
- if (code === "EPERM" || code === "EACCES" || code === "EBUSY") {
184
- sleepSync(5 + Math.random() * 10);
185
- continue;
181
+ const busy = code === "EEXIST" || code === "EPERM" || code === "EACCES" || code === "EBUSY";
182
+ if (!busy) {
183
+ throw new ScreencastError(`Could not lock the session registry (${lock}): ${err.message}`);
186
184
  }
187
- if (code !== "EEXIST")
188
- break; // e.g. a missing or read-only dir: write unlocked
189
- let holder;
190
- try {
191
- holder = JSON.parse(readFileSync(lock, "utf8"));
192
- }
193
- catch {
194
- // Unreadable or half-written: judge it by the file's age instead.
185
+ if (code === "EEXIST") {
186
+ let seen;
195
187
  try {
196
- holder = { at: statSync(lock).mtimeMs };
188
+ const raw = readFileSync(lock, "utf8");
189
+ let holder;
190
+ try {
191
+ holder = JSON.parse(raw);
192
+ }
193
+ catch {
194
+ holder = { at: statSync(lock).mtimeMs };
195
+ }
196
+ seen = { raw, holder };
197
197
  }
198
198
  catch {
199
- continue; // the holder just released it; retry at once
200
- }
201
- }
202
- if (isLockStale(holder, Date.now(), isAlive(holder?.pid ?? null))) {
203
- try {
204
- unlinkSync(lock);
199
+ seen = null;
205
200
  }
206
- catch {
207
- /* another instance took it over first */
201
+ if (seen) {
202
+ holderPid = seen.holder?.pid;
203
+ if (isLockStale(seen.holder, Date.now(), isAlive(seen.holder?.pid ?? null)) &&
204
+ breakStaleLock(lock, seen.raw)) {
205
+ continue;
206
+ }
208
207
  }
209
- continue;
210
208
  }
211
- sleepSync(10 + Math.random() * 15);
209
+ if (Date.now() >= deadline) {
210
+ throw new ScreencastError(`The session registry is busy: could not take ${lock} within ${waitMs / 1000} s` +
211
+ `${holderPid !== undefined ? ` (held by process ${holderPid})` : ""}. Nothing was written.`, "Another screencast-mcp server is writing to the same registry. Retry; if no other server is running, delete the .lock file.");
212
+ }
213
+ sleepSync(Math.min(50, 2 ** Math.min(attempt, 6)) * (0.5 + Math.random()));
212
214
  }
213
215
  }
214
216
  try {
215
217
  return fn();
216
218
  }
217
219
  finally {
218
- if (held) {
219
- try {
220
+ try {
221
+ if (readFileSync(lock, "utf8") === mine)
220
222
  unlinkSync(lock);
221
- }
222
- catch {
223
- /* already removed */
224
- }
223
+ }
224
+ catch {
225
225
  }
226
226
  }
227
227
  }
228
228
  export class SessionStore {
229
229
  path;
230
+ lockWaitMs;
230
231
  records = new Map();
231
- /** Ids this instance created or changed since its last write. Only these
232
- * override the on-disk copy; every other record is taken from disk, so a
233
- * stale copy loaded at boot never undoes another instance's update (#55). */
234
- dirty = new Set();
232
+ pending = new Map();
233
+ seen = null;
235
234
  children = new Map();
236
- /** Ids with a deliberate stop in flight, so the child's exit handler does not
237
- * misread the clean exit as the maxDurationSec cap firing. */
238
235
  stopping = new Set();
239
- /** Called after every write, e.g. to tell MCP clients the session
240
- * resources changed (#126). */
241
236
  listeners = [];
242
- constructor(path) {
237
+ constructor(path, lockWaitMs = LOCK_WAIT_MS) {
243
238
  this.path = path;
239
+ this.lockWaitMs = lockWaitMs;
244
240
  }
245
- /** Run `cb` after each registry write. A throwing listener is ignored. */
246
241
  onChange(cb) {
247
242
  this.listeners.push(cb);
248
243
  }
249
- /** Read the on-disk records, tolerating a missing or corrupt file. A corrupt
250
- * registry is copied to .bak for inspection instead of silently discarded -
251
- * it may hold "recording" entries whose ffmpeg would otherwise never be
252
- * reaped. */
253
244
  readDisk() {
254
245
  if (!existsSync(this.path))
255
246
  return new Map();
256
247
  try {
257
- const data = JSON.parse(readFileSync(this.path, "utf8"));
258
- return new Map(data.map((r) => [r.id, r]));
248
+ return this.parseDisk();
259
249
  }
260
250
  catch {
261
251
  try {
@@ -263,69 +253,113 @@ export class SessionStore {
263
253
  process.stderr.write(`Session registry was unreadable; saved a copy to ${this.path}.bak and starting fresh.\n`);
264
254
  }
265
255
  catch {
266
- /* best effort */
267
256
  }
268
257
  return new Map();
269
258
  }
270
259
  }
260
+ parseDisk() {
261
+ const data = JSON.parse(readFileSync(this.path, "utf8"));
262
+ return new Map(data.map((r) => [r.id, r]));
263
+ }
264
+ signature() {
265
+ try {
266
+ const s = statSync(this.path, { bigint: true });
267
+ return `${s.ino}:${s.size}:${s.mtimeNs}`;
268
+ }
269
+ catch {
270
+ return null;
271
+ }
272
+ }
273
+ overlay(disk) {
274
+ for (const [id, patch] of this.pending) {
275
+ const base = disk.get(id) ?? this.records.get(id);
276
+ if (base)
277
+ disk.set(id, { ...base, ...patch });
278
+ }
279
+ return disk;
280
+ }
281
+ refresh() {
282
+ const sig = this.signature();
283
+ if (sig === this.seen)
284
+ return;
285
+ let disk;
286
+ try {
287
+ disk = sig === null ? new Map() : this.parseDisk();
288
+ }
289
+ catch {
290
+ return;
291
+ }
292
+ this.seen = sig;
293
+ this.records = new Map(pruneRecords([...this.overlay(disk).values()]).map((r) => [r.id, r]));
294
+ }
271
295
  load() {
272
- // Read under the lock too: on Windows a writer's rename over the file
273
- // fails while any other process has it open for reading.
274
- const disk = withRegistryLock(this.path, () => this.readDisk());
275
- this.records = new Map(pruneRecords([...disk.values()]).map((r) => [r.id, r]));
296
+ const read = () => {
297
+ const disk = this.readDisk();
298
+ this.seen = this.signature();
299
+ return disk;
300
+ };
301
+ let disk;
302
+ try {
303
+ disk = withRegistryLock(this.path, read, this.lockWaitMs);
304
+ }
305
+ catch (err) {
306
+ process.stderr.write(`${err.message} Reading the session registry without the lock.\n`);
307
+ disk = read();
308
+ }
309
+ this.records = new Map(pruneRecords([...this.overlay(disk).values()]).map((r) => [r.id, r]));
276
310
  }
277
311
  persist() {
278
- // Under the registry lock: re-read the file, overlay only the records this
279
- // instance changed (anything else on disk is newer than our copy), prune,
280
- // and write atomically (temp + rename) so a kill mid-write cannot corrupt
281
- // the file. Our view is then refreshed from what was written.
282
312
  withRegistryLock(this.path, () => {
283
- const merged = this.readDisk();
284
- for (const id of this.dirty) {
285
- const rec = this.records.get(id);
286
- if (rec)
287
- merged.set(id, rec);
288
- }
289
- const pruned = pruneRecords([...merged.values()]);
313
+ const pruned = pruneRecords([...this.overlay(this.readDisk()).values()]);
290
314
  const tmp = `${this.path}.${process.pid}.tmp`;
291
315
  writeFileSync(tmp, JSON.stringify(pruned, null, 2));
292
316
  renameWithRetry(tmp, this.path);
317
+ this.seen = this.signature();
293
318
  this.records = new Map(pruned.map((r) => [r.id, r]));
294
- this.dirty.clear();
295
- });
319
+ this.pending.clear();
320
+ }, this.lockWaitMs);
296
321
  for (const cb of this.listeners) {
297
322
  try {
298
323
  cb();
299
324
  }
300
325
  catch {
301
- /* a listener must not break a registry write */
302
326
  }
303
327
  }
304
328
  }
305
329
  create(record) {
306
330
  this.records.set(record.id, record);
307
- this.dirty.add(record.id);
308
- this.persist();
331
+ this.pending.set(record.id, record);
332
+ try {
333
+ this.persist();
334
+ }
335
+ catch (err) {
336
+ this.records.delete(record.id);
337
+ this.pending.delete(record.id);
338
+ throw err;
339
+ }
309
340
  }
310
341
  get(id) {
342
+ this.refresh();
311
343
  return this.records.get(id);
312
344
  }
313
345
  list() {
346
+ this.refresh();
314
347
  return [...this.records.values()].sort((a, b) => a.startedAt < b.startedAt ? 1 : -1);
315
348
  }
316
349
  update(id, patch) {
317
- const cur = this.records.get(id);
350
+ let cur = this.records.get(id);
351
+ if (!cur) {
352
+ this.refresh();
353
+ cur = this.records.get(id);
354
+ }
318
355
  if (!cur)
319
356
  return undefined;
320
357
  const next = { ...cur, ...patch };
321
358
  this.records.set(id, next);
322
- this.dirty.add(id);
359
+ this.pending.set(id, { ...this.pending.get(id), ...patch });
323
360
  this.persist();
324
361
  return this.records.get(id) ?? next;
325
362
  }
326
- /** update() for event handlers: a failed registry write (a full disk, a
327
- * locked sessions.json) is logged instead of thrown, because a throw from a
328
- * child-process or finalizer callback would crash the server (#207). */
329
363
  tryUpdate(id, patch) {
330
364
  try {
331
365
  return this.update(id, patch);
@@ -344,7 +378,6 @@ export class SessionStore {
344
378
  detachChild(id) {
345
379
  this.children.delete(id);
346
380
  }
347
- /** Ids of recordings this instance owns a live child handle for. */
348
381
  activeIds() {
349
382
  return [...this.children.keys()].filter((id) => this.records.get(id)?.status === "recording");
350
383
  }
@@ -357,19 +390,22 @@ export class SessionStore {
357
390
  clearStopping(id) {
358
391
  this.stopping.delete(id);
359
392
  }
360
- /**
361
- * Reconcile persisted "recording" sessions at boot: kill any ffmpeg child
362
- * that outlived the previous server, and mark records accordingly. Returns
363
- * the ids that were reaped.
364
- */
365
393
  reapOrphans() {
394
+ this.refresh();
366
395
  const reaped = [];
396
+ const owners = new Map();
397
+ const ownerAlive = (record) => {
398
+ const pid = record.serverPid;
399
+ if (pid === undefined || pid === process.pid || !isAlive(pid))
400
+ return false;
401
+ if (!owners.has(pid))
402
+ owners.set(pid, processInfo(pid));
403
+ return isSameServer(record, owners.get(pid) ?? null);
404
+ };
367
405
  for (const record of this.records.values()) {
368
406
  if (record.status !== "recording")
369
407
  continue;
370
- // Never reap a recording owned by another still-live server instance:
371
- // that would kill its active capture. Leave the record untouched.
372
- if (isForeignLiveRecording(record, process.pid, isAlive(record.serverPid ?? null))) {
408
+ if (isForeignLiveRecording(record, process.pid, ownerAlive(record))) {
373
409
  continue;
374
410
  }
375
411
  const alive = isAlive(record.pid);
@@ -379,19 +415,18 @@ export class SessionStore {
379
415
  killPid(record.pid);
380
416
  reaped.push(record.id);
381
417
  }
382
- this.dirty.add(record.id);
383
- this.records.set(record.id, {
384
- ...record,
418
+ const patch = {
385
419
  status: verdict.status,
386
- stoppedAt: record.stoppedAt ?? new Date().toISOString(),
387
- error: verdict.status === "orphaned"
388
- ? "Reaped on server restart (recording was interrupted)."
389
- : record.error,
390
- });
420
+ ...(record.stoppedAt ? {} : { stoppedAt: new Date().toISOString() }),
421
+ ...(verdict.status === "orphaned"
422
+ ? { error: "Reaped on server restart (recording was interrupted)." }
423
+ : {}),
424
+ };
425
+ this.records.set(record.id, { ...record, ...patch });
426
+ this.pending.set(record.id, { ...this.pending.get(record.id), ...patch });
391
427
  }
392
428
  if (this.records.size > 0)
393
429
  this.persist();
394
430
  return reaped;
395
431
  }
396
432
  }
397
- //# sourceMappingURL=sessions.js.map
@@ -1,25 +1,14 @@
1
- /**
2
- * Contact sheets and poster frames (#115).
3
- *
4
- * A contact sheet tiles N timestamped frames of a video into one image, so an
5
- * agent can see a whole recording in a single image read. Each tile is grabbed
6
- * at its own timestamp (accurate seek), scaled to a fixed width, and labelled;
7
- * a final pass tiles them. All builders here are pure.
8
- */
9
1
  import { ScreencastError } from "./errors.js";
10
2
  import { escapeFilterPath } from "./fonts.js";
11
3
  import { stillOutput } from "./paths.js";
12
4
  export const DEFAULT_SHEET_COUNT = 12;
13
5
  export const MAX_SHEET_COUNT = 48;
14
6
  export const DEFAULT_TILE_WIDTH = 320;
15
- /** `count` timestamps spread evenly across the video, each in the middle of
16
- * its slice (so the first is not a black opening frame). Millisecond precision. */
17
7
  export function evenTimes(durationSec, count) {
18
8
  if (!(durationSec > 0))
19
9
  throw new ScreencastError("Could not read the video's duration.");
20
10
  return Array.from({ length: count }, (_, i) => Math.round(((i + 0.5) * durationSec) / count * 1000) / 1000);
21
11
  }
22
- /** `m:ss.s`, or `h:mm:ss` from an hour up. */
23
12
  export function formatTimecode(sec) {
24
13
  const s = Math.max(0, sec);
25
14
  const h = Math.floor(s / 3600);
@@ -29,15 +18,11 @@ export function formatTimecode(sec) {
29
18
  return `${h}:${String(m).padStart(2, "0")}:${String(Math.floor(rest)).padStart(2, "0")}`;
30
19
  return `${m}:${rest.toFixed(1).padStart(4, "0")}`;
31
20
  }
32
- /** Grid for `count` tiles: `columns` if given, else one row for up to four
33
- * tiles and roughly square beyond that. */
34
21
  export function sheetGrid(count, columns) {
35
22
  const auto = count <= 4 ? count : Math.ceil(Math.sqrt(count));
36
23
  const c = Math.max(1, Math.min(count, columns ?? auto));
37
24
  return { columns: c, rows: Math.ceil(count / c) };
38
25
  }
39
- /** Grab one labelled tile: seek to `timeSec`, scale to `tileWidth`, and draw
40
- * the label (read from `labelFile`, so no text escaping is needed). */
41
26
  export function buildTileArgs(input, timeSec, output, tileWidth, fontFile, labelFile) {
42
27
  if (!Number.isInteger(tileWidth) || tileWidth < 64) {
43
28
  throw new ScreencastError("tileWidth must be an integer of at least 64.");
@@ -52,7 +37,6 @@ export function buildTileArgs(input, timeSec, output, tileWidth, fontFile, label
52
37
  ...stillOutput(output),
53
38
  ];
54
39
  }
55
- /** Tile a numbered PNG sequence into one image; unused cells stay black. */
56
40
  export function buildSheetArgs(tilePattern, grid, output) {
57
41
  return [
58
42
  "-y", "-v", "error", "-framerate", "1", "-i", tilePattern,
@@ -61,8 +45,6 @@ export function buildSheetArgs(tilePattern, grid, output) {
61
45
  ...stillOutput(output),
62
46
  ];
63
47
  }
64
- /** A single representative poster frame: sample 30 candidates across the
65
- * whole video and let ffmpeg's `thumbnail` filter pick the most typical. */
66
48
  export function buildPosterArgs(input, durationSec, output, width) {
67
49
  if (!(durationSec > 0))
68
50
  throw new ScreencastError("Could not read the video's duration.");
@@ -75,4 +57,3 @@ export function buildPosterArgs(input, durationSec, output, width) {
75
57
  ...stillOutput(output),
76
58
  ];
77
59
  }
78
- //# sourceMappingURL=sheet.js.map