@muhkoo/theater-transcoder 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/client.js +10 -4
- package/src/worker.js +10 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@muhkoo/theater-transcoder",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Drain a Muhkoo Theater transcode queue with NATIVE ffmpeg. Run it on any machine signed in as you to add transcoding power to your library.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@muhkoo/connect": "0.10.
|
|
28
|
+
"@muhkoo/connect": "0.10.2-alpha.0",
|
|
29
29
|
"ffmpeg-static": "^5.2.0",
|
|
30
30
|
"node-datachannel": "^0.12.0",
|
|
31
31
|
"snarkjs": "^0.7.5",
|
package/src/client.js
CHANGED
|
@@ -55,10 +55,16 @@ export async function connect({ baseUrl, appKey, username, password }) {
|
|
|
55
55
|
apiKey: appKey,
|
|
56
56
|
circuits,
|
|
57
57
|
offline: { enabled: false },
|
|
58
|
-
// P2P on: fetch raw shards from a browser peer over WebRTC
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
|
|
58
|
+
// P2P on: fetch raw shards from a browser peer over WebRTC instead of
|
|
59
|
+
// round-tripping R2. We must let the default STUN server apply (do NOT pass
|
|
60
|
+
// an empty iceServers — that disables STUN entirely, so WebRTC can't gather
|
|
61
|
+
// server-reflexive candidates and the browser↔Node connection never forms).
|
|
62
|
+
// Origin stays the fallback; the block engine runs main-thread in Node.
|
|
63
|
+
p2p: {
|
|
64
|
+
enabled: true,
|
|
65
|
+
...(process.env.MUHKOO_STUN ? { iceServers: [{ urls: process.env.MUHKOO_STUN }] } : {}),
|
|
66
|
+
debug: process.env.MUHKOO_P2P_DEBUG === "1",
|
|
67
|
+
},
|
|
62
68
|
});
|
|
63
69
|
const user = await client.auth.zk.login(username, password);
|
|
64
70
|
return { client, user };
|
package/src/worker.js
CHANGED
|
@@ -75,11 +75,18 @@ export function startWorker({ client, space, appKey, baseUrl }) {
|
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
try {
|
|
78
|
-
log(`claim job ${job._id} "${job.title}" —
|
|
78
|
+
log(`claim job ${job._id} "${job.title}" — fetching raw (P2P → origin)…`);
|
|
79
|
+
// Surface the fetch stage so the uploader's UI shows "Fetching raw… on the
|
|
80
|
+
// transcoder" instead of a silent stall while the bytes transfer.
|
|
81
|
+
await patch(job._id, { phase: "Fetching raw…", progress: 0 }).catch(() => {});
|
|
82
|
+
await postSignal({ kind: "progress", jobId: job._id, progress: 0, phase: "Fetching raw…", worker: WORKER_LABEL });
|
|
79
83
|
// The DB json column can hand back the manifest as a STRING — parse it, or
|
|
80
|
-
//
|
|
84
|
+
// getFile chokes ("manifest.chunks is not iterable").
|
|
81
85
|
const manifest = typeof job.input_manifest === "string" ? JSON.parse(job.input_manifest) : job.input_manifest;
|
|
82
|
-
|
|
86
|
+
// Read through the Space's getFile (NOT client.storage.readByManifest):
|
|
87
|
+
// only the Space file surface has the P2P peer source wired, so this pulls
|
|
88
|
+
// shards from the uploader's browser over WebRTC first, origin as fallback.
|
|
89
|
+
const { data } = await space.getFile(manifest);
|
|
83
90
|
log(`transcoding ${(data.length / 1e6).toFixed(1)}MB…`);
|
|
84
91
|
const { hls_index, duration, size } = await transcodeToHls({
|
|
85
92
|
rawBytes: data, filename: job.filename || "input.mp4", space, onProgress, signal: abort.signal,
|