@tmhs/screencast-mcp 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +34 -0
- package/README.md +212 -0
- package/dist/context.d.ts +5 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +13 -0
- package/dist/context.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/concat.d.ts +3 -0
- package/dist/tools/concat.d.ts.map +1 -0
- package/dist/tools/concat.js +42 -0
- package/dist/tools/concat.js.map +1 -0
- package/dist/tools/convert.d.ts +3 -0
- package/dist/tools/convert.d.ts.map +1 -0
- package/dist/tools/convert.js +38 -0
- package/dist/tools/convert.js.map +1 -0
- package/dist/tools/getMediaInfo.d.ts +3 -0
- package/dist/tools/getMediaInfo.d.ts.map +1 -0
- package/dist/tools/getMediaInfo.js +28 -0
- package/dist/tools/getMediaInfo.js.map +1 -0
- package/dist/tools/getSession.d.ts +3 -0
- package/dist/tools/getSession.d.ts.map +1 -0
- package/dist/tools/getSession.js +28 -0
- package/dist/tools/getSession.js.map +1 -0
- package/dist/tools/listSessions.d.ts +3 -0
- package/dist/tools/listSessions.d.ts.map +1 -0
- package/dist/tools/listSessions.js +18 -0
- package/dist/tools/listSessions.js.map +1 -0
- package/dist/tools/sampleFrames.d.ts +3 -0
- package/dist/tools/sampleFrames.d.ts.map +1 -0
- package/dist/tools/sampleFrames.js +69 -0
- package/dist/tools/sampleFrames.js.map +1 -0
- package/dist/tools/screenshot.d.ts +3 -0
- package/dist/tools/screenshot.d.ts.map +1 -0
- package/dist/tools/screenshot.js +39 -0
- package/dist/tools/screenshot.js.map +1 -0
- package/dist/tools/startRecording.d.ts +3 -0
- package/dist/tools/startRecording.d.ts.map +1 -0
- package/dist/tools/startRecording.js +107 -0
- package/dist/tools/startRecording.js.map +1 -0
- package/dist/tools/stopRecording.d.ts +3 -0
- package/dist/tools/stopRecording.d.ts.map +1 -0
- package/dist/tools/stopRecording.js +100 -0
- package/dist/tools/stopRecording.js.map +1 -0
- package/dist/tools/trim.d.ts +3 -0
- package/dist/tools/trim.d.ts.map +1 -0
- package/dist/tools/trim.js +38 -0
- package/dist/tools/trim.js.map +1 -0
- package/dist/utils/errors.d.ts +25 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +36 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/ffmpeg.d.ts +24 -0
- package/dist/utils/ffmpeg.d.ts.map +1 -0
- package/dist/utils/ffmpeg.js +88 -0
- package/dist/utils/ffmpeg.js.map +1 -0
- package/dist/utils/media.d.ts +53 -0
- package/dist/utils/media.d.ts.map +1 -0
- package/dist/utils/media.js +133 -0
- package/dist/utils/media.js.map +1 -0
- package/dist/utils/monitors.d.ts +14 -0
- package/dist/utils/monitors.d.ts.map +1 -0
- package/dist/utils/monitors.js +55 -0
- package/dist/utils/monitors.js.map +1 -0
- package/dist/utils/paths.d.ts +11 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +47 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/resolveTarget.d.ts +24 -0
- package/dist/utils/resolveTarget.d.ts.map +1 -0
- package/dist/utils/resolveTarget.js +32 -0
- package/dist/utils/resolveTarget.js.map +1 -0
- package/dist/utils/sessions.d.ts +51 -0
- package/dist/utils/sessions.d.ts.map +1 -0
- package/dist/utils/sessions.js +144 -0
- package/dist/utils/sessions.js.map +1 -0
- package/dist/utils/targets.d.ts +43 -0
- package/dist/utils/targets.d.ts.map +1 -0
- package/dist/utils/targets.js +156 -0
- package/dist/utils/targets.js.map +1 -0
- package/dist/utils/windows.d.ts +43 -0
- package/dist/utils/windows.d.ts.map +1 -0
- package/dist/utils/windows.js +127 -0
- package/dist/utils/windows.js.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TM Hospitality Strategies
|
|
4
|
+
|
|
5
|
+
This work is licensed under the Creative Commons
|
|
6
|
+
Attribution-NonCommercial-NoDerivatives 4.0 International License.
|
|
7
|
+
|
|
8
|
+
You are free to:
|
|
9
|
+
|
|
10
|
+
Share - copy and redistribute the material in any medium or format.
|
|
11
|
+
|
|
12
|
+
The licensor cannot revoke these freedoms as long as you follow the
|
|
13
|
+
license terms.
|
|
14
|
+
|
|
15
|
+
Under the following terms:
|
|
16
|
+
|
|
17
|
+
Attribution - You must give appropriate credit, provide a link to the
|
|
18
|
+
license, and indicate if changes were made. You may do so in any
|
|
19
|
+
reasonable manner, but not in any way that suggests the licensor
|
|
20
|
+
endorses you or your use.
|
|
21
|
+
|
|
22
|
+
NonCommercial - You may not use the material for commercial purposes.
|
|
23
|
+
|
|
24
|
+
NoDerivatives - If you remix, transform, or build upon the material,
|
|
25
|
+
you may not distribute the modified material.
|
|
26
|
+
|
|
27
|
+
No additional restrictions - You may not apply legal terms or
|
|
28
|
+
technological measures that legally restrict others from doing
|
|
29
|
+
anything the license permits.
|
|
30
|
+
|
|
31
|
+
Full license text:
|
|
32
|
+
https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode
|
|
33
|
+
|
|
34
|
+
SPDX-License-Identifier: CC-BY-NC-ND-4.0
|
package/README.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# Screencast MCP
|
|
4
|
+
|
|
5
|
+
**An MCP server that lets an agent record the screen, _watch_ the footage, and make minimal ffmpeg edits — over stdio, on Windows.**
|
|
6
|
+
|
|
7
|
+
Capture the desktop, a monitor, a window, or a region; sample a recording into frames the agent can actually look at; trim, concat, and convert. No cloud, no streaming — ffmpeg and ffprobe wrapped behind ten typed tools.
|
|
8
|
+
|
|
9
|
+
<br />
|
|
10
|
+
|
|
11
|
+
[](https://tmhsdigital.github.io/screencast-mcp/)
|
|
12
|
+
|
|
13
|
+
<br />
|
|
14
|
+
|
|
15
|
+
[](https://github.com/TMHSDigital/screencast-mcp/actions/workflows/ci.yml)
|
|
16
|
+
[](LICENSE)
|
|
17
|
+

|
|
18
|
+

|
|
19
|
+

|
|
20
|
+
|
|
21
|
+

|
|
22
|
+

|
|
23
|
+

|
|
24
|
+

|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
> [!NOTE]
|
|
30
|
+
> This is **Phase 1**. Screen capture uses `gdigrab` and is Windows-only; the watch and edit tools work anywhere ffmpeg runs. The fuller edit surface (crop, scale, speed, overlay, extract, compress), audio capture, and a higher-level production layer are deliberately later phases — see [ROADMAP.md](ROADMAP.md).
|
|
31
|
+
|
|
32
|
+
## Overview
|
|
33
|
+
|
|
34
|
+
Screencast MCP gives an agent a screen recorder it can drive and reason about. It speaks [Model Context Protocol](https://modelcontextprotocol.io) over stdio and exposes ffmpeg as a small, typed tool surface rather than a flag soup. The defining capability is the **watch loop**: an agent records footage, samples it into PNG frames, and views those frames to confirm what actually happened on screen.
|
|
35
|
+
|
|
36
|
+
The design choices are deliberate rather than incidental:
|
|
37
|
+
|
|
38
|
+
- **Capture is always explicit.** A recording or screenshot happens only on a tool call — nothing auto-fires and there is no background or scheduled capture.
|
|
39
|
+
- **Footage is made viewable.** `sample_frames` turns a video into images an agent can open, so "watch what happened" is a first-class operation, not an afterthought.
|
|
40
|
+
- **Presets over raw flags.** Quality is `draft` / `standard` / `high`; the agent never reasons about codecs, CRF, or pixel formats.
|
|
41
|
+
- **Safe by default.** Output lands under `SCREENCAST_HOME`, never inside a project checkout, and the public repo's `.gitignore` blocks captured media from being committed.
|
|
42
|
+
- **Crash-safe sessions.** A recording interrupted by a crash is reconciled on the next start (orphan reaping), so no ffmpeg child silently outlives the server.
|
|
43
|
+
|
|
44
|
+
## Tools
|
|
45
|
+
|
|
46
|
+
Ten tools across three concerns. The manifest in [`mcp-tools.json`](mcp-tools.json) is the canonical surface and is kept in sync with `src/tools/`.
|
|
47
|
+
|
|
48
|
+
### Capture
|
|
49
|
+
|
|
50
|
+
| Tool | Purpose |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| `start_recording` | Start a background recording. `target` = `full` \| `monitor:<index>` \| `window:<title>` \| `region:<x>,<y>,<w>,<h>`; optional `fps` and `quality`. Returns a session id and output path. |
|
|
53
|
+
| `stop_recording` | Stop a session by id. Sends ffmpeg a graceful quit so the file is **finalized, not truncated**. Returns the final path and duration. |
|
|
54
|
+
| `list_sessions` | List active and finished sessions. |
|
|
55
|
+
| `get_session` | Inspect a single session by id. |
|
|
56
|
+
| `screenshot` | Capture a single PNG of a `target`. |
|
|
57
|
+
|
|
58
|
+
### Watch
|
|
59
|
+
|
|
60
|
+
| Tool | Purpose |
|
|
61
|
+
| --- | --- |
|
|
62
|
+
| `sample_frames` | Extract frames from a video — at a fixed `fps` or at explicit `timestamps` — so the agent can view what happened. Returns the frame paths. |
|
|
63
|
+
| `get_media_info` | ffprobe wrapper: duration, resolution, fps, codecs, container format, and size. |
|
|
64
|
+
|
|
65
|
+
### Minimal edit
|
|
66
|
+
|
|
67
|
+
| Tool | Purpose |
|
|
68
|
+
| --- | --- |
|
|
69
|
+
| `trim` | Cut a sub-clip by `start` + (`end` or `duration`). Stream-copy for speed. |
|
|
70
|
+
| `concat` | Join two or more videos into one. |
|
|
71
|
+
| `convert` | Convert between `mp4`, `gif`, and `webm`. |
|
|
72
|
+
|
|
73
|
+
### Targets
|
|
74
|
+
|
|
75
|
+
Every capture tool takes a single `target` string, so an agent never has to juggle quoting:
|
|
76
|
+
|
|
77
|
+
| Target | Captures |
|
|
78
|
+
| --- | --- |
|
|
79
|
+
| `full` | The whole virtual desktop |
|
|
80
|
+
| `monitor:<index>` | One display; `0` is always primary |
|
|
81
|
+
| `window:<title>` | The on-screen rectangle a window occupies (case-insensitive exact title, else substring; topmost wins) |
|
|
82
|
+
| `region:<x>,<y>,<w>,<h>` | An absolute pixel rectangle |
|
|
83
|
+
|
|
84
|
+
Output is written under `SCREENCAST_HOME` (default `<homedir>/.screencast-mcp`) into `recordings/`, `frames/`, `screenshots/`, and `edits/`. Any tool also accepts an explicit output path.
|
|
85
|
+
|
|
86
|
+
## Prerequisites
|
|
87
|
+
|
|
88
|
+
`ffmpeg` and `ffprobe` are external dependencies and must be on `PATH` (or pointed at via the `FFMPEG_PATH` / `FFPROBE_PATH` environment variables). The server detects them per call and returns a clear error with an install hint if either is missing.
|
|
89
|
+
|
|
90
|
+
| Platform | Install |
|
|
91
|
+
| --- | --- |
|
|
92
|
+
| Windows | `winget install Gyan.FFmpeg` or `choco install ffmpeg` |
|
|
93
|
+
| macOS | `brew install ffmpeg` |
|
|
94
|
+
| Linux | `apt install ffmpeg` |
|
|
95
|
+
|
|
96
|
+
## Installation
|
|
97
|
+
|
|
98
|
+
Run it from a clone — this is the supported install today:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
git clone https://github.com/TMHSDigital/screencast-mcp.git
|
|
102
|
+
cd screencast-mcp
|
|
103
|
+
npm install
|
|
104
|
+
npm run build # produces dist/index.js, the server entry point
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
> [!NOTE]
|
|
108
|
+
> A published npm package is planned but **not yet live**. Once it is, `npm install -g @tmhs/screencast-mcp` (or `npx -y @tmhs/screencast-mcp`) will be the one-line install. Until then, use the from-clone path above.
|
|
109
|
+
|
|
110
|
+
### MCP client configuration
|
|
111
|
+
|
|
112
|
+
Point your client at the built entry:
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"mcpServers": {
|
|
117
|
+
"screencast": {
|
|
118
|
+
"command": "node",
|
|
119
|
+
"args": ["C:/path/to/screencast-mcp/dist/index.js"]
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
> [!TIP]
|
|
126
|
+
> Once the package is on npm, this simplifies to `"command": "npx"`, `"args": ["-y", "@tmhs/screencast-mcp"]`.
|
|
127
|
+
|
|
128
|
+
## Usage
|
|
129
|
+
|
|
130
|
+
A typical watch loop — record, sample, look:
|
|
131
|
+
|
|
132
|
+
```jsonc
|
|
133
|
+
// 1. record a region for a few seconds
|
|
134
|
+
start_recording { "target": "region:0,0,1280,720", "quality": "draft" }
|
|
135
|
+
// -> { "sessionId": "rec-…", "outputPath": "…/recordings/rec-….mp4" }
|
|
136
|
+
|
|
137
|
+
// 2. finalize the file
|
|
138
|
+
stop_recording { "sessionId": "rec-…" }
|
|
139
|
+
// -> { "durationSec": 4.2, "finalizedGracefully": true }
|
|
140
|
+
|
|
141
|
+
// 3. turn it into frames the agent can view
|
|
142
|
+
sample_frames { "input": "…/recordings/rec-….mp4", "timestamps": [0.5, 2, 3.5] }
|
|
143
|
+
// -> { "frames": ["…/frames/…/frame_000_0.5s.png", …] }
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
`screenshot { "target": "window:My App" }` is the one-shot equivalent for a still.
|
|
147
|
+
|
|
148
|
+
## Windows notes
|
|
149
|
+
|
|
150
|
+
- **Multi-monitor offsets.** `gdigrab` has no "capture monitor N" selector, so a monitor target captures the whole virtual desktop and crops to that display's pixel bounds (from `System.Windows.Forms.Screen.AllScreens`). `monitor:1` grabs the second display at its real offset; `monitor:0` is always primary.
|
|
151
|
+
- **Window capture** resolves the window to the on-screen **rectangle** it occupies and captures that, rather than the window's own surface — `gdigrab`'s native `title=` grab returns a blank frame for GPU- or DirectComposition-composited windows (Chrome, Electron, UWP). The window must be **visible, on top, and not minimized** (a minimized window is rejected with a clear error), the capture includes anything drawn over that rectangle, and for `start_recording` the rectangle is fixed **once at start**. True per-window background capture (Windows Graphics Capture API) is a future phase.
|
|
152
|
+
- **Fullscreen-exclusive apps** often produce black frames under `gdigrab`; run the source in borderless-windowed mode for reliable capture.
|
|
153
|
+
- **No audio in Phase 1.** `gdigrab` is video-only; audio (dshow / WASAPI loopback) is a Phase 2 seam and is intentionally not half-wired.
|
|
154
|
+
|
|
155
|
+
## Threat model
|
|
156
|
+
|
|
157
|
+
> [!WARNING]
|
|
158
|
+
> Screen capture can record **anything** on screen at the moment of capture — passwords, tokens, private messages, and other secrets. `window:` captures the screen rectangle a window occupies, so overlays, notifications, or another window drawn over it are captured too. Treat recordings, screenshots, and sampled frames as sensitive by default.
|
|
159
|
+
|
|
160
|
+
- **Capture is always explicit.** Nothing auto-fires; capture is gated behind an explicit tool call.
|
|
161
|
+
- **Output stays local.** Files are written to the local filesystem only — never uploaded, streamed, or transmitted anywhere.
|
|
162
|
+
- **Public repo, private captures.** The `.gitignore` blocks recordings, frames, screenshots, and common video/image output so test media cannot be committed by accident.
|
|
163
|
+
- **Review before sharing.** Sample frames or inspect a recording before handing a file to another tool or person, so you know what it contains.
|
|
164
|
+
|
|
165
|
+
## Project structure
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
.
|
|
169
|
+
├── src/
|
|
170
|
+
│ ├── index.ts # MCP server entry (stdio); registers every tool, reaps orphans
|
|
171
|
+
│ ├── context.ts # shared session-store singleton
|
|
172
|
+
│ ├── tools/ # one file per tool (capture, watch, edit)
|
|
173
|
+
│ ├── utils/ # ffmpeg, monitors, windows, sessions, paths, targets
|
|
174
|
+
│ └── __tests__/ # vitest unit tests + guarded local-capture harness
|
|
175
|
+
├── docs/ # GitHub Pages documentation site
|
|
176
|
+
├── mcp-tools.json # canonical tool manifest (kept in sync with src/tools)
|
|
177
|
+
├── .github/workflows/ # CI, release, npm publish, Pages, ecosystem drift check
|
|
178
|
+
├── ROADMAP.md · CONTRIBUTING.md · SECURITY.md · LICENSE
|
|
179
|
+
└── package.json
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Development
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
npm install
|
|
186
|
+
npm run build # tsc -> dist/
|
|
187
|
+
npm test # vitest (pure unit tests; no ffmpeg or display required)
|
|
188
|
+
npm run dev # tsx watch
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
The capture path can't be exercised on CI's headless Linux runners, so an end-to-end harness lives behind a flag and is skipped by default:
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
RUN_LOCAL_CAPTURE_TESTS=1 npm test # Windows + ffmpeg + a real display
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Contributing
|
|
198
|
+
|
|
199
|
+
Issues and pull requests are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md) and the [Code of Conduct](CODE_OF_CONDUCT.md). Security reports go through [SECURITY.md](SECURITY.md).
|
|
200
|
+
|
|
201
|
+
## License
|
|
202
|
+
|
|
203
|
+
Released under the [CC-BY-NC-ND-4.0](LICENSE) license.
|
|
204
|
+
|
|
205
|
+
<div align="center">
|
|
206
|
+
<br />
|
|
207
|
+
|
|
208
|
+
[**Documentation**](https://tmhsdigital.github.io/screencast-mcp/) · [**Roadmap**](ROADMAP.md) · [**Report an issue**](https://github.com/TMHSDigital/screencast-mcp/issues) · [**License**](LICENSE)
|
|
209
|
+
|
|
210
|
+
<sub>Built by <a href="https://github.com/TMHSDigital">TMHSDigital</a> · <a href="#screencast-mcp">Back to top ↑</a></sub>
|
|
211
|
+
|
|
212
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAKnD,8DAA8D;AAC9D,wBAAgB,QAAQ,IAAI,YAAY,CAMvC"}
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Process-wide singletons shared by every tool. */
|
|
2
|
+
import { SessionStore } from "./utils/sessions.js";
|
|
3
|
+
import { registryPath } from "./utils/paths.js";
|
|
4
|
+
let store = null;
|
|
5
|
+
/** Lazily construct and load the on-disk session registry. */
|
|
6
|
+
export function getStore() {
|
|
7
|
+
if (!store) {
|
|
8
|
+
store = new SessionStore(registryPath());
|
|
9
|
+
store.load();
|
|
10
|
+
}
|
|
11
|
+
return store;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,IAAI,KAAK,GAAwB,IAAI,CAAC;AAEtC,8DAA8D;AAC9D,MAAM,UAAU,QAAQ;IACtB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,KAAK,GAAG,IAAI,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC;QACzC,KAAK,CAAC,IAAI,EAAE,CAAC;IACf,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* screencast-mcp - a Windows-first MCP server for screen recording, frame
|
|
4
|
+
* sampling ("watching" footage), and minimal ffmpeg edits.
|
|
5
|
+
*
|
|
6
|
+
* Transport: stdio. ffmpeg/ffprobe are external dependencies detected per call.
|
|
7
|
+
* Capture is always explicit (a tool call) and never auto-fires - a recording
|
|
8
|
+
* can contain anything on screen, including secrets. See the README threat
|
|
9
|
+
* model.
|
|
10
|
+
*/
|
|
11
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
12
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
13
|
+
import { getStore } from "./context.js";
|
|
14
|
+
import { register as registerStartRecording } from "./tools/startRecording.js";
|
|
15
|
+
import { register as registerStopRecording } from "./tools/stopRecording.js";
|
|
16
|
+
import { register as registerListSessions } from "./tools/listSessions.js";
|
|
17
|
+
import { register as registerGetSession } from "./tools/getSession.js";
|
|
18
|
+
import { register as registerScreenshot } from "./tools/screenshot.js";
|
|
19
|
+
import { register as registerSampleFrames } from "./tools/sampleFrames.js";
|
|
20
|
+
import { register as registerGetMediaInfo } from "./tools/getMediaInfo.js";
|
|
21
|
+
import { register as registerTrim } from "./tools/trim.js";
|
|
22
|
+
import { register as registerConcat } from "./tools/concat.js";
|
|
23
|
+
import { register as registerConvert } from "./tools/convert.js";
|
|
24
|
+
const server = new McpServer({
|
|
25
|
+
name: "screencast-mcp",
|
|
26
|
+
version: "0.2.1",
|
|
27
|
+
});
|
|
28
|
+
registerStartRecording(server);
|
|
29
|
+
registerStopRecording(server);
|
|
30
|
+
registerListSessions(server);
|
|
31
|
+
registerGetSession(server);
|
|
32
|
+
registerScreenshot(server);
|
|
33
|
+
registerSampleFrames(server);
|
|
34
|
+
registerGetMediaInfo(server);
|
|
35
|
+
registerTrim(server);
|
|
36
|
+
registerConcat(server);
|
|
37
|
+
registerConvert(server);
|
|
38
|
+
async function main() {
|
|
39
|
+
// Reconcile any sessions interrupted by a previous crash and kill ffmpeg
|
|
40
|
+
// children that outlived the last run, so no zombie capture survives.
|
|
41
|
+
try {
|
|
42
|
+
const reaped = getStore().reapOrphans();
|
|
43
|
+
if (reaped.length > 0) {
|
|
44
|
+
process.stderr.write(`Reaped ${reaped.length} orphaned recording(s) on startup.\n`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
process.stderr.write(`Orphan reaping skipped: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
49
|
+
}
|
|
50
|
+
const transport = new StdioServerTransport();
|
|
51
|
+
await server.connect(transport);
|
|
52
|
+
}
|
|
53
|
+
main().catch((error) => {
|
|
54
|
+
process.stderr.write(`Fatal error: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,QAAQ,IAAI,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,QAAQ,IAAI,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,QAAQ,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,QAAQ,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,QAAQ,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEjE,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;IAC3B,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,OAAO;CACjB,CAAC,CAAC;AAEH,sBAAsB,CAAC,MAAM,CAAC,CAAC;AAC/B,qBAAqB,CA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CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concat.d.ts","sourceRoot":"","sources":["../../src/tools/concat.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAczE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA4BhD"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { extname, join } from "node:path";
|
|
3
|
+
import { existsSync, writeFileSync, rmSync } from "node:fs";
|
|
4
|
+
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
5
|
+
import { requireFfmpeg, runFfmpeg } from "../utils/ffmpeg.js";
|
|
6
|
+
import { buildConcatArgs, buildConcatListContent } from "../utils/media.js";
|
|
7
|
+
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
8
|
+
const inputSchema = {
|
|
9
|
+
inputs: z
|
|
10
|
+
.array(z.string().min(1))
|
|
11
|
+
.min(2)
|
|
12
|
+
.describe("Two or more video paths to join, in order. Inputs must share codec/format."),
|
|
13
|
+
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
14
|
+
};
|
|
15
|
+
export function register(server) {
|
|
16
|
+
server.tool("concat", "Concatenate two or more videos into a single file using the ffmpeg concat " +
|
|
17
|
+
"demuxer (stream copy). Inputs should share the same codec and format.", inputSchema, async (args) => {
|
|
18
|
+
try {
|
|
19
|
+
requireFfmpeg();
|
|
20
|
+
for (const f of args.inputs) {
|
|
21
|
+
if (!existsSync(f))
|
|
22
|
+
throw new ScreencastError(`Input file not found: ${f}`);
|
|
23
|
+
}
|
|
24
|
+
const ext = extname(args.inputs[0]) || ".mp4";
|
|
25
|
+
const editsDir = subdir("edits");
|
|
26
|
+
const output = resolveOutput(args.output, editsDir, `concat-${stamp()}-${rand()}${ext}`);
|
|
27
|
+
const listFile = join(editsDir, `.concat-${stamp()}-${rand()}.txt`);
|
|
28
|
+
writeFileSync(listFile, buildConcatListContent(args.inputs));
|
|
29
|
+
try {
|
|
30
|
+
await runFfmpeg(buildConcatArgs(listFile, output), 10 * 60_000);
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
rmSync(listFile, { force: true });
|
|
34
|
+
}
|
|
35
|
+
return okResponse({ outputPath: output, inputCount: args.inputs.length });
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
return errorResponse(error);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=concat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concat.js","sourceRoot":"","sources":["../../src/tools/concat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEvE,MAAM,WAAW,GAAG;IAClB,MAAM,EAAE,CAAC;SACN,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SACxB,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CAAC,4EAA4E,CAAC;IACzF,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC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AAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../src/tools/convert.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAgBzE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA6BhD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
+
import { requireFfmpeg, runFfmpeg } from "../utils/ffmpeg.js";
|
|
5
|
+
import { buildConvertArgs } from "../utils/media.js";
|
|
6
|
+
import { resolveOutput, subdir, stamp, rand } from "../utils/paths.js";
|
|
7
|
+
const inputSchema = {
|
|
8
|
+
input: z.string().min(1).describe("Path to the source media."),
|
|
9
|
+
format: z
|
|
10
|
+
.enum(["mp4", "gif", "webm"])
|
|
11
|
+
.describe("Target format. Converts mp4 <-> gif/webm (H.264 / VP9 / palette gif)."),
|
|
12
|
+
fps: z.number().positive().optional().describe("Output fps (gif only; default 12)."),
|
|
13
|
+
width: z.number().positive().optional().describe("Output width in px, height auto (gif only; default 720)."),
|
|
14
|
+
output: z.string().optional().describe("Optional output path. Defaults under SCREENCAST_HOME/edits."),
|
|
15
|
+
};
|
|
16
|
+
export function register(server) {
|
|
17
|
+
server.tool("convert", "Convert a video between mp4, gif, and webm. mp4 uses H.264, webm uses VP9, " +
|
|
18
|
+
"and gif uses a palette filter for quality. Returns the output path.", inputSchema, async (args) => {
|
|
19
|
+
try {
|
|
20
|
+
requireFfmpeg();
|
|
21
|
+
if (!existsSync(args.input)) {
|
|
22
|
+
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
23
|
+
}
|
|
24
|
+
const format = args.format;
|
|
25
|
+
const output = resolveOutput(args.output, subdir("edits"), `convert-${stamp()}-${rand()}.${format}`);
|
|
26
|
+
const ffArgs = buildConvertArgs(args.input, output, format, {
|
|
27
|
+
fps: args.fps,
|
|
28
|
+
width: args.width,
|
|
29
|
+
});
|
|
30
|
+
await runFfmpeg(ffArgs, 10 * 60_000);
|
|
31
|
+
return okResponse({ outputPath: output, format });
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
return errorResponse(error);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=convert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../../src/tools/convert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAsB,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEvE,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,2BAA2B,CAAC;IAC9D,MAAM,EAAE,CAAC;SACN,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;SAC5B,QAAQ,CAAC,uEAAuE,CAAC;IACpF,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE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C,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMediaInfo.d.ts","sourceRoot":"","sources":["../../src/tools/getMediaInfo.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AASzE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAwBhD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
+
import { requireFfmpeg, runCapture } from "../utils/ffmpeg.js";
|
|
5
|
+
import { buildProbeArgs, parseMediaInfo } from "../utils/media.js";
|
|
6
|
+
const inputSchema = {
|
|
7
|
+
input: z.string().min(1).describe("Path to the media file to probe."),
|
|
8
|
+
};
|
|
9
|
+
export function register(server) {
|
|
10
|
+
server.tool("get_media_info", "Probe a media file with ffprobe and return duration, resolution, frame " +
|
|
11
|
+
"rate, codecs, container format, and size.", inputSchema, async (args) => {
|
|
12
|
+
try {
|
|
13
|
+
const { ffprobe } = requireFfmpeg();
|
|
14
|
+
if (!existsSync(args.input)) {
|
|
15
|
+
throw new ScreencastError(`Input file not found: ${args.input}`);
|
|
16
|
+
}
|
|
17
|
+
const res = await runCapture(ffprobe, buildProbeArgs(args.input), 30_000);
|
|
18
|
+
if (res.code !== 0) {
|
|
19
|
+
throw new ScreencastError(`ffprobe failed (exit ${res.code}): ${res.stderr.trim().slice(-400)}`);
|
|
20
|
+
}
|
|
21
|
+
return okResponse({ input: args.input, ...parseMediaInfo(JSON.parse(res.stdout)) });
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
return errorResponse(error);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=getMediaInfo.js.map
|
|
@@ -0,0 +1 @@
|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J,CAAC;YACD,OAAO,UAAU,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,GAAG,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;QACtF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSession.d.ts","sourceRoot":"","sources":["../../src/tools/getSession.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AASzE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAsBhD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { errorResponse, okResponse, ScreencastError } from "../utils/errors.js";
|
|
4
|
+
import { isAlive } from "../utils/sessions.js";
|
|
5
|
+
import { getStore } from "../context.js";
|
|
6
|
+
const inputSchema = {
|
|
7
|
+
sessionId: z.string().min(1).describe("Session id returned by start_recording."),
|
|
8
|
+
};
|
|
9
|
+
export function register(server) {
|
|
10
|
+
server.tool("get_session", "Inspect a single recording session by id, including live status and " +
|
|
11
|
+
"whether its output file exists on disk.", inputSchema, async (args) => {
|
|
12
|
+
try {
|
|
13
|
+
const record = getStore().get(args.sessionId);
|
|
14
|
+
if (!record) {
|
|
15
|
+
throw new ScreencastError(`No session with id "${args.sessionId}".`);
|
|
16
|
+
}
|
|
17
|
+
return okResponse({
|
|
18
|
+
...record,
|
|
19
|
+
alive: record.status === "recording" && isAlive(record.pid),
|
|
20
|
+
fileExists: existsSync(record.outputPath),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
return errorResponse(error);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=getSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSession.js","sourceRoot":"","sources":["../../src/tools/getSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,WAAW,GAAG;IAClB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,yCAAyC,CAAC;CACjF,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,MAAiB;IACxC,MAAM,CAAC,IAAI,CACT,aAAa,EACb,sEAAsE;QACpE,yCAAyC,EAC3C,WAAW,EACX,KAAK,EAAE,IAAI,EAAE,EAAE;QACb,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,QAAQ,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC9C,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,IAAI,eAAe,CAAC,uBAAuB,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC;YACvE,CAAC;YACD,OAAO,UAAU,CAAC;gBAChB,GAAG,MAAM;gBACT,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC;gBAC3D,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC;aAC1C,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listSessions.d.ts","sourceRoot":"","sources":["../../src/tools/listSessions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKzE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAiBhD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { errorResponse, okResponse } from "../utils/errors.js";
|
|
2
|
+
import { isAlive } from "../utils/sessions.js";
|
|
3
|
+
import { getStore } from "../context.js";
|
|
4
|
+
export function register(server) {
|
|
5
|
+
server.tool("list_sessions", "List all recording sessions (active and finished) with their status, " +
|
|
6
|
+
"target, output path, and whether the process is still alive.", {}, async () => {
|
|
7
|
+
try {
|
|
8
|
+
const sessions = getStore()
|
|
9
|
+
.list()
|
|
10
|
+
.map((s) => ({ ...s, alive: s.status === "recording" && isAlive(s.pid) }));
|
|
11
|
+
return okResponse({ count: sessions.length, sessions });
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
return errorResponse(error);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=listSessions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listSessions.js","sourceRoot":"","sources":["../../src/tools/listSessions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,UAAU,QAAQ,CAAC,MAAiB;IACxC,MAAM,CAAC,IAAI,CACT,eAAe,EACf,uEAAuE;QACrE,8DAA8D,EAChE,EAAE,EACF,KAAK,IAAI,EAAE;QACT,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,QAAQ,EAAE;iBACxB,IAAI,EAAE;iBACN,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,KAAK,WAAW,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;YAC7E,OAAO,UAAU,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC1D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sampleFrames.d.ts","sourceRoot":"","sources":["../../src/tools/sampleFrames.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA0BzE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAoDhD"}
|