@walkrstudio/recorder 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdp.d.ts +14 -0
- package/dist/cdp.d.ts.map +1 -0
- package/dist/cdp.js +86 -0
- package/dist/cdp.js.map +1 -0
- package/dist/chromium.d.ts +12 -0
- package/dist/chromium.d.ts.map +1 -0
- package/dist/chromium.js +75 -0
- package/dist/chromium.js.map +1 -0
- package/dist/embed.d.ts +3 -0
- package/dist/embed.d.ts.map +1 -0
- package/dist/embed.js +548 -0
- package/dist/embed.js.map +1 -0
- package/dist/encoder.d.ts +6 -0
- package/dist/encoder.d.ts.map +1 -0
- package/dist/encoder.js +121 -0
- package/dist/encoder.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/realtime-recorder.d.ts +4 -0
- package/dist/realtime-recorder.d.ts.map +1 -0
- package/dist/realtime-recorder.js +109 -0
- package/dist/realtime-recorder.js.map +1 -0
- package/dist/recorder.d.ts +4 -0
- package/dist/recorder.d.ts.map +1 -0
- package/dist/recorder.js +180 -0
- package/dist/recorder.js.map +1 -0
- package/dist/recording-session.d.ts +26 -0
- package/dist/recording-session.d.ts.map +1 -0
- package/dist/recording-session.js +88 -0
- package/dist/recording-session.js.map +1 -0
- package/dist/static-server.d.ts +9 -0
- package/dist/static-server.d.ts.map +1 -0
- package/dist/static-server.js +212 -0
- package/dist/static-server.js.map +1 -0
- package/dist/streaming-encoder.d.ts +26 -0
- package/dist/streaming-encoder.d.ts.map +1 -0
- package/dist/streaming-encoder.js +89 -0
- package/dist/streaming-encoder.js.map +1 -0
- package/dist/types.d.ts +15 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +34 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { execSync } from "node:child_process";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as http from "node:http";
|
|
4
|
+
import * as https from "node:https";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
import * as net from "node:net";
|
|
7
|
+
import { dirname, extname, join, resolve } from "node:path";
|
|
8
|
+
const PROXY_PREFIX = "/__target__";
|
|
9
|
+
function rewriteWalkthroughUrl(walkthrough, targetOrigin) {
|
|
10
|
+
return {
|
|
11
|
+
...walkthrough,
|
|
12
|
+
originalUrl: walkthrough.url,
|
|
13
|
+
url: walkthrough.url.replace(targetOrigin, PROXY_PREFIX),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
async function getFreePort() {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
const server = net.createServer();
|
|
19
|
+
server.listen(0, () => {
|
|
20
|
+
const addr = server.address();
|
|
21
|
+
if (!addr || typeof addr === "string") {
|
|
22
|
+
server.close();
|
|
23
|
+
reject(new Error("Failed to get free port"));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const port = addr.port;
|
|
27
|
+
server.close(() => resolve(port));
|
|
28
|
+
});
|
|
29
|
+
server.on("error", reject);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const MIME_TYPES = {
|
|
33
|
+
".html": "text/html; charset=utf-8",
|
|
34
|
+
".js": "application/javascript; charset=utf-8",
|
|
35
|
+
".mjs": "application/javascript; charset=utf-8",
|
|
36
|
+
".css": "text/css; charset=utf-8",
|
|
37
|
+
".json": "application/json; charset=utf-8",
|
|
38
|
+
".png": "image/png",
|
|
39
|
+
".jpg": "image/jpeg",
|
|
40
|
+
".jpeg": "image/jpeg",
|
|
41
|
+
".gif": "image/gif",
|
|
42
|
+
".svg": "image/svg+xml",
|
|
43
|
+
".ico": "image/x-icon",
|
|
44
|
+
".woff": "font/woff",
|
|
45
|
+
".woff2": "font/woff2",
|
|
46
|
+
".ttf": "font/ttf",
|
|
47
|
+
".eot": "application/vnd.ms-fontobject",
|
|
48
|
+
".webp": "image/webp",
|
|
49
|
+
".avif": "image/avif",
|
|
50
|
+
".mp4": "video/mp4",
|
|
51
|
+
".webm": "video/webm",
|
|
52
|
+
".wasm": "application/wasm",
|
|
53
|
+
".map": "application/json",
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Rewrite absolute paths in proxied text responses so that sub-resource
|
|
57
|
+
* requests (scripts, styles, fetches) route back through the proxy.
|
|
58
|
+
*/
|
|
59
|
+
function rewriteAbsolutePaths(content, contentType) {
|
|
60
|
+
if (contentType.includes("html")) {
|
|
61
|
+
let html = content
|
|
62
|
+
.replace(/((?:src|href|action|poster|formaction|icon|manifest|ping|background)\s*=\s*)(["'])\/(?!\/|__target__)/gi, `$1$2${PROXY_PREFIX}/`)
|
|
63
|
+
.replace(/\burl\(\s*["']?\/(?!\/|__target__)/g, (m) => m.replace("/", `${PROXY_PREFIX}/`))
|
|
64
|
+
.replace(/(["'`])\/(?!\/|__target__)([a-zA-Z@._][\w@._-]*\/)/g, `$1${PROXY_PREFIX}/$2`)
|
|
65
|
+
.replace(/(["'`])\/(?!\/|__target__)([a-zA-Z@._][\w@._-]+\.\w{2,})/g, `$1${PROXY_PREFIX}/$2`);
|
|
66
|
+
if (!/<base\b/i.test(html)) {
|
|
67
|
+
html = html.replace(/(<head[^>]*>)/i, `$1<base href="${PROXY_PREFIX}/">`);
|
|
68
|
+
}
|
|
69
|
+
return html;
|
|
70
|
+
}
|
|
71
|
+
if (contentType.includes("css")) {
|
|
72
|
+
return content
|
|
73
|
+
.replace(/\burl\(\s*["']?\/(?!\/|__target__)/g, (m) => m.replace("/", `${PROXY_PREFIX}/`))
|
|
74
|
+
.replace(/(@import\s+["'])\/(?!\/|__target__)/g, `$1${PROXY_PREFIX}/`);
|
|
75
|
+
}
|
|
76
|
+
return content
|
|
77
|
+
.replace(/(["'`])\/(?!\/|__target__)([a-zA-Z@._][\w@._-]*\/)/g, `$1${PROXY_PREFIX}/$2`)
|
|
78
|
+
.replace(/(["'`])\/(?!\/|__target__)([a-zA-Z@._][\w@._-]+\.\w{2,})/g, `$1${PROXY_PREFIX}/$2`);
|
|
79
|
+
}
|
|
80
|
+
function isTextResponse(contentType) {
|
|
81
|
+
return (contentType.includes("text/") ||
|
|
82
|
+
contentType.includes("javascript") ||
|
|
83
|
+
contentType.includes("json") ||
|
|
84
|
+
contentType.includes("css"));
|
|
85
|
+
}
|
|
86
|
+
function ensureStudioBuild(studioRoot) {
|
|
87
|
+
const distIndex = resolve(studioRoot, "dist", "index.html");
|
|
88
|
+
if (fs.existsSync(distIndex))
|
|
89
|
+
return;
|
|
90
|
+
execSync("npx vite build", {
|
|
91
|
+
cwd: studioRoot,
|
|
92
|
+
stdio: "inherit",
|
|
93
|
+
});
|
|
94
|
+
if (!fs.existsSync(distIndex)) {
|
|
95
|
+
throw new Error(`Studio build failed: ${distIndex} not found after vite build`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function proxyRequest(targetOrigin, targetPath, req, res) {
|
|
99
|
+
const targetUrl = new URL(targetPath, targetOrigin);
|
|
100
|
+
const transport = targetUrl.protocol === "https:" ? https : http;
|
|
101
|
+
const headers = { ...req.headers };
|
|
102
|
+
headers.host = targetUrl.host;
|
|
103
|
+
headers["accept-encoding"] = "identity";
|
|
104
|
+
const proxyReq = transport.request(targetUrl, {
|
|
105
|
+
method: req.method,
|
|
106
|
+
headers,
|
|
107
|
+
}, (proxyRes) => {
|
|
108
|
+
const contentType = proxyRes.headers["content-type"] ?? "";
|
|
109
|
+
if (isTextResponse(contentType)) {
|
|
110
|
+
const chunks = [];
|
|
111
|
+
proxyRes.on("data", (chunk) => chunks.push(chunk));
|
|
112
|
+
proxyRes.on("end", () => {
|
|
113
|
+
const raw = Buffer.concat(chunks).toString("utf-8");
|
|
114
|
+
const rewritten = rewriteAbsolutePaths(raw, contentType);
|
|
115
|
+
const responseHeaders = { ...proxyRes.headers };
|
|
116
|
+
delete responseHeaders["content-length"];
|
|
117
|
+
delete responseHeaders["content-encoding"];
|
|
118
|
+
responseHeaders["cache-control"] = "no-store";
|
|
119
|
+
delete responseHeaders.etag;
|
|
120
|
+
res.writeHead(proxyRes.statusCode ?? 200, responseHeaders);
|
|
121
|
+
res.end(rewritten);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
const responseHeaders = { ...proxyRes.headers };
|
|
126
|
+
responseHeaders["cache-control"] = "no-store";
|
|
127
|
+
delete responseHeaders.etag;
|
|
128
|
+
res.writeHead(proxyRes.statusCode ?? 200, responseHeaders);
|
|
129
|
+
proxyRes.pipe(res);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
proxyReq.on("error", (err) => {
|
|
133
|
+
res.writeHead(502);
|
|
134
|
+
res.end(`Proxy error: ${err.message}`);
|
|
135
|
+
});
|
|
136
|
+
req.pipe(proxyReq);
|
|
137
|
+
}
|
|
138
|
+
export async function startStaticServer(walkthrough) {
|
|
139
|
+
const require = createRequire(import.meta.url);
|
|
140
|
+
const studioRoot = dirname(require.resolve("@walkrstudio/studio/package.json"));
|
|
141
|
+
ensureStudioBuild(studioRoot);
|
|
142
|
+
let targetOrigin = "";
|
|
143
|
+
try {
|
|
144
|
+
targetOrigin = new URL(walkthrough.url).origin;
|
|
145
|
+
}
|
|
146
|
+
catch { }
|
|
147
|
+
const proxied = targetOrigin ? rewriteWalkthroughUrl(walkthrough, targetOrigin) : walkthrough;
|
|
148
|
+
const walkthroughJson = JSON.stringify(proxied, null, 2);
|
|
149
|
+
const distDir = resolve(studioRoot, "dist");
|
|
150
|
+
const port = await getFreePort();
|
|
151
|
+
const server = http.createServer((req, res) => {
|
|
152
|
+
const urlPath = req.url?.split("?")[0] ?? "/";
|
|
153
|
+
// Serve walkthrough.json from memory
|
|
154
|
+
if (urlPath === "/walkthrough.json") {
|
|
155
|
+
res.writeHead(200, {
|
|
156
|
+
"content-type": "application/json; charset=utf-8",
|
|
157
|
+
"cache-control": "no-store",
|
|
158
|
+
});
|
|
159
|
+
res.end(walkthroughJson);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
// Proxy /__target__/* to target origin
|
|
163
|
+
if (targetOrigin && urlPath.startsWith(PROXY_PREFIX)) {
|
|
164
|
+
const targetPath = urlPath.slice(PROXY_PREFIX.length) || "/";
|
|
165
|
+
proxyRequest(targetOrigin, targetPath, req, res);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
// Serve static files from dist
|
|
169
|
+
let filePath = join(distDir, urlPath === "/" ? "index.html" : urlPath);
|
|
170
|
+
// SPA fallback: if file doesn't exist and no extension, serve index.html
|
|
171
|
+
if (!fs.existsSync(filePath)) {
|
|
172
|
+
const ext = extname(filePath);
|
|
173
|
+
if (!ext) {
|
|
174
|
+
filePath = join(distDir, "index.html");
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (!fs.existsSync(filePath)) {
|
|
178
|
+
res.writeHead(404);
|
|
179
|
+
res.end("Not Found");
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const stat = fs.statSync(filePath);
|
|
183
|
+
if (stat.isDirectory()) {
|
|
184
|
+
filePath = join(filePath, "index.html");
|
|
185
|
+
if (!fs.existsSync(filePath)) {
|
|
186
|
+
res.writeHead(404);
|
|
187
|
+
res.end("Not Found");
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const ext = extname(filePath).toLowerCase();
|
|
192
|
+
const mime = MIME_TYPES[ext] ?? "application/octet-stream";
|
|
193
|
+
res.writeHead(200, {
|
|
194
|
+
"content-type": mime,
|
|
195
|
+
"content-length": stat.size,
|
|
196
|
+
"cache-control": "no-store",
|
|
197
|
+
});
|
|
198
|
+
fs.createReadStream(filePath).pipe(res);
|
|
199
|
+
});
|
|
200
|
+
await new Promise((resolve, reject) => {
|
|
201
|
+
server.listen(port, "127.0.0.1", () => resolve());
|
|
202
|
+
server.on("error", reject);
|
|
203
|
+
});
|
|
204
|
+
return {
|
|
205
|
+
port,
|
|
206
|
+
url: `http://127.0.0.1:${port}`,
|
|
207
|
+
close() {
|
|
208
|
+
server.close();
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=static-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-server.js","sourceRoot":"","sources":["../src/static-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAI5D,MAAM,YAAY,GAAG,aAAa,CAAC;AAQnC,SAAS,qBAAqB,CAC5B,WAAwB,EACxB,YAAoB;IAEpB,OAAO;QACL,GAAG,WAAW;QACd,WAAW,EAAE,WAAW,CAAC,GAAG;QAC5B,GAAG,EAAE,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,YAAY,CAAC;KACzD,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,WAAW;IACxB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC;QAClC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE;YACpB,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;YAC9B,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACtC,MAAM,CAAC,KAAK,EAAE,CAAC;gBACf,MA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,cAAc,EAAE,IAAI;YACpB,gBAAgB,EAAE,IAAI,CAAC,IAAI;YAC3B,eAAe,EAAE,UAAU;SAC5B,CAAC,CAAC;QACH,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC1C,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QAClD,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,IAAI;QACJ,GAAG,EAAE,oBAAoB,IAAI,EAAE;QAC/B,KAAK;YACH,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { RecordResult } from "./types.js";
|
|
2
|
+
interface StreamingEncoderOptions {
|
|
3
|
+
format: "mp4" | "gif" | "webm";
|
|
4
|
+
fps: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
outputPath: string;
|
|
8
|
+
onProgress?: (percent: number) => void;
|
|
9
|
+
expectedFrames?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare class StreamingEncoder {
|
|
12
|
+
private child;
|
|
13
|
+
private exitPromise;
|
|
14
|
+
private frameCount;
|
|
15
|
+
private readonly fps;
|
|
16
|
+
private readonly totalSeconds;
|
|
17
|
+
private readonly onProgress?;
|
|
18
|
+
private readonly outputPath;
|
|
19
|
+
constructor(options: StreamingEncoderOptions);
|
|
20
|
+
private parseProgress;
|
|
21
|
+
write(frame: Buffer): Promise<void>;
|
|
22
|
+
finish(): Promise<RecordResult>;
|
|
23
|
+
abort(): void;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=streaming-encoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming-encoder.d.ts","sourceRoot":"","sources":["../src/streaming-encoder.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,UAAU,uBAAuB;IAC/B,MAAM,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAA4B;IACxD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAExB,OAAO,EAAE,uBAAuB;IAgC5C,OAAO,CAAC,aAAa;IAef,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAcnC,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC;IAarC,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
export class StreamingEncoder {
|
|
3
|
+
child;
|
|
4
|
+
exitPromise;
|
|
5
|
+
frameCount = 0;
|
|
6
|
+
fps;
|
|
7
|
+
totalSeconds;
|
|
8
|
+
onProgress;
|
|
9
|
+
outputPath;
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.outputPath = options.outputPath;
|
|
12
|
+
this.onProgress = options.onProgress;
|
|
13
|
+
this.fps = options.fps;
|
|
14
|
+
this.totalSeconds = (options.expectedFrames ?? 0) / Math.max(1, options.fps);
|
|
15
|
+
const args = buildFfmpegArgs(options);
|
|
16
|
+
this.child = spawn("ffmpeg", args, {
|
|
17
|
+
stdio: ["pipe", "ignore", "pipe"],
|
|
18
|
+
});
|
|
19
|
+
this.exitPromise = new Promise((resolve, reject) => {
|
|
20
|
+
this.child.on("close", (code) => {
|
|
21
|
+
if (code === 0) {
|
|
22
|
+
resolve();
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
reject(new Error(`ffmpeg exited with code ${code}`));
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
this.child.on("error", reject);
|
|
29
|
+
});
|
|
30
|
+
// Absorb stdin errors — they surface via exitPromise when ffmpeg exits
|
|
31
|
+
this.child.stdin?.on("error", () => { });
|
|
32
|
+
if (this.child.stderr && this.onProgress) {
|
|
33
|
+
this.child.stderr.on("data", (chunk) => {
|
|
34
|
+
this.parseProgress(chunk.toString());
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
parseProgress(output) {
|
|
39
|
+
if (!this.onProgress || this.totalSeconds <= 0)
|
|
40
|
+
return;
|
|
41
|
+
const match = /time=(\d+):(\d+):(\d+(?:\.\d+)?)/.exec(output);
|
|
42
|
+
if (!match)
|
|
43
|
+
return;
|
|
44
|
+
const hours = Number(match[1]);
|
|
45
|
+
const minutes = Number(match[2]);
|
|
46
|
+
const seconds = Number(match[3]);
|
|
47
|
+
const elapsedSeconds = hours * 3600 + minutes * 60 + seconds;
|
|
48
|
+
const percent = Math.max(0, Math.min(100, (elapsedSeconds / this.totalSeconds) * 100));
|
|
49
|
+
this.onProgress(percent);
|
|
50
|
+
}
|
|
51
|
+
async write(frame) {
|
|
52
|
+
const stdin = this.child.stdin;
|
|
53
|
+
if (!stdin || stdin.destroyed) {
|
|
54
|
+
throw new Error("ffmpeg stdin is not writable");
|
|
55
|
+
}
|
|
56
|
+
const ok = stdin.write(frame);
|
|
57
|
+
if (!ok) {
|
|
58
|
+
await new Promise((resolve) => stdin.once("drain", resolve));
|
|
59
|
+
}
|
|
60
|
+
this.frameCount++;
|
|
61
|
+
}
|
|
62
|
+
async finish() {
|
|
63
|
+
this.child.stdin?.end();
|
|
64
|
+
await this.exitPromise;
|
|
65
|
+
this.onProgress?.(100);
|
|
66
|
+
return {
|
|
67
|
+
outputPath: this.outputPath,
|
|
68
|
+
duration: Math.round((this.frameCount / this.fps) * 1000),
|
|
69
|
+
frameCount: this.frameCount,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
abort() {
|
|
73
|
+
this.child.kill("SIGTERM");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function buildFfmpegArgs(options) {
|
|
77
|
+
const { format, fps, outputPath } = options;
|
|
78
|
+
// Input: read concatenated JPEG frames from stdin (JPEG is self-delimiting)
|
|
79
|
+
const inputArgs = ["-y", "-f", "image2pipe", "-c:v", "mjpeg", "-r", String(fps), "-i", "pipe:0"];
|
|
80
|
+
if (format === "gif") {
|
|
81
|
+
return [...inputArgs, "-vf", "fps=15,scale=1280:-1:flags=lanczos", outputPath];
|
|
82
|
+
}
|
|
83
|
+
if (format === "webm") {
|
|
84
|
+
return [...inputArgs, "-c:v", "libvpx-vp9", outputPath];
|
|
85
|
+
}
|
|
86
|
+
// mp4
|
|
87
|
+
return [...inputArgs, "-c:v", "libx264", "-pix_fmt", "yuv420p", outputPath];
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=streaming-encoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming-encoder.js","sourceRoot":"","sources":["../src/streaming-encoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAc9D,MAAM,OAAO,g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C;IAED,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM;IACN,OAAO,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AAC9E,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface RecordOptions {
|
|
2
|
+
width?: number;
|
|
3
|
+
height?: number;
|
|
4
|
+
fps?: number;
|
|
5
|
+
format?: "mp4" | "gif" | "webm" | "embed";
|
|
6
|
+
output?: string;
|
|
7
|
+
realtime?: boolean;
|
|
8
|
+
onProgress?: (percent: number) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface RecordResult {
|
|
11
|
+
outputPath: string;
|
|
12
|
+
duration: number;
|
|
13
|
+
frameCount: number;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@walkrstudio/recorder",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"ws": "^8.18.0",
|
|
18
|
+
"@walkrstudio/studio": "^0.3.0",
|
|
19
|
+
"@walkrstudio/core": "^0.2.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/node": "^22.0.0",
|
|
23
|
+
"@types/ws": "^8.5.14"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc -p tsconfig.json",
|
|
30
|
+
"lint": "biome check src",
|
|
31
|
+
"type-check": "tsc -p tsconfig.json --noEmit",
|
|
32
|
+
"dev": "tsc -p tsconfig.json --watch"
|
|
33
|
+
}
|
|
34
|
+
}
|