@lumen5/framefusion 1.3.1 → 2.0.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.
@@ -1,34 +1,34 @@
1
- var $ = (a, i, t) => {
2
- if (!i.has(a))
1
+ var B = (a, s, t) => {
2
+ if (!s.has(a))
3
3
  throw TypeError("Cannot " + t);
4
4
  };
5
- var e = (a, i, t) => ($(a, i, "read from private field"), t ? t.call(a) : i.get(a)), c = (a, i, t) => {
6
- if (i.has(a))
5
+ var e = (a, s, t) => (B(a, s, "read from private field"), t ? t.call(a) : s.get(a)), h = (a, s, t) => {
6
+ if (s.has(a))
7
7
  throw TypeError("Cannot add the same private member more than once");
8
- i instanceof WeakSet ? i.add(a) : i.set(a, t);
9
- }, o = (a, i, t, s) => ($(a, i, "write to private field"), s ? s.call(a, t) : i.set(a, t), t), b = (a, i, t, s) => ({
8
+ s instanceof WeakSet ? s.add(a) : s.set(a, t);
9
+ }, o = (a, s, t, i) => (B(a, s, "write to private field"), i ? i.call(a, t) : s.set(a, t), t), F = (a, s, t, i) => ({
10
10
  set _(r) {
11
- o(a, i, r, t);
11
+ o(a, s, r, t);
12
12
  },
13
13
  get _() {
14
- return e(a, i, s);
15
- }
16
- }), L = (a, i, t) => ($(a, i, "access private method"), t);
17
- import C from "@lumen5/beamcoder";
18
- import q from "path";
19
- import G from "tmp";
20
- import H from "fs-extra";
21
- class X {
22
- static async create(i) {
14
+ return e(a, s, i);
15
+ }
16
+ }), I = (a, s, t) => (B(a, s, "access private method"), t);
17
+ import R from "@lumen5/beamcoder";
18
+ import z from "path";
19
+ import H from "tmp";
20
+ import X from "fs-extra";
21
+ class j {
22
+ static async create(s) {
23
23
  throw new Error("Not implemented");
24
24
  }
25
25
  async init({
26
- inputFileOrUrl: i,
26
+ inputFileOrUrl: s,
27
27
  outputFile: t,
28
- threadCount: s = 8,
28
+ threadCount: i = 8,
29
29
  endTime: r,
30
- interpolateFps: h,
31
- interpolateMode: n
30
+ interpolateFps: n,
31
+ interpolateMode: p
32
32
  }) {
33
33
  throw new Error("Not implemented");
34
34
  }
@@ -41,29 +41,29 @@ class X {
41
41
  get height() {
42
42
  throw new Error("Not implemented");
43
43
  }
44
- async seekToPTS(i) {
44
+ async seekToPTS(s) {
45
45
  throw new Error("Not implemented");
46
46
  }
47
- async getFrameAtTime(i) {
47
+ async getFrameAtTime(s) {
48
48
  throw new Error("Not implemented");
49
49
  }
50
- async getImageDataAtTime(i) {
50
+ async getImageDataAtTime(s) {
51
51
  throw new Error("Not implemented");
52
52
  }
53
- async getFrameAtPts(i) {
53
+ async getFrameAtPts(s) {
54
54
  throw new Error("Not implemented");
55
55
  }
56
- async seekToTime(i) {
56
+ async seekToTime(s) {
57
57
  throw new Error("Not implemented");
58
58
  }
59
59
  /**
60
60
  * Convert a PTS (based on timebase) to PTS (in seconds)
61
61
  */
62
- ptsToTime(i) {
62
+ ptsToTime(s) {
63
63
  throw new Error("Not implemented");
64
64
  }
65
65
  async readFrames({
66
- onFrameAvailable: i,
66
+ onFrameAvailable: s,
67
67
  flush: t = !0
68
68
  } = {
69
69
  flush: !0,
@@ -75,102 +75,102 @@ class X {
75
75
  throw new Error("Not implemented");
76
76
  }
77
77
  }
78
- var x, D, v, _;
79
- class B {
80
- constructor(i) {
81
- c(this, x, void 0);
82
- c(this, D, void 0);
83
- c(this, v, void 0);
84
- c(this, _, void 0);
85
- o(this, x, i);
86
- const t = q.extname(i);
87
- o(this, _, G.fileSync({ postfix: t })), o(this, v, e(this, _).name);
78
+ var N, D, x, E;
79
+ class G {
80
+ constructor(s) {
81
+ h(this, N, void 0);
82
+ h(this, D, void 0);
83
+ h(this, x, void 0);
84
+ h(this, E, void 0);
85
+ o(this, N, s);
86
+ const t = z.extname(s);
87
+ o(this, E, H.fileSync({ postfix: t })), o(this, x, e(this, E).name);
88
88
  }
89
89
  /**
90
90
  * returns the filepath of the downloaded file. If the file has not been downloaded yet, it will be undefined
91
91
  */
92
92
  get filepath() {
93
- return e(this, v);
93
+ return e(this, x);
94
94
  }
95
95
  /**
96
96
  * Downloads the file from the given URL. The file will be downloaded to a temporary file.
97
97
  */
98
98
  async download() {
99
- const i = e(this, x), t = await fetch(i);
99
+ const s = e(this, N), t = await fetch(s);
100
100
  if (!t.ok)
101
101
  throw new Error(
102
- `Failed to fetch ${i}, status: ${t.status}`
102
+ `Failed to fetch ${s}, status: ${t.status}`
103
103
  );
104
- const s = t.headers.get("content-type");
105
- if (!s || !s.includes("video"))
104
+ const i = t.headers.get("content-type");
105
+ if (!i || !i.includes("video"))
106
106
  throw new Error(
107
- `Source ${i}, returned unsupported content type ${s}`
107
+ `Source ${s}, returned unsupported content type ${i}`
108
108
  );
109
- const r = H.createWriteStream(e(this, _).name), h = t.body;
110
- if (!h)
111
- throw new Error(`Response body is null for ${i}`);
112
- const n = h.getReader();
113
- return new Promise((y, p) => {
114
- const m = () => {
115
- n.read().then(({ done: d, value: P }) => {
109
+ const r = X.createWriteStream(e(this, E).name), n = t.body;
110
+ if (!n)
111
+ throw new Error(`Response body is null for ${s}`);
112
+ const p = n.getReader();
113
+ return new Promise((y, m) => {
114
+ const l = () => {
115
+ p.read().then(({ done: d, value: _ }) => {
116
116
  if (d) {
117
117
  r.end(() => {
118
- o(this, v, e(this, _).name), y();
118
+ o(this, x, e(this, E).name), y();
119
119
  });
120
120
  return;
121
121
  }
122
- const O = Buffer.from(P);
123
- r.write(O) ? m() : r.once("drain", m);
124
- }).catch(p);
122
+ const M = Buffer.from(_);
123
+ r.write(M) ? l() : r.once("drain", l);
124
+ }).catch(m);
125
125
  };
126
- r.on("error", p), m();
126
+ r.on("error", m), l();
127
127
  });
128
128
  }
129
129
  clear() {
130
- e(this, _) && e(this, _).removeCallback(), e(this, x) && o(this, x, void 0), e(this, D) && o(this, D, null), e(this, v) && o(this, v, void 0);
130
+ e(this, E) && e(this, E).removeCallback(), e(this, N) && o(this, N, void 0), e(this, D) && o(this, D, null), e(this, x) && o(this, x, void 0);
131
131
  }
132
132
  }
133
- x = new WeakMap(), D = new WeakMap(), v = new WeakMap(), _ = new WeakMap();
134
- const I = 4, j = ({
133
+ N = new WeakMap(), D = new WeakMap(), x = new WeakMap(), E = new WeakMap();
134
+ const V = 4, K = ({
135
135
  demuxer: a,
136
- streamIndex: i,
136
+ streamIndex: s,
137
137
  threadCount: t
138
138
  }) => {
139
- const s = {
140
- width: a.streams[i].codecpar.width,
141
- height: a.streams[i].codecpar.height,
142
- pix_fmt: a.streams[i].codecpar.format,
139
+ const i = {
140
+ width: a.streams[s].codecpar.width,
141
+ height: a.streams[s].codecpar.height,
142
+ pix_fmt: a.streams[s].codecpar.format,
143
143
  thread_count: t
144
144
  };
145
- return a.streams[i].codecpar.name === "vp8" ? C.decoder({
146
- ...s,
145
+ return a.streams[s].codecpar.name === "vp8" ? R.decoder({
146
+ ...i,
147
147
  name: "libvpx"
148
- }) : a.streams[i].codecpar.name === "vp9" ? C.decoder({
149
- ...s,
148
+ }) : a.streams[s].codecpar.name === "vp9" ? R.decoder({
149
+ ...i,
150
150
  name: "libvpx-vp9"
151
- }) : C.decoder({
152
- ...s,
151
+ }) : R.decoder({
152
+ ...i,
153
153
  demuxer: a,
154
- stream_index: i
154
+ stream_index: s
155
155
  });
156
- }, K = async ({
156
+ }, O = async ({
157
157
  stream: a,
158
- outputPixelFormat: i,
158
+ outputPixelFormat: s,
159
159
  interpolateFps: t,
160
- interpolateMode: s = "fast"
160
+ interpolateMode: i = "fast"
161
161
  }) => {
162
162
  if (!a.codecpar.format)
163
163
  return null;
164
164
  let r = [`[in0:v]format=${a.codecpar.format}`];
165
- if (a.codecpar.color_trc === "arib-std-b67" && (r = [...r, "zscale=t=linear:npl=100:p=bt2020,tonemap=tonemap=hable:desat=0,zscale=t=bt709:p=bt709:m=bt709:r=tv"]), t)
166
- if (s === "high-quality")
165
+ if (t)
166
+ if (i === "high-quality")
167
167
  r = [...r, `minterpolate=fps=${t}`];
168
- else if (s === "fast")
168
+ else if (i === "fast")
169
169
  r = [...r, `fps=${t}`];
170
170
  else
171
- throw new Error(`Unexpected interpolation mode: ${s}`);
172
- const h = r.join(", ") + "[out0:v]";
173
- return C.filterer({
171
+ throw new Error(`Unexpected interpolation mode: ${i}`);
172
+ const n = r.join(", ") + "[out0:v]";
173
+ return R.filterer({
174
174
  filterType: "video",
175
175
  inputParams: [
176
176
  {
@@ -185,30 +185,30 @@ const I = 4, j = ({
185
185
  outputParams: [
186
186
  {
187
187
  name: "out0:v",
188
- pixelFormat: i
188
+ pixelFormat: s
189
189
  }
190
190
  ],
191
- filterSpec: h
191
+ filterSpec: n
192
192
  });
193
- }, V = "video", Y = "rgba", Z = 5;
194
- var l, f, N, w, g, E, T, R, u, F, k, S, W;
195
- const M = class extends X {
193
+ }, L = "video", Y = 5;
194
+ var c, f, P, w, g, T, v, C, u, b, k, S, q;
195
+ const $ = class extends j {
196
196
  constructor() {
197
197
  super(...arguments);
198
- c(this, S);
198
+ h(this, S);
199
199
  /**
200
200
  * The demuxer reads the file and outputs packet streams
201
201
  */
202
- c(this, l, null);
202
+ h(this, c, null);
203
203
  /**
204
204
  * The decoder reads packets and can output raw frame data
205
205
  */
206
- c(this, f, null);
206
+ h(this, f, null);
207
207
  /**
208
208
  * Packets can be filtered to change colorspace, fps and add various effects. If there are no colorspace changes or
209
209
  * filters, filter might not be necessary.
210
210
  */
211
- c(this, N, null);
211
+ h(this, P, null);
212
212
  /**
213
213
  * This is where we store filtered frames from each previously processed packet.
214
214
  * We keep these in chronological order. We hang on to them for two reasons:
@@ -216,122 +216,119 @@ const M = class extends X {
216
216
  * 2. so we can return frames close the end of the stream. When such a frame is requested we have to flush (destroy)
217
217
  * the encoder to get the last few frames. This avoids having to re-create an encoder.
218
218
  */
219
- c(this, w, []);
219
+ h(this, w, []);
220
220
  /**
221
221
  * This contains the last raw frames we read from the demuxer. We use it as a starting point for each new query. We
222
222
  * do this ensure we don't skip any frames.
223
223
  */
224
- c(this, g, []);
224
+ h(this, g, []);
225
225
  /**
226
226
  * This contains the last packet we read from the demuxer. We use it as a starting point for each new query. We do
227
227
  * this ensure we don't skip any frames.
228
228
  */
229
- c(this, E, null);
229
+ h(this, T, null);
230
230
  /**
231
231
  * The last target presentation timestamp (PTS) we requested. If we never requested a time(stamp) then this
232
232
  * value is null
233
233
  */
234
- c(this, T, null);
234
+ h(this, v, null);
235
235
  /**
236
236
  * The number of threads to use for decoding
237
237
  */
238
- c(this, R, 8);
238
+ h(this, C, 8);
239
239
  /**
240
240
  * The index of the video stream in the demuxer
241
241
  */
242
- c(this, u, 0);
242
+ h(this, u, 0);
243
243
  /**
244
244
  * The number of packets we've read from the demuxer to complete the frame query
245
245
  * @private
246
246
  */
247
- c(this, F, 0);
247
+ h(this, b, 0);
248
248
  /**
249
249
  * The number of times we've recursively read packets from the demuxer to complete the frame query
250
250
  * @private
251
251
  */
252
- c(this, k, 0);
252
+ h(this, k, 0);
253
253
  }
254
254
  /**
255
255
  * Encoder/Decoder construction is async, so it can't be put in a regular constructor.
256
256
  * Use and await this method to generate an extractor.
257
257
  */
258
258
  static async create(t) {
259
- const s = new M();
260
- return await s.init(t), s;
259
+ const i = new $();
260
+ return await i.init(t), i;
261
261
  }
262
262
  async init({
263
263
  inputFileOrUrl: t,
264
- threadCount: s = 8
264
+ threadCount: i = 8,
265
+ outputPixelFormat: r = "rgba"
265
266
  }) {
266
- if (o(this, R, s), t.startsWith("http")) {
267
- const r = new B(t);
268
- await r.download(), t = r.filepath;
267
+ if (o(this, C, i), t.startsWith("http")) {
268
+ const n = new G(t);
269
+ await n.download(), t = n.filepath;
269
270
  }
270
- if (t.startsWith("file:") || (t = "file:" + t), o(this, l, await C.demuxer(t)), o(this, u, e(this, l).streams.findIndex((r) => r.codecpar.codec_type === V)), e(this, u) === -1)
271
- throw new Error(`File has no ${V} stream!`);
272
- o(this, N, await K({
273
- stream: e(this, l).streams[e(this, u)],
274
- outputPixelFormat: Y
271
+ if (t.startsWith("file:") || (t = "file:" + t), o(this, c, await R.demuxer(t)), o(this, u, e(this, c).streams.findIndex((n) => n.codecpar.codec_type === L)), e(this, u) === -1)
272
+ throw new Error(`File has no ${L} stream!`);
273
+ o(this, P, await O({
274
+ stream: e(this, c).streams[e(this, u)],
275
+ outputPixelFormat: r === "original" ? e(this, c).streams[e(this, u)].codecpar.format : "rgba"
275
276
  }));
276
277
  }
277
- /**
278
- * This is the duration of the first video stream in the file expressed in seconds.
279
- */
280
278
  get duration() {
281
- const t = e(this, l).streams[e(this, u)];
282
- return t.duration !== null ? this.ptsToTime(t.duration) : this.ptsToTime(e(this, l).duration) / 1e3;
279
+ return Math.max(...e(this, c).streams.map((i) => {
280
+ const r = i.time_base;
281
+ return i.duration * r[0] / r[1];
282
+ })) || this.ptsToTime(e(this, c).duration) / 1e3;
283
283
  }
284
284
  /**
285
285
  * Width in pixels
286
286
  */
287
287
  get width() {
288
- return e(this, l).streams[e(this, u)].codecpar.width;
288
+ return e(this, c).streams[e(this, u)].codecpar.width;
289
289
  }
290
290
  /**
291
291
  * Height in pixels
292
292
  */
293
293
  get height() {
294
- return e(this, l).streams[e(this, u)].codecpar.height;
294
+ return e(this, c).streams[e(this, u)].codecpar.height;
295
295
  }
296
296
  /**
297
297
  * Get the beamcoder Frame for a given time in seconds
298
298
  * @param targetTime
299
299
  */
300
300
  async getFrameAtTime(t) {
301
- const s = Math.round(this._timeToPTS(t));
302
- return this._getFrameAtPts(s);
301
+ const i = Math.round(this._timeToPTS(t));
302
+ return this._getFrameAtPts(i);
303
303
  }
304
304
  /**
305
305
  * Get imageData for a given time in seconds
306
306
  * @param targetTime
307
307
  */
308
- async getImageDataAtTime(t, s) {
309
- const r = Math.round(this._timeToPTS(t)), h = await this._getFrameAtPts(r);
310
- if (!h)
311
- return null;
312
- let n = s;
313
- return s || (n = new Uint8ClampedArray(h.width * h.height * I)), this._setFrameDataToImageData(h, n), {
314
- data: n,
315
- width: h.width,
316
- height: h.height
317
- };
308
+ async getImageDataAtTime(t, i) {
309
+ const r = Math.round(this._timeToPTS(t)), n = await this._getFrameAtPts(r);
310
+ return n ? (i && $._setFrameDataToRGBABufferTarget(n, i), {
311
+ width: n.width,
312
+ height: n.height,
313
+ frame: n
314
+ }) : null;
318
315
  }
319
316
  /**
320
317
  * Get the presentation timestamp (PTS) for a given time in seconds
321
318
  */
322
319
  _timeToPTS(t) {
323
- const s = e(this, l).streams[e(this, u)].time_base;
324
- return t * s[1] / s[0];
320
+ const i = e(this, c).streams[e(this, u)].time_base;
321
+ return t * i[1] / i[0];
325
322
  }
326
323
  /**
327
324
  * Get the time in seconds from a given presentation timestamp (PTS)
328
325
  */
329
326
  ptsToTime(t) {
330
- const s = e(this, l).streams[e(this, u)].time_base;
331
- return t * s[0] / s[1];
327
+ const i = e(this, c).streams[e(this, u)].time_base;
328
+ return t * i[0] / i[1];
332
329
  }
333
330
  get packetReadCount() {
334
- return e(this, F);
331
+ return e(this, b);
335
332
  }
336
333
  /**
337
334
  * Get the frame at the given presentation timestamp (PTS)
@@ -340,44 +337,44 @@ const M = class extends X {
340
337
  * the targetPTS. We use it to further move away from the requested PTS to find a frame. The allows use to read
341
338
  * additional packets and find a frame that is closer to the targetPTS.
342
339
  */
343
- async _getFrameAtPts(t, s = 0) {
344
- o(this, F, 0);
345
- const r = 3, h = e(this, w).flat().some((m) => this.ptsToTime(Math.abs(t - m.pts)) < r);
346
- (e(this, T) === null || e(this, T) > t || !h) && (await e(this, l).seek({
340
+ async _getFrameAtPts(t, i = 0) {
341
+ o(this, b, 0);
342
+ const r = 3, n = e(this, w).flat().some((l) => this.ptsToTime(Math.abs(t - l.pts)) < r);
343
+ (e(this, v) === null || e(this, v) > t || !n) && (await e(this, c).seek({
347
344
  stream_index: 0,
348
345
  // even though we specify the stream index, it still seeks all streams
349
- timestamp: t + s,
346
+ timestamp: t + i,
350
347
  any: !1
351
- }), await L(this, S, W).call(this), o(this, E, null), o(this, g, []), o(this, T, t), o(this, w, []));
352
- let n = null, y = -1, p = null;
348
+ }), await I(this, S, q).call(this), o(this, T, null), o(this, g, []), o(this, v, t), o(this, w, []));
349
+ let p = null, y = -1, m = null;
353
350
  if (e(this, w).length > 0) {
354
- const m = e(this, w).flat().find((d) => d.pts <= t);
355
- if (m) {
356
- const d = e(this, w).flat().find((P) => P.pts > m.pts);
357
- if (y = m.pts, p = m, d && d.pts > t || y === t)
358
- return o(this, T, t), p;
351
+ const l = e(this, w).flat().find((d) => d.pts <= t);
352
+ if (l) {
353
+ const d = e(this, w).flat().find((_) => _.pts > l.pts);
354
+ if (y = l.pts, m = l, d && d.pts > t || y === t)
355
+ return o(this, v, t), m;
359
356
  }
360
357
  }
361
- for (!e(this, E) && e(this, g).length === 0 && ({ packet: b(this, E)._, frames: b(this, g)._ } = await this._getNextPacketAndDecodeFrames(), b(this, F)._++); (e(this, E) || e(this, g).length !== 0) && y < t; ) {
358
+ for (!e(this, T) && e(this, g).length === 0 && ({ packet: F(this, T)._, frames: F(this, g)._ } = await this._getNextPacketAndDecodeFrames(), F(this, b)._++); (e(this, T) || e(this, g).length !== 0) && y < t; ) {
362
359
  if (e(this, g).length !== 0) {
363
- n = (await e(this, N).filter([{ name: "in0:v", frames: e(this, g) }])).flatMap((P) => P.frames);
364
- const d = e(this, F) === 1 && n[0].pts > t ? n[0] : n.reverse().find((P) => P.pts <= t);
360
+ p = (await e(this, P).filter([{ name: "in0:v", frames: e(this, g) }])).flatMap((_) => _.frames);
361
+ const d = e(this, b) === 1 && p[0].pts > t ? p[0] : p.reverse().find((_) => _.pts <= t);
365
362
  if (!d)
366
- return p;
367
- if (e(this, w).unshift(n), e(this, w).length > 2 && e(this, w).pop(), y = d == null ? void 0 : d.pts, !p || y <= t)
368
- o(this, T, t), p = d;
363
+ return m;
364
+ if (e(this, w).unshift(p), e(this, w).length > 2 && e(this, w).pop(), y = d == null ? void 0 : d.pts, !m || y <= t)
365
+ o(this, v, t), m = d;
369
366
  else
370
367
  break;
371
368
  }
372
- ({ packet: b(this, E)._, frames: b(this, g)._ } = await this._getNextPacketAndDecodeFrames()), b(this, F)._++;
369
+ ({ packet: F(this, T)._, frames: F(this, g)._ } = await this._getNextPacketAndDecodeFrames()), F(this, b)._++;
373
370
  }
374
- if (!p) {
375
- if (Z < e(this, k))
371
+ if (!m) {
372
+ if (Y < e(this, k))
376
373
  throw Error("No matching frame found");
377
- const m = 0.1, d = this._timeToPTS(m);
378
- b(this, k)._++, p = await this._getFrameAtPts(t, s - d), p && o(this, k, 0);
374
+ const l = 0.1, d = this._timeToPTS(l);
375
+ F(this, k)._++, m = await this._getFrameAtPts(t, i - d), m && o(this, k, 0);
379
376
  }
380
- return p;
377
+ return m;
381
378
  }
382
379
  /**
383
380
  * Get the next packet from the video stream and decode it into frames. Each frame has a presentation time stamp
@@ -386,79 +383,79 @@ const M = class extends X {
386
383
  */
387
384
  async _getNextPacketAndDecodeFrames() {
388
385
  const t = await this._getNextVideoStreamPacket();
389
- let s = null;
390
- t !== null && e(this, f) ? s = await e(this, f).decode(t) : e(this, f) && (s = await e(this, f).flush(), o(this, f, null));
386
+ let i = null;
387
+ t !== null && e(this, f) ? i = await e(this, f).decode(t) : e(this, f) && (i = await e(this, f).flush(), o(this, f, null));
391
388
  let r = [];
392
- return s && s.frames.length !== 0 && (r = s.frames), { packet: t, frames: r };
389
+ return i && i.frames.length !== 0 && (r = i.frames), { packet: t, frames: r };
393
390
  }
394
391
  async _getNextVideoStreamPacket() {
395
- let t = await e(this, l).read();
392
+ let t = await e(this, c).read();
396
393
  for (; t && t.stream_index !== e(this, u); )
397
- if (t = await e(this, l).read(), t === null)
394
+ if (t = await e(this, c).read(), t === null)
398
395
  return null;
399
396
  return t;
400
397
  }
401
- _setFrameDataToImageData(t, s) {
402
- const r = t.linesize, h = t.data[0];
403
- for (let n = 0; n < t.height; n++) {
404
- const y = n * r, p = y + t.width * I, m = h.subarray(y, p), d = n * t.width * I;
405
- s.set(m, d);
398
+ static _setFrameDataToRGBABufferTarget(t, i) {
399
+ const r = t.linesize, n = t.data[0], p = t.width, y = t.height;
400
+ for (let m = 0; m < y; m++) {
401
+ const l = m * r, d = l + p * V, _ = n.subarray(l, d), M = m * p * V;
402
+ i.set(_, M);
406
403
  }
407
404
  }
408
405
  async dispose() {
409
- e(this, f) && (await e(this, f).flush(), o(this, f, null)), e(this, l).forceClose(), o(this, N, null), o(this, w, void 0), o(this, g, []), o(this, E, null), o(this, T, null), o(this, u, 0);
406
+ e(this, f) && (await e(this, f).flush(), o(this, f, null)), e(this, c).forceClose(), o(this, P, null), o(this, w, void 0), o(this, g, []), o(this, T, null), o(this, v, null), o(this, u, 0);
410
407
  }
411
408
  };
412
- let z = M;
413
- l = new WeakMap(), f = new WeakMap(), N = new WeakMap(), w = new WeakMap(), g = new WeakMap(), E = new WeakMap(), T = new WeakMap(), R = new WeakMap(), u = new WeakMap(), F = new WeakMap(), k = new WeakMap(), S = new WeakSet(), W = async function() {
414
- e(this, f) && (await e(this, f).flush(), o(this, f, null)), o(this, f, j({
415
- demuxer: e(this, l),
409
+ let W = $;
410
+ c = new WeakMap(), f = new WeakMap(), P = new WeakMap(), w = new WeakMap(), g = new WeakMap(), T = new WeakMap(), v = new WeakMap(), C = new WeakMap(), u = new WeakMap(), b = new WeakMap(), k = new WeakMap(), S = new WeakSet(), q = async function() {
411
+ e(this, f) && (await e(this, f).flush(), o(this, f, null)), o(this, f, K({
412
+ demuxer: e(this, c),
416
413
  streamIndex: e(this, u),
417
- threadCount: e(this, R)
414
+ threadCount: e(this, C)
418
415
  }));
419
416
  };
420
417
  var A;
421
- class it {
418
+ class et {
422
419
  constructor() {
423
- c(this, A, /* @__PURE__ */ new Map());
420
+ h(this, A, /* @__PURE__ */ new Map());
424
421
  }
425
- get(i) {
422
+ get(s) {
426
423
  const t = this;
427
- let s;
424
+ let i;
428
425
  return {
429
- url: i,
426
+ url: s,
430
427
  get filepath() {
431
- return s;
428
+ return i;
432
429
  },
433
430
  async download() {
434
- let r = e(t, A).get(i);
431
+ let r = e(t, A).get(s);
435
432
  if (r)
436
433
  r.refCount += 1, r.downloadPromise && await r.downloadPromise;
437
434
  else {
438
- const h = new B(i), n = h.download();
435
+ const n = new G(s), p = n.download();
439
436
  r = {
440
- downloader: h,
437
+ downloader: n,
441
438
  refCount: 1,
442
- downloadPromise: n
443
- }, e(t, A).set(i, r);
439
+ downloadPromise: p
440
+ }, e(t, A).set(s, r);
444
441
  try {
445
- await n;
442
+ await p;
446
443
  } finally {
447
444
  r.downloadPromise = void 0;
448
445
  }
449
446
  }
450
- s = e(t, A).get(i).downloader.filepath;
447
+ i = e(t, A).get(s).downloader.filepath;
451
448
  },
452
449
  destroy() {
453
- const r = e(t, A).get(i);
454
- r && (r.refCount -= 1, r.refCount <= 0 && (r.downloader.clear(), e(t, A).delete(i)), s = void 0);
450
+ const r = e(t, A).get(s);
451
+ r && (r.refCount -= 1, r.refCount <= 0 && (r.downloader.clear(), e(t, A).delete(s)), i = void 0);
455
452
  }
456
453
  };
457
454
  }
458
455
  }
459
456
  A = new WeakMap();
460
457
  export {
461
- z as BeamcoderExtractor,
462
- it as CachedVideoDownloader
458
+ W as BeamcoderExtractor,
459
+ et as CachedVideoDownloader
463
460
  };
464
461
  //# sourceMappingURL=framefusion.es.js.map