@vitroyfix/streamcraft-cli 0.0.0-stage → 0.1.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 +21 -0
- package/README.md +4 -2
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +16 -0
- package/dist/cli.js.map +1 -0
- package/dist/main.d.ts +7 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +311 -0
- package/dist/main.js.map +1 -0
- package/package.json +44 -4
- package/src/cli.ts +18 -0
- package/src/main.ts +384 -0
- package/src/node-ambient.d.ts +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 peter wangimwa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @vitroyfix/streamcraft-cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Command-line interface for Streamcraft: inspect MPEG-TS timelines, repair PTS/DTS/PCR jumps, remux to MP4, and pack/unpack PNG-carrier MP4s.
|
|
4
|
+
|
|
5
|
+
Install the `streamcraft` binary (Node ≥ 20). See the [main README](https://github.com/vitroyfix/streamcraft-js#readme) for monorepo overview, package list, and usage.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;GAGG"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Bin entry for `streamcraft`. Always runs main() so npm global symlinks work
|
|
4
|
+
* (comparing import.meta.url to process.argv[1] fails when argv[1] is a symlink).
|
|
5
|
+
*/
|
|
6
|
+
import { friendlyRuntimeMessage, main } from "./main.js";
|
|
7
|
+
const EXIT_RUNTIME = 1;
|
|
8
|
+
main()
|
|
9
|
+
.then((code) => {
|
|
10
|
+
process.exitCode = code;
|
|
11
|
+
})
|
|
12
|
+
.catch((err) => {
|
|
13
|
+
process.stderr.write(`${friendlyRuntimeMessage(err)}\n`);
|
|
14
|
+
process.exitCode = EXIT_RUNTIME;
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,EAAE,sBAAsB,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEzD,MAAM,YAAY,GAAG,CAAC,CAAC;AAEvB,IAAI,EAAE;KACH,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;IACb,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;AAC1B,CAAC,CAAC;KACD,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IACtB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACzD,OAAO,CAAC,QAAQ,GAAG,YAAY,CAAC;AAClC,CAAC,CAAC,CAAC"}
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* streamcraft CLI library — inspect, fix, remux, pack/unpack MPEG-TS / MP4.
|
|
3
|
+
* The bin entry is src/cli.ts, which always invokes main() (symlink-safe).
|
|
4
|
+
*/
|
|
5
|
+
export declare function friendlyRuntimeMessage(err: unknown): string;
|
|
6
|
+
export declare function main(argv?: string[]): Promise<number>;
|
|
7
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA6JH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAmB3D;AAgGD,wBAAsB,IAAI,CAAC,IAAI,GAAE,MAAM,EAA0B,GAAG,OAAO,CAAC,MAAM,CAAC,CA4GlF"}
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* streamcraft CLI library — inspect, fix, remux, pack/unpack MPEG-TS / MP4.
|
|
3
|
+
* The bin entry is src/cli.ts, which always invokes main() (symlink-safe).
|
|
4
|
+
*/
|
|
5
|
+
import { readFileSync } from "node:fs";
|
|
6
|
+
import { dirname, join } from "node:path";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
import { parseArgs } from "node:util";
|
|
9
|
+
import { fixFile, fixVideo, inspectFile, packCarrier, probeMp4, unpackCarrier, } from "@vitroyfix/streamcraft-node";
|
|
10
|
+
const EXIT_OK = 0;
|
|
11
|
+
const EXIT_RUNTIME = 1;
|
|
12
|
+
const EXIT_USAGE = 2;
|
|
13
|
+
const USAGE = `Usage: streamcraft <command> [options]
|
|
14
|
+
|
|
15
|
+
Commands:
|
|
16
|
+
inspect <in.ts> [--json] Report PES/PCR timeline
|
|
17
|
+
fix <in.ts> <out.ts> Repair timestamp jumps, writing a new file
|
|
18
|
+
fix-video <in.ts> <out.mp4> Repair then remux to MP4 (stream copy)
|
|
19
|
+
probe <in.mp4> [--json] Report per-frame MP4 sample durations
|
|
20
|
+
pack -o <out.mp4> <seg.ts...> [--width N] [--fps N]
|
|
21
|
+
Pack MPEG-TS segments into a PNG-carrier MP4
|
|
22
|
+
unpack -o <dir> <carrier.mp4> Unpack carrier MP4 to segment files
|
|
23
|
+
|
|
24
|
+
Global:
|
|
25
|
+
-h, --help Show this help
|
|
26
|
+
-V, --version Show version
|
|
27
|
+
`;
|
|
28
|
+
function packageVersion() {
|
|
29
|
+
try {
|
|
30
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
31
|
+
const pkgPath = join(here, "..", "package.json");
|
|
32
|
+
const raw = readFileSync(pkgPath, "utf8");
|
|
33
|
+
const pkg = JSON.parse(raw);
|
|
34
|
+
return pkg.version ?? "0.0.0";
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return "0.0.0";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function printUsage(stream = process.stderr) {
|
|
41
|
+
stream.write(USAGE);
|
|
42
|
+
}
|
|
43
|
+
function formatInspectHuman(report) {
|
|
44
|
+
const lines = [];
|
|
45
|
+
lines.push(`MPEG-TS timeline (clock=${report.clockHz} Hz, jump > ${report.threshold} ticks)`);
|
|
46
|
+
lines.push("");
|
|
47
|
+
const pes = report.streams.filter((s) => s.kind === "pes");
|
|
48
|
+
const pcr = report.streams.filter((s) => s.kind === "pcr");
|
|
49
|
+
if (pes.length === 0) {
|
|
50
|
+
lines.push("PES: (none)");
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
for (const stream of pes) {
|
|
54
|
+
lines.push(`PES PID ${stream.pid} (${stream.samples.length} samples)`);
|
|
55
|
+
lines.push(`${"idx".padStart(8)} ${"PTS".padStart(12)} ${"DTS".padStart(12)} ${"step".padStart(12)} ${"jump".padStart(6)}`);
|
|
56
|
+
for (const row of stream.samples) {
|
|
57
|
+
const pts = row.pts === null ? "-" : String(row.pts);
|
|
58
|
+
const dts = row.dts === null ? "-" : String(row.dts);
|
|
59
|
+
const step = row.step === null ? "-" : String(row.step);
|
|
60
|
+
const jump = row.jump ? "YES" : "";
|
|
61
|
+
lines.push(`${row.index.toString().padStart(8)} ${pts.padStart(12)} ${dts.padStart(12)} ${step.padStart(12)} ${jump.padStart(6)}`);
|
|
62
|
+
}
|
|
63
|
+
lines.push("");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (pcr.length === 0) {
|
|
67
|
+
lines.push("PCR: (none)");
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
for (const stream of pcr) {
|
|
71
|
+
lines.push(`PCR PID ${stream.pid} (${stream.samples.length} samples)`);
|
|
72
|
+
lines.push(`${"idx".padStart(8)} ${"pcr_base".padStart(12)} ${"step".padStart(12)} ${"jump".padStart(6)}`);
|
|
73
|
+
for (const row of stream.samples) {
|
|
74
|
+
const pcrBase = row.pcr === null ? "-" : String(row.pcr);
|
|
75
|
+
const step = row.step === null ? "-" : String(row.step);
|
|
76
|
+
const jump = row.jump ? "YES" : "";
|
|
77
|
+
lines.push(`${row.index.toString().padStart(8)} ${pcrBase.padStart(12)} ${step.padStart(12)} ${jump.padStart(6)}`);
|
|
78
|
+
}
|
|
79
|
+
lines.push("");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
lines.push(`Total jumps flagged: ${report.jumpCount}`);
|
|
83
|
+
return lines.join("\n").replace(/\n+$/, "") + "\n";
|
|
84
|
+
}
|
|
85
|
+
function formatProbeHuman(report) {
|
|
86
|
+
const lines = [];
|
|
87
|
+
lines.push("MP4 per-frame duration report");
|
|
88
|
+
lines.push("");
|
|
89
|
+
let outlierTotal = 0;
|
|
90
|
+
if (report.tracks.length === 0) {
|
|
91
|
+
lines.push("Tracks: (none with stts)");
|
|
92
|
+
}
|
|
93
|
+
for (const track of report.tracks) {
|
|
94
|
+
const outliers = track.outlierIndexes.length;
|
|
95
|
+
outlierTotal += outliers;
|
|
96
|
+
lines.push(`Track ${track.trackId}: timescale=${track.timescale}, ` +
|
|
97
|
+
`samples=${track.durations.length}, modal_duration=${track.modalDuration}, ` +
|
|
98
|
+
`outliers=${outliers}`);
|
|
99
|
+
lines.push(`${"sample".padStart(8)} ${"duration".padStart(12)} ${"seconds".padStart(14)} ${"outlier".padStart(8)}`);
|
|
100
|
+
const outlierSet = new Set(track.outlierIndexes);
|
|
101
|
+
for (let i = 0; i < track.durations.length; i++) {
|
|
102
|
+
const dur = track.durations[i] ?? 0;
|
|
103
|
+
const seconds = track.timescale ? dur / track.timescale : 0;
|
|
104
|
+
const mark = outlierSet.has(i) ? "YES" : "";
|
|
105
|
+
lines.push(`${i.toString().padStart(8)} ${dur.toString().padStart(12)} ${seconds.toFixed(6).padStart(14)} ${mark.padStart(8)}`);
|
|
106
|
+
}
|
|
107
|
+
lines.push("");
|
|
108
|
+
}
|
|
109
|
+
lines.push(`Total outliers flagged: ${outlierTotal}`);
|
|
110
|
+
return lines.join("\n").replace(/\n+$/, "") + "\n";
|
|
111
|
+
}
|
|
112
|
+
function formatFixReport(path, report) {
|
|
113
|
+
return (`Wrote ${path} (jumps=${report.jumps}, finalOffset=${report.finalOffset}, ` +
|
|
114
|
+
`pcrsAdjusted=${report.pcrsAdjusted})\n`);
|
|
115
|
+
}
|
|
116
|
+
class UsageError extends Error {
|
|
117
|
+
constructor(message) {
|
|
118
|
+
super(message);
|
|
119
|
+
this.name = "UsageError";
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
export function friendlyRuntimeMessage(err) {
|
|
123
|
+
const code = err && typeof err === "object" && "code" in err
|
|
124
|
+
? String(err.code)
|
|
125
|
+
: "";
|
|
126
|
+
const pathProp = err &&
|
|
127
|
+
typeof err === "object" &&
|
|
128
|
+
"path" in err &&
|
|
129
|
+
typeof err.path === "string"
|
|
130
|
+
? err.path
|
|
131
|
+
: undefined;
|
|
132
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
133
|
+
if (code === "ENOENT" || /ENOENT|no such file or directory/i.test(msg)) {
|
|
134
|
+
const fromMsg = /open '([^']+)'/.exec(msg)?.[1];
|
|
135
|
+
const path = pathProp ?? fromMsg ?? "file";
|
|
136
|
+
return `streamcraft: cannot read ${path}: no such file`;
|
|
137
|
+
}
|
|
138
|
+
return msg;
|
|
139
|
+
}
|
|
140
|
+
async function cmdInspect(positionals, asJson) {
|
|
141
|
+
if (positionals.length !== 1) {
|
|
142
|
+
throw new UsageError("inspect requires exactly one argument: <in.ts>");
|
|
143
|
+
}
|
|
144
|
+
const input = positionals[0];
|
|
145
|
+
const report = await inspectFile(input);
|
|
146
|
+
if (asJson) {
|
|
147
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
process.stdout.write(formatInspectHuman(report));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async function cmdFix(positionals) {
|
|
154
|
+
if (positionals.length !== 2) {
|
|
155
|
+
throw new UsageError("fix requires <in.ts> <out.ts>");
|
|
156
|
+
}
|
|
157
|
+
const [input, output] = positionals;
|
|
158
|
+
const report = await fixFile(input, output);
|
|
159
|
+
process.stdout.write(formatFixReport(output, report));
|
|
160
|
+
}
|
|
161
|
+
async function cmdFixVideo(positionals) {
|
|
162
|
+
if (positionals.length !== 2) {
|
|
163
|
+
throw new UsageError("fix-video requires <in.ts> <out.mp4>");
|
|
164
|
+
}
|
|
165
|
+
const [input, output] = positionals;
|
|
166
|
+
const report = await fixVideo(input, output);
|
|
167
|
+
process.stdout.write(formatFixReport(output, report));
|
|
168
|
+
}
|
|
169
|
+
async function cmdProbe(positionals, asJson) {
|
|
170
|
+
if (positionals.length !== 1) {
|
|
171
|
+
throw new UsageError("probe requires exactly one argument: <in.mp4>");
|
|
172
|
+
}
|
|
173
|
+
const input = positionals[0];
|
|
174
|
+
const report = await probeMp4(input);
|
|
175
|
+
if (asJson) {
|
|
176
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
process.stdout.write(formatProbeHuman(report));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
async function cmdPack(positionals, outPath, width, fps) {
|
|
183
|
+
if (!outPath) {
|
|
184
|
+
throw new UsageError("pack requires -o <out.mp4>");
|
|
185
|
+
}
|
|
186
|
+
if (positionals.length < 1) {
|
|
187
|
+
throw new UsageError("pack requires at least one <seg.ts>");
|
|
188
|
+
}
|
|
189
|
+
const opts = {};
|
|
190
|
+
if (width !== undefined)
|
|
191
|
+
opts.width = width;
|
|
192
|
+
if (fps !== undefined)
|
|
193
|
+
opts.fps = fps;
|
|
194
|
+
await packCarrier(positionals, outPath, opts);
|
|
195
|
+
process.stdout.write(`Packed ${positionals.length} segment(s) -> ${outPath}\n`);
|
|
196
|
+
}
|
|
197
|
+
async function cmdUnpack(positionals, outDir) {
|
|
198
|
+
if (!outDir) {
|
|
199
|
+
throw new UsageError("unpack requires -o <dir>");
|
|
200
|
+
}
|
|
201
|
+
if (positionals.length !== 1) {
|
|
202
|
+
throw new UsageError("unpack requires exactly one <carrier.mp4>");
|
|
203
|
+
}
|
|
204
|
+
const carrier = positionals[0];
|
|
205
|
+
const written = await unpackCarrier(carrier, outDir);
|
|
206
|
+
process.stdout.write(`Unpacked ${written.length} segment(s) -> ${outDir}\n`);
|
|
207
|
+
for (const path of written) {
|
|
208
|
+
process.stdout.write(` ${path}\n`);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function parsePositiveInt(raw, flag) {
|
|
212
|
+
if (raw === undefined)
|
|
213
|
+
return undefined;
|
|
214
|
+
const n = Number(raw);
|
|
215
|
+
if (!Number.isInteger(n) || n <= 0) {
|
|
216
|
+
throw new UsageError(`${flag} must be a positive integer`);
|
|
217
|
+
}
|
|
218
|
+
return n;
|
|
219
|
+
}
|
|
220
|
+
export async function main(argv = process.argv.slice(2)) {
|
|
221
|
+
if (argv.length === 0) {
|
|
222
|
+
printUsage();
|
|
223
|
+
return EXIT_USAGE;
|
|
224
|
+
}
|
|
225
|
+
// Global help/version before command parsing.
|
|
226
|
+
if (argv.includes("-h") || argv.includes("--help")) {
|
|
227
|
+
printUsage(process.stdout);
|
|
228
|
+
return EXIT_OK;
|
|
229
|
+
}
|
|
230
|
+
if (argv.includes("-V") || argv.includes("--version")) {
|
|
231
|
+
process.stdout.write(`${packageVersion()}\n`);
|
|
232
|
+
return EXIT_OK;
|
|
233
|
+
}
|
|
234
|
+
const command = argv[0];
|
|
235
|
+
if (!command || command.startsWith("-")) {
|
|
236
|
+
printUsage();
|
|
237
|
+
return EXIT_USAGE;
|
|
238
|
+
}
|
|
239
|
+
const rest = argv.slice(1);
|
|
240
|
+
const config = {
|
|
241
|
+
args: rest,
|
|
242
|
+
allowPositionals: true,
|
|
243
|
+
strict: true,
|
|
244
|
+
options: {
|
|
245
|
+
json: { type: "boolean", default: false },
|
|
246
|
+
o: { type: "string", short: "o" },
|
|
247
|
+
width: { type: "string" },
|
|
248
|
+
fps: { type: "string" },
|
|
249
|
+
help: { type: "boolean", short: "h", default: false },
|
|
250
|
+
version: { type: "boolean", short: "V", default: false },
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
let values;
|
|
254
|
+
let positionals;
|
|
255
|
+
try {
|
|
256
|
+
const parsed = parseArgs(config);
|
|
257
|
+
values = parsed.values;
|
|
258
|
+
positionals = parsed.positionals;
|
|
259
|
+
}
|
|
260
|
+
catch (err) {
|
|
261
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
262
|
+
process.stderr.write(`${msg}\n`);
|
|
263
|
+
printUsage();
|
|
264
|
+
return EXIT_USAGE;
|
|
265
|
+
}
|
|
266
|
+
if (values.help) {
|
|
267
|
+
printUsage(process.stdout);
|
|
268
|
+
return EXIT_OK;
|
|
269
|
+
}
|
|
270
|
+
if (values.version) {
|
|
271
|
+
process.stdout.write(`${packageVersion()}\n`);
|
|
272
|
+
return EXIT_OK;
|
|
273
|
+
}
|
|
274
|
+
try {
|
|
275
|
+
switch (command) {
|
|
276
|
+
case "inspect":
|
|
277
|
+
await cmdInspect(positionals, Boolean(values.json));
|
|
278
|
+
break;
|
|
279
|
+
case "fix":
|
|
280
|
+
await cmdFix(positionals);
|
|
281
|
+
break;
|
|
282
|
+
case "fix-video":
|
|
283
|
+
await cmdFixVideo(positionals);
|
|
284
|
+
break;
|
|
285
|
+
case "probe":
|
|
286
|
+
await cmdProbe(positionals, Boolean(values.json));
|
|
287
|
+
break;
|
|
288
|
+
case "pack":
|
|
289
|
+
await cmdPack(positionals, values.o, parsePositiveInt(values.width, "--width"), parsePositiveInt(values.fps, "--fps"));
|
|
290
|
+
break;
|
|
291
|
+
case "unpack":
|
|
292
|
+
await cmdUnpack(positionals, values.o);
|
|
293
|
+
break;
|
|
294
|
+
default:
|
|
295
|
+
process.stderr.write(`Unknown command: ${command}\n`);
|
|
296
|
+
printUsage();
|
|
297
|
+
return EXIT_USAGE;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
catch (err) {
|
|
301
|
+
if (err instanceof UsageError) {
|
|
302
|
+
process.stderr.write(`${err.message}\n`);
|
|
303
|
+
printUsage();
|
|
304
|
+
return EXIT_USAGE;
|
|
305
|
+
}
|
|
306
|
+
process.stderr.write(`${friendlyRuntimeMessage(err)}\n`);
|
|
307
|
+
return EXIT_RUNTIME;
|
|
308
|
+
}
|
|
309
|
+
return EXIT_OK;
|
|
310
|
+
}
|
|
311
|
+
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAwB,MAAM,WAAW,CAAC;AAC5D,OAAO,EACL,OAAO,EACP,QAAQ,EACR,WAAW,EACX,WAAW,EACX,QAAQ,EACR,aAAa,GAId,MAAM,6BAA6B,CAAC;AAErC,MAAM,OAAO,GAAG,CAAC,CAAC;AAClB,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,UAAU,GAAG,CAAC,CAAC;AAErB,MAAM,KAAK,GAAG;;;;;;;;;;;;;;CAcb,CAAC;AAEF,SAAS,cAAc;IACrB,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACrD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;QACjD,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAyB,CAAC;QACpD,OAAO,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,SAA4C,OAAO,CAAC,MAAM;IAC5E,MAAM,CAAC,KA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,CAAC,KAAK,CAAC,GAAG,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACzD,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitroyfix/streamcraft-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "CLI for inspecting, repairing, and remuxing MPEG-TS / HLS / MP4 streams",
|
|
5
|
+
"author": "vitroyfix",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"bin": {
|
|
9
|
+
"streamcraft": "dist/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"src",
|
|
14
|
+
"README.md",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc -b",
|
|
22
|
+
"test": "npm run build && node --test test/*.test.js"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@vitroyfix/streamcraft-node": "0.1.0"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"mpeg-ts",
|
|
29
|
+
"hls",
|
|
30
|
+
"mp4",
|
|
31
|
+
"timestamps",
|
|
32
|
+
"pts",
|
|
33
|
+
"dts",
|
|
34
|
+
"pcr",
|
|
35
|
+
"video",
|
|
36
|
+
"cli"
|
|
37
|
+
],
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/vitroyfix/streamcraft-js.git",
|
|
41
|
+
"directory": "packages/cli"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
}
|
|
46
|
+
}
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Bin entry for `streamcraft`. Always runs main() so npm global symlinks work
|
|
4
|
+
* (comparing import.meta.url to process.argv[1] fails when argv[1] is a symlink).
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { friendlyRuntimeMessage, main } from "./main.js";
|
|
8
|
+
|
|
9
|
+
const EXIT_RUNTIME = 1;
|
|
10
|
+
|
|
11
|
+
main()
|
|
12
|
+
.then((code) => {
|
|
13
|
+
process.exitCode = code;
|
|
14
|
+
})
|
|
15
|
+
.catch((err: unknown) => {
|
|
16
|
+
process.stderr.write(`${friendlyRuntimeMessage(err)}\n`);
|
|
17
|
+
process.exitCode = EXIT_RUNTIME;
|
|
18
|
+
});
|
package/src/main.ts
ADDED
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* streamcraft CLI library — inspect, fix, remux, pack/unpack MPEG-TS / MP4.
|
|
3
|
+
* The bin entry is src/cli.ts, which always invokes main() (symlink-safe).
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
|
+
import { dirname, join } from "node:path";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
import { parseArgs, type ParseArgsConfig } from "node:util";
|
|
10
|
+
import {
|
|
11
|
+
fixFile,
|
|
12
|
+
fixVideo,
|
|
13
|
+
inspectFile,
|
|
14
|
+
packCarrier,
|
|
15
|
+
probeMp4,
|
|
16
|
+
unpackCarrier,
|
|
17
|
+
type FixReport,
|
|
18
|
+
type Mp4DurationReport,
|
|
19
|
+
type TimelineReport,
|
|
20
|
+
} from "@vitroyfix/streamcraft-node";
|
|
21
|
+
|
|
22
|
+
const EXIT_OK = 0;
|
|
23
|
+
const EXIT_RUNTIME = 1;
|
|
24
|
+
const EXIT_USAGE = 2;
|
|
25
|
+
|
|
26
|
+
const USAGE = `Usage: streamcraft <command> [options]
|
|
27
|
+
|
|
28
|
+
Commands:
|
|
29
|
+
inspect <in.ts> [--json] Report PES/PCR timeline
|
|
30
|
+
fix <in.ts> <out.ts> Repair timestamp jumps, writing a new file
|
|
31
|
+
fix-video <in.ts> <out.mp4> Repair then remux to MP4 (stream copy)
|
|
32
|
+
probe <in.mp4> [--json] Report per-frame MP4 sample durations
|
|
33
|
+
pack -o <out.mp4> <seg.ts...> [--width N] [--fps N]
|
|
34
|
+
Pack MPEG-TS segments into a PNG-carrier MP4
|
|
35
|
+
unpack -o <dir> <carrier.mp4> Unpack carrier MP4 to segment files
|
|
36
|
+
|
|
37
|
+
Global:
|
|
38
|
+
-h, --help Show this help
|
|
39
|
+
-V, --version Show version
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
function packageVersion(): string {
|
|
43
|
+
try {
|
|
44
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
45
|
+
const pkgPath = join(here, "..", "package.json");
|
|
46
|
+
const raw = readFileSync(pkgPath, "utf8");
|
|
47
|
+
const pkg = JSON.parse(raw) as { version?: string };
|
|
48
|
+
return pkg.version ?? "0.0.0";
|
|
49
|
+
} catch {
|
|
50
|
+
return "0.0.0";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function printUsage(stream: { write(chunk: string): unknown } = process.stderr): void {
|
|
55
|
+
stream.write(USAGE);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function formatInspectHuman(report: TimelineReport): string {
|
|
59
|
+
const lines: string[] = [];
|
|
60
|
+
lines.push(
|
|
61
|
+
`MPEG-TS timeline (clock=${report.clockHz} Hz, jump > ${report.threshold} ticks)`,
|
|
62
|
+
);
|
|
63
|
+
lines.push("");
|
|
64
|
+
|
|
65
|
+
const pes = report.streams.filter((s) => s.kind === "pes");
|
|
66
|
+
const pcr = report.streams.filter((s) => s.kind === "pcr");
|
|
67
|
+
|
|
68
|
+
if (pes.length === 0) {
|
|
69
|
+
lines.push("PES: (none)");
|
|
70
|
+
} else {
|
|
71
|
+
for (const stream of pes) {
|
|
72
|
+
lines.push(`PES PID ${stream.pid} (${stream.samples.length} samples)`);
|
|
73
|
+
lines.push(
|
|
74
|
+
`${"idx".padStart(8)} ${"PTS".padStart(12)} ${"DTS".padStart(12)} ${"step".padStart(12)} ${"jump".padStart(6)}`,
|
|
75
|
+
);
|
|
76
|
+
for (const row of stream.samples) {
|
|
77
|
+
const pts = row.pts === null ? "-" : String(row.pts);
|
|
78
|
+
const dts = row.dts === null ? "-" : String(row.dts);
|
|
79
|
+
const step = row.step === null ? "-" : String(row.step);
|
|
80
|
+
const jump = row.jump ? "YES" : "";
|
|
81
|
+
lines.push(
|
|
82
|
+
`${row.index.toString().padStart(8)} ${pts.padStart(12)} ${dts.padStart(12)} ${step.padStart(12)} ${jump.padStart(6)}`,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
lines.push("");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (pcr.length === 0) {
|
|
90
|
+
lines.push("PCR: (none)");
|
|
91
|
+
} else {
|
|
92
|
+
for (const stream of pcr) {
|
|
93
|
+
lines.push(`PCR PID ${stream.pid} (${stream.samples.length} samples)`);
|
|
94
|
+
lines.push(
|
|
95
|
+
`${"idx".padStart(8)} ${"pcr_base".padStart(12)} ${"step".padStart(12)} ${"jump".padStart(6)}`,
|
|
96
|
+
);
|
|
97
|
+
for (const row of stream.samples) {
|
|
98
|
+
const pcrBase = row.pcr === null ? "-" : String(row.pcr);
|
|
99
|
+
const step = row.step === null ? "-" : String(row.step);
|
|
100
|
+
const jump = row.jump ? "YES" : "";
|
|
101
|
+
lines.push(
|
|
102
|
+
`${row.index.toString().padStart(8)} ${pcrBase.padStart(12)} ${step.padStart(12)} ${jump.padStart(6)}`,
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
lines.push("");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
lines.push(`Total jumps flagged: ${report.jumpCount}`);
|
|
110
|
+
return lines.join("\n").replace(/\n+$/, "") + "\n";
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function formatProbeHuman(report: Mp4DurationReport): string {
|
|
114
|
+
const lines: string[] = [];
|
|
115
|
+
lines.push("MP4 per-frame duration report");
|
|
116
|
+
lines.push("");
|
|
117
|
+
let outlierTotal = 0;
|
|
118
|
+
if (report.tracks.length === 0) {
|
|
119
|
+
lines.push("Tracks: (none with stts)");
|
|
120
|
+
}
|
|
121
|
+
for (const track of report.tracks) {
|
|
122
|
+
const outliers = track.outlierIndexes.length;
|
|
123
|
+
outlierTotal += outliers;
|
|
124
|
+
lines.push(
|
|
125
|
+
`Track ${track.trackId}: timescale=${track.timescale}, ` +
|
|
126
|
+
`samples=${track.durations.length}, modal_duration=${track.modalDuration}, ` +
|
|
127
|
+
`outliers=${outliers}`,
|
|
128
|
+
);
|
|
129
|
+
lines.push(
|
|
130
|
+
`${"sample".padStart(8)} ${"duration".padStart(12)} ${"seconds".padStart(14)} ${"outlier".padStart(8)}`,
|
|
131
|
+
);
|
|
132
|
+
const outlierSet = new Set(track.outlierIndexes);
|
|
133
|
+
for (let i = 0; i < track.durations.length; i++) {
|
|
134
|
+
const dur = track.durations[i] ?? 0;
|
|
135
|
+
const seconds = track.timescale ? dur / track.timescale : 0;
|
|
136
|
+
const mark = outlierSet.has(i) ? "YES" : "";
|
|
137
|
+
lines.push(
|
|
138
|
+
`${i.toString().padStart(8)} ${dur.toString().padStart(12)} ${seconds.toFixed(6).padStart(14)} ${mark.padStart(8)}`,
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
lines.push("");
|
|
142
|
+
}
|
|
143
|
+
lines.push(`Total outliers flagged: ${outlierTotal}`);
|
|
144
|
+
return lines.join("\n").replace(/\n+$/, "") + "\n";
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function formatFixReport(path: string, report: FixReport): string {
|
|
148
|
+
return (
|
|
149
|
+
`Wrote ${path} (jumps=${report.jumps}, finalOffset=${report.finalOffset}, ` +
|
|
150
|
+
`pcrsAdjusted=${report.pcrsAdjusted})\n`
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
class UsageError extends Error {
|
|
155
|
+
constructor(message: string) {
|
|
156
|
+
super(message);
|
|
157
|
+
this.name = "UsageError";
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function friendlyRuntimeMessage(err: unknown): string {
|
|
162
|
+
const code =
|
|
163
|
+
err && typeof err === "object" && "code" in err
|
|
164
|
+
? String((err as { code: unknown }).code)
|
|
165
|
+
: "";
|
|
166
|
+
const pathProp =
|
|
167
|
+
err &&
|
|
168
|
+
typeof err === "object" &&
|
|
169
|
+
"path" in err &&
|
|
170
|
+
typeof (err as { path: unknown }).path === "string"
|
|
171
|
+
? (err as { path: string }).path
|
|
172
|
+
: undefined;
|
|
173
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
174
|
+
if (code === "ENOENT" || /ENOENT|no such file or directory/i.test(msg)) {
|
|
175
|
+
const fromMsg = /open '([^']+)'/.exec(msg)?.[1];
|
|
176
|
+
const path = pathProp ?? fromMsg ?? "file";
|
|
177
|
+
return `streamcraft: cannot read ${path}: no such file`;
|
|
178
|
+
}
|
|
179
|
+
return msg;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async function cmdInspect(positionals: string[], asJson: boolean): Promise<void> {
|
|
183
|
+
if (positionals.length !== 1) {
|
|
184
|
+
throw new UsageError("inspect requires exactly one argument: <in.ts>");
|
|
185
|
+
}
|
|
186
|
+
const input = positionals[0]!;
|
|
187
|
+
const report = await inspectFile(input);
|
|
188
|
+
if (asJson) {
|
|
189
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
190
|
+
} else {
|
|
191
|
+
process.stdout.write(formatInspectHuman(report));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
async function cmdFix(positionals: string[]): Promise<void> {
|
|
196
|
+
if (positionals.length !== 2) {
|
|
197
|
+
throw new UsageError("fix requires <in.ts> <out.ts>");
|
|
198
|
+
}
|
|
199
|
+
const [input, output] = positionals as [string, string];
|
|
200
|
+
const report = await fixFile(input, output);
|
|
201
|
+
process.stdout.write(formatFixReport(output, report));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
async function cmdFixVideo(positionals: string[]): Promise<void> {
|
|
205
|
+
if (positionals.length !== 2) {
|
|
206
|
+
throw new UsageError("fix-video requires <in.ts> <out.mp4>");
|
|
207
|
+
}
|
|
208
|
+
const [input, output] = positionals as [string, string];
|
|
209
|
+
const report = await fixVideo(input, output);
|
|
210
|
+
process.stdout.write(formatFixReport(output, report));
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async function cmdProbe(positionals: string[], asJson: boolean): Promise<void> {
|
|
214
|
+
if (positionals.length !== 1) {
|
|
215
|
+
throw new UsageError("probe requires exactly one argument: <in.mp4>");
|
|
216
|
+
}
|
|
217
|
+
const input = positionals[0]!;
|
|
218
|
+
const report = await probeMp4(input);
|
|
219
|
+
if (asJson) {
|
|
220
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
221
|
+
} else {
|
|
222
|
+
process.stdout.write(formatProbeHuman(report));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
async function cmdPack(
|
|
227
|
+
positionals: string[],
|
|
228
|
+
outPath: string | undefined,
|
|
229
|
+
width: number | undefined,
|
|
230
|
+
fps: number | undefined,
|
|
231
|
+
): Promise<void> {
|
|
232
|
+
if (!outPath) {
|
|
233
|
+
throw new UsageError("pack requires -o <out.mp4>");
|
|
234
|
+
}
|
|
235
|
+
if (positionals.length < 1) {
|
|
236
|
+
throw new UsageError("pack requires at least one <seg.ts>");
|
|
237
|
+
}
|
|
238
|
+
const opts: { width?: number; fps?: number } = {};
|
|
239
|
+
if (width !== undefined) opts.width = width;
|
|
240
|
+
if (fps !== undefined) opts.fps = fps;
|
|
241
|
+
await packCarrier(positionals, outPath, opts);
|
|
242
|
+
process.stdout.write(
|
|
243
|
+
`Packed ${positionals.length} segment(s) -> ${outPath}\n`,
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
async function cmdUnpack(
|
|
248
|
+
positionals: string[],
|
|
249
|
+
outDir: string | undefined,
|
|
250
|
+
): Promise<void> {
|
|
251
|
+
if (!outDir) {
|
|
252
|
+
throw new UsageError("unpack requires -o <dir>");
|
|
253
|
+
}
|
|
254
|
+
if (positionals.length !== 1) {
|
|
255
|
+
throw new UsageError("unpack requires exactly one <carrier.mp4>");
|
|
256
|
+
}
|
|
257
|
+
const carrier = positionals[0]!;
|
|
258
|
+
const written = await unpackCarrier(carrier, outDir);
|
|
259
|
+
process.stdout.write(
|
|
260
|
+
`Unpacked ${written.length} segment(s) -> ${outDir}\n`,
|
|
261
|
+
);
|
|
262
|
+
for (const path of written) {
|
|
263
|
+
process.stdout.write(` ${path}\n`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function parsePositiveInt(raw: string | undefined, flag: string): number | undefined {
|
|
268
|
+
if (raw === undefined) return undefined;
|
|
269
|
+
const n = Number(raw);
|
|
270
|
+
if (!Number.isInteger(n) || n <= 0) {
|
|
271
|
+
throw new UsageError(`${flag} must be a positive integer`);
|
|
272
|
+
}
|
|
273
|
+
return n;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export async function main(argv: string[] = process.argv.slice(2)): Promise<number> {
|
|
277
|
+
if (argv.length === 0) {
|
|
278
|
+
printUsage();
|
|
279
|
+
return EXIT_USAGE;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// Global help/version before command parsing.
|
|
283
|
+
if (argv.includes("-h") || argv.includes("--help")) {
|
|
284
|
+
printUsage(process.stdout);
|
|
285
|
+
return EXIT_OK;
|
|
286
|
+
}
|
|
287
|
+
if (argv.includes("-V") || argv.includes("--version")) {
|
|
288
|
+
process.stdout.write(`${packageVersion()}\n`);
|
|
289
|
+
return EXIT_OK;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const command = argv[0];
|
|
293
|
+
if (!command || command.startsWith("-")) {
|
|
294
|
+
printUsage();
|
|
295
|
+
return EXIT_USAGE;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const rest = argv.slice(1);
|
|
299
|
+
|
|
300
|
+
const config: ParseArgsConfig = {
|
|
301
|
+
args: rest,
|
|
302
|
+
allowPositionals: true,
|
|
303
|
+
strict: true,
|
|
304
|
+
options: {
|
|
305
|
+
json: { type: "boolean", default: false },
|
|
306
|
+
o: { type: "string", short: "o" },
|
|
307
|
+
width: { type: "string" },
|
|
308
|
+
fps: { type: "string" },
|
|
309
|
+
help: { type: "boolean", short: "h", default: false },
|
|
310
|
+
version: { type: "boolean", short: "V", default: false },
|
|
311
|
+
},
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
let values: {
|
|
315
|
+
json?: boolean;
|
|
316
|
+
o?: string;
|
|
317
|
+
width?: string;
|
|
318
|
+
fps?: string;
|
|
319
|
+
help?: boolean;
|
|
320
|
+
version?: boolean;
|
|
321
|
+
};
|
|
322
|
+
let positionals: string[];
|
|
323
|
+
try {
|
|
324
|
+
const parsed = parseArgs(config);
|
|
325
|
+
values = parsed.values as typeof values;
|
|
326
|
+
positionals = parsed.positionals;
|
|
327
|
+
} catch (err) {
|
|
328
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
329
|
+
process.stderr.write(`${msg}\n`);
|
|
330
|
+
printUsage();
|
|
331
|
+
return EXIT_USAGE;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if (values.help) {
|
|
335
|
+
printUsage(process.stdout);
|
|
336
|
+
return EXIT_OK;
|
|
337
|
+
}
|
|
338
|
+
if (values.version) {
|
|
339
|
+
process.stdout.write(`${packageVersion()}\n`);
|
|
340
|
+
return EXIT_OK;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
try {
|
|
344
|
+
switch (command) {
|
|
345
|
+
case "inspect":
|
|
346
|
+
await cmdInspect(positionals, Boolean(values.json));
|
|
347
|
+
break;
|
|
348
|
+
case "fix":
|
|
349
|
+
await cmdFix(positionals);
|
|
350
|
+
break;
|
|
351
|
+
case "fix-video":
|
|
352
|
+
await cmdFixVideo(positionals);
|
|
353
|
+
break;
|
|
354
|
+
case "probe":
|
|
355
|
+
await cmdProbe(positionals, Boolean(values.json));
|
|
356
|
+
break;
|
|
357
|
+
case "pack":
|
|
358
|
+
await cmdPack(
|
|
359
|
+
positionals,
|
|
360
|
+
values.o,
|
|
361
|
+
parsePositiveInt(values.width, "--width"),
|
|
362
|
+
parsePositiveInt(values.fps, "--fps"),
|
|
363
|
+
);
|
|
364
|
+
break;
|
|
365
|
+
case "unpack":
|
|
366
|
+
await cmdUnpack(positionals, values.o);
|
|
367
|
+
break;
|
|
368
|
+
default:
|
|
369
|
+
process.stderr.write(`Unknown command: ${command}\n`);
|
|
370
|
+
printUsage();
|
|
371
|
+
return EXIT_USAGE;
|
|
372
|
+
}
|
|
373
|
+
} catch (err) {
|
|
374
|
+
if (err instanceof UsageError) {
|
|
375
|
+
process.stderr.write(`${err.message}\n`);
|
|
376
|
+
printUsage();
|
|
377
|
+
return EXIT_USAGE;
|
|
378
|
+
}
|
|
379
|
+
process.stderr.write(`${friendlyRuntimeMessage(err)}\n`);
|
|
380
|
+
return EXIT_RUNTIME;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
return EXIT_OK;
|
|
384
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal Node ambient types so the CLI can typecheck before @types/node
|
|
3
|
+
* is installed at the workspace root.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
declare module "node:fs" {
|
|
7
|
+
export function readFileSync(
|
|
8
|
+
path: string,
|
|
9
|
+
encoding: BufferEncoding,
|
|
10
|
+
): string;
|
|
11
|
+
export type BufferEncoding = "utf8" | "utf-8" | string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module "node:path" {
|
|
15
|
+
export function dirname(path: string): string;
|
|
16
|
+
export function join(...paths: string[]): string;
|
|
17
|
+
export function resolve(...paths: string[]): string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare module "node:url" {
|
|
21
|
+
export function fileURLToPath(url: string | URL): string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module "node:util" {
|
|
25
|
+
export interface ParseArgsOptionConfig {
|
|
26
|
+
type: "string" | "boolean";
|
|
27
|
+
short?: string;
|
|
28
|
+
default?: string | boolean | string[] | boolean[];
|
|
29
|
+
multiple?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface ParseArgsConfig {
|
|
32
|
+
args?: string[];
|
|
33
|
+
options?: Record<string, ParseArgsOptionConfig>;
|
|
34
|
+
strict?: boolean;
|
|
35
|
+
allowPositionals?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export function parseArgs(
|
|
38
|
+
config: ParseArgsConfig,
|
|
39
|
+
): {
|
|
40
|
+
values: Record<string, string | boolean | string[] | undefined>;
|
|
41
|
+
positionals: string[];
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare const process: {
|
|
46
|
+
argv: string[];
|
|
47
|
+
exitCode: number | undefined;
|
|
48
|
+
stdout: { write(chunk: string): unknown };
|
|
49
|
+
stderr: { write(chunk: string): unknown };
|
|
50
|
+
env: Record<string, string | undefined>;
|
|
51
|
+
};
|