@meframe/server 0.0.1 → 0.0.3
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/README.md +1 -1
- package/dist/ServerExporter.d.ts +2 -0
- package/dist/ServerExporter.d.ts.map +1 -1
- package/dist/ServerExporter.js +121 -80
- package/dist/ServerExporter.js.map +1 -1
- package/dist/runner/runner-browser.d.ts +21 -0
- package/dist/runner/runner-browser.d.ts.map +1 -0
- package/dist/runner/runner-browser.js +232 -0
- package/dist/runner/runner-browser.js.map +1 -0
- package/dist/runner/runner.d.ts +24 -0
- package/dist/runner/runner.d.ts.map +1 -0
- package/dist/runner/runner.js +73 -0
- package/dist/runner/runner.js.map +1 -0
- package/dist/{runner → runner-browser}/runner.mjs +1122 -1089
- package/dist/types.d.ts +8 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/abort-gate.d.ts +10 -0
- package/dist/utils/abort-gate.d.ts.map +1 -0
- package/dist/utils/abort-gate.js +45 -0
- package/dist/utils/abort-gate.js.map +1 -0
- package/docs/ARCHITECTURE.md +5 -5
- package/docs/INTEGRATION.md +317 -87
- package/package.json +3 -3
- package/dist/browser/puppeteer-core-launcher.d.ts +0 -3
- package/dist/browser/puppeteer-core-launcher.d.ts.map +0 -1
- package/dist/browser/puppeteer-core-launcher.js +0 -12
- package/dist/browser/puppeteer-core-launcher.js.map +0 -1
- package/dist/browser/types.d.ts +0 -21
- package/dist/browser/types.d.ts.map +0 -1
- package/dist/browser/types.js +0 -2
- package/dist/browser/types.js.map +0 -1
- package/dist/mock/MockMultipartObjectStore.d.ts +0 -37
- package/dist/mock/MockMultipartObjectStore.d.ts.map +0 -1
- package/dist/mock/MockMultipartObjectStore.js +0 -34
- package/dist/mock/MockMultipartObjectStore.js.map +0 -1
|
@@ -43,10 +43,10 @@ function Oe(a, e, s, r) {
|
|
|
43
43
|
for (let p = u; p < a.length; p++) {
|
|
44
44
|
const m = a[p];
|
|
45
45
|
if (!m) continue;
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
46
|
+
const y = r(m, p);
|
|
47
|
+
if (y.start >= s)
|
|
48
48
|
break;
|
|
49
|
-
|
|
49
|
+
y.start < s && y.end > e && o.push(m);
|
|
50
50
|
}
|
|
51
51
|
return o;
|
|
52
52
|
}
|
|
@@ -66,8 +66,8 @@ function Ps(a, e, s) {
|
|
|
66
66
|
const u = a[r - 1], o = a[r];
|
|
67
67
|
if (!u || !o)
|
|
68
68
|
return o || u || null;
|
|
69
|
-
const p = s(u), m = s(o),
|
|
70
|
-
return
|
|
69
|
+
const p = s(u), m = s(o), y = Math.abs(e - p), v = Math.abs(e - m);
|
|
70
|
+
return y < v ? u : o;
|
|
71
71
|
}
|
|
72
72
|
const l = a[r];
|
|
73
73
|
return l !== void 0 ? l : null;
|
|
@@ -321,8 +321,8 @@ ${s.map((r) => `${r.path}: ${r.message}`).join(`
|
|
|
321
321
|
if (o && typeof o == "string") {
|
|
322
322
|
const p = this.resources.get(o);
|
|
323
323
|
if (p) {
|
|
324
|
-
const
|
|
325
|
-
|
|
324
|
+
const y = p.clipIds || [];
|
|
325
|
+
y.includes(r.id) || (p.clipIds = [...y, r.id]);
|
|
326
326
|
}
|
|
327
327
|
const m = this.resourceRefCount.get(o) || 0;
|
|
328
328
|
this.resourceRefCount.set(o, m + 1);
|
|
@@ -408,19 +408,19 @@ ${s.map((r) => `${r.path}: ${r.message}`).join(`
|
|
|
408
408
|
)?.params,
|
|
409
409
|
overlayClipStartUs: h.startUs,
|
|
410
410
|
mainClipStartUs: u.startUs
|
|
411
|
-
},
|
|
411
|
+
}, y = ut(
|
|
412
412
|
"renderConfig" in h ? h.renderConfig : void 0,
|
|
413
413
|
`attachment clip ${h.id}`
|
|
414
414
|
);
|
|
415
|
-
|
|
416
|
-
const
|
|
415
|
+
y && (m.renderConfig = y), "resourceId" in h && h.resourceId && (m.resourceId = h.resourceId), "text" in h && h.text && (m.text = h.text);
|
|
416
|
+
const v = {
|
|
417
417
|
id: `${l}-${h.id}-${u.id}`,
|
|
418
418
|
kind: l,
|
|
419
419
|
startUs: o.clipRelativeStart,
|
|
420
420
|
durationUs: o.duration,
|
|
421
421
|
data: m
|
|
422
422
|
};
|
|
423
|
-
u.attachments.push(
|
|
423
|
+
u.attachments.push(v);
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
426
|
}
|
|
@@ -819,10 +819,10 @@ class me {
|
|
|
819
819
|
function Fs() {
|
|
820
820
|
return me.getInstance();
|
|
821
821
|
}
|
|
822
|
-
async function
|
|
822
|
+
async function Ds(a) {
|
|
823
823
|
return Fs().load(a);
|
|
824
824
|
}
|
|
825
|
-
class
|
|
825
|
+
class Di {
|
|
826
826
|
listeners = /* @__PURE__ */ new Map();
|
|
827
827
|
onceListeners = /* @__PURE__ */ new Map();
|
|
828
828
|
/**
|
|
@@ -895,19 +895,19 @@ class Li {
|
|
|
895
895
|
}
|
|
896
896
|
}
|
|
897
897
|
var ft = /* @__PURE__ */ ((a) => (a.Ready = "ready", a.Error = "error", a.Dispose = "dispose", a.Configure = "configure", a.LoadResource = "load_resource", a.ResourceLoaded = "resource_loaded", a.ResourceProgress = "resource_progress", a.ConfigureDemux = "configure_demux", a.AppendBuffer = "append_buffer", a.DemuxSamples = "demux_samples", a.FlushDemux = "flush_demux", a.ConfigureDecode = "configure_decode", a.DecodeChunk = "decode_chunk", a.DecodedFrame = "decoded_frame", a.SeekGop = "seek_gop", a.SetComposition = "set_composition", a.ApplyPatch = "apply_patch", a.RenderFrame = "render_frame", a.ComposeFrameReady = "compose_frame_ready", a.ConfigureEncode = "configure_encode", a.EncodeFrame = "encode_frame", a.EncodeAudio = "encode_audio", a.EncodedChunk = "encoded_chunk", a.FlushEncode = "flush_encode", a.AddChunk = "add_chunk", a.PerformanceStats = "performance_stats", a.RenderWindow = "renderWindow", a.AudioTrackAdd = "audio_track:add", a.AudioTrackRemove = "audio_track:remove", a.AudioTrackUpdate = "audio_track:update", a))(ft || {}), be = /* @__PURE__ */ ((a) => (a.Idle = "idle", a.Initializing = "initializing", a.Ready = "ready", a.Processing = "processing", a.Error = "error", a.Disposed = "disposed", a))(be || {});
|
|
898
|
-
const
|
|
898
|
+
const Li = {
|
|
899
899
|
maxRetries: 3,
|
|
900
900
|
initialDelay: 100,
|
|
901
901
|
maxDelay: 5e3,
|
|
902
902
|
backoffFactor: 2,
|
|
903
903
|
retryableErrors: ["TIMEOUT", "NETWORK_ERROR", "WORKER_BUSY"]
|
|
904
904
|
};
|
|
905
|
-
function
|
|
905
|
+
function Ls(a, e) {
|
|
906
906
|
const { initialDelay: s = 100, maxDelay: r = 5e3, backoffFactor: h = 2 } = e, l = s * Math.pow(h, a - 1);
|
|
907
907
|
return Math.min(l, r);
|
|
908
908
|
}
|
|
909
909
|
function zs(a, e) {
|
|
910
|
-
const { retryableErrors: s =
|
|
910
|
+
const { retryableErrors: s = Li.retryableErrors } = e;
|
|
911
911
|
if (!a) return !1;
|
|
912
912
|
const r = a.code || a.name;
|
|
913
913
|
if (r && s.includes(r))
|
|
@@ -924,7 +924,7 @@ async function Os(a, e) {
|
|
|
924
924
|
} catch (l) {
|
|
925
925
|
if (r = l, !zs(l, e) || h === s)
|
|
926
926
|
throw l;
|
|
927
|
-
const u =
|
|
927
|
+
const u = Ls(h, e);
|
|
928
928
|
await Ns(u);
|
|
929
929
|
}
|
|
930
930
|
throw r || new Error("Retry failed");
|
|
@@ -996,7 +996,7 @@ class Gs {
|
|
|
996
996
|
*/
|
|
997
997
|
async send(e, s, r) {
|
|
998
998
|
const h = r?.maxRetries ?? this.defaultMaxRetries, l = {
|
|
999
|
-
...
|
|
999
|
+
...Li,
|
|
1000
1000
|
maxRetries: h,
|
|
1001
1001
|
...r?.retryConfig
|
|
1002
1002
|
};
|
|
@@ -1022,15 +1022,15 @@ class Gs {
|
|
|
1022
1022
|
reject: p
|
|
1023
1023
|
};
|
|
1024
1024
|
this.pendingRequests.set(h, m);
|
|
1025
|
-
const
|
|
1026
|
-
const
|
|
1027
|
-
if (
|
|
1025
|
+
const y = setTimeout(() => {
|
|
1026
|
+
const v = this.pendingRequests.get(h);
|
|
1027
|
+
if (v) {
|
|
1028
1028
|
this.pendingRequests.delete(h);
|
|
1029
1029
|
const k = new Error(`Request timeout: ${h} ${e} (${l}ms)`);
|
|
1030
|
-
k.code = "TIMEOUT",
|
|
1030
|
+
k.code = "TIMEOUT", v.reject(k);
|
|
1031
1031
|
}
|
|
1032
1032
|
}, l);
|
|
1033
|
-
m.timeoutId =
|
|
1033
|
+
m.timeoutId = y, r?.transfer ? this.port.postMessage(u, r.transfer) : this.port.postMessage(u);
|
|
1034
1034
|
});
|
|
1035
1035
|
}
|
|
1036
1036
|
/**
|
|
@@ -1268,27 +1268,27 @@ class Gs {
|
|
|
1268
1268
|
return;
|
|
1269
1269
|
}
|
|
1270
1270
|
if (o === "stream_start" && m?.streamId) {
|
|
1271
|
-
const
|
|
1272
|
-
start(
|
|
1273
|
-
s.set(m.streamId, { controller:
|
|
1271
|
+
const y = new ReadableStream({
|
|
1272
|
+
start(v) {
|
|
1273
|
+
s.set(m.streamId, { controller: v, metadata: m });
|
|
1274
1274
|
}
|
|
1275
1275
|
});
|
|
1276
|
-
e(
|
|
1276
|
+
e(y, m);
|
|
1277
1277
|
return;
|
|
1278
1278
|
}
|
|
1279
1279
|
if (o === "stream_chunk" && m?.streamId && s.has(m.streamId)) {
|
|
1280
|
-
const
|
|
1281
|
-
|
|
1280
|
+
const y = s.get(m.streamId);
|
|
1281
|
+
y && y.controller.enqueue(m.chunk);
|
|
1282
1282
|
return;
|
|
1283
1283
|
}
|
|
1284
1284
|
if (o === "stream_end" && m?.streamId && s.has(m.streamId)) {
|
|
1285
|
-
const
|
|
1286
|
-
|
|
1285
|
+
const y = s.get(m.streamId);
|
|
1286
|
+
y && (y.controller.close(), s.delete(m.streamId));
|
|
1287
1287
|
return;
|
|
1288
1288
|
}
|
|
1289
1289
|
if (o === "stream_error" && m?.streamId && s.has(m.streamId)) {
|
|
1290
|
-
const
|
|
1291
|
-
|
|
1290
|
+
const y = s.get(m.streamId);
|
|
1291
|
+
y && (y.controller.error(new Error(String(m.error || "stream error"))), s.delete(m.streamId));
|
|
1292
1292
|
return;
|
|
1293
1293
|
}
|
|
1294
1294
|
typeof r == "function" && r.call(this.port, l);
|
|
@@ -1296,7 +1296,7 @@ class Gs {
|
|
|
1296
1296
|
this.port.onmessage = h;
|
|
1297
1297
|
}
|
|
1298
1298
|
}
|
|
1299
|
-
var
|
|
1299
|
+
var O = /* @__PURE__ */ ((a) => (a.ModelSet = "model:set", a.ResourceAdd = "resource:add", a.ResourceUpdate = "resource:update", a.ResourceRemove = "resource:remove", a.ResourceStageChange = "resource:state", a.ResourceFirstFrameReady = "resource:firstFrameReady", a.LoadStart = "load:start", a.LoadProgress = "load:progress", a.LoadComplete = "load:complete", a.LoadError = "load:error", a.DemuxStart = "demux:start", a.DemuxProgress = "demux:progress", a.DemuxComplete = "demux:complete", a.DemuxError = "demux:error", a.DecodeStart = "decode:start", a.DecodeProgress = "decode:progress", a.DecodeComplete = "decode:complete", a.DecodeError = "decode:error", a.ComposeStart = "compose:start", a.ComposeProgress = "compose:progress", a.ComposeComplete = "compose:complete", a.ComposeFrameReady = "compose:frameReady", a.ComposeFrameDropped = "compose:frameDropped", a.EncodeChunkReady = "encode:chunkReady", a.EncodeChunkError = "encode:chunkError", a.CacheHit = "cache:hit", a.CacheMiss = "cache:miss", a.CacheEvict = "cache:evict", a.CacheWrite = "cache:write", a.CacheCover = "cache:cover", a.ExportPreparing = "export:preparing", a.ExportStart = "export:start", a.ExportProgress = "export:progress", a.ExportComplete = "export:complete", a.ExportError = "export:error", a.CompositionUpdated = "composition:updated", a.PatchApplied = "patch:applied", a.Ready = "ready", a.WorkerStarted = "worker:started", a.WorkerReady = "worker:ready", a.WorkerError = "worker:error", a.WorkerRestarted = "worker:restarted", a.PlaybackBuffering = "playback:buffering", a.PlaybackPlay = "playback:play", a.PlaybackPause = "playback:pause", a.PlaybackStop = "playback:stop", a.PlaybackSeek = "playback:seek", a.PlaybackEnded = "playback:ended", a.PlaybackTimeUpdate = "playback:timeupdate", a.PlaybackRateChange = "playback:ratechange", a.PlaybackVolumeChange = "playback:volumechange", a.PlaybackError = "playback:error", a.PlaybackStarted = "playback:started", a.PlaybackPaused = "playback:paused", a.PlaybackSeeked = "playback:seeked", a.Error = "error", a.PluginLoaded = "plugin:loaded", a.PluginError = "plugin:error", a.PluginUnloaded = "plugin:unloaded", a.ClipActivated = "clip:activated", a.ClipDeactivated = "clip:deactivated", a))(O || {});
|
|
1300
1300
|
class $s {
|
|
1301
1301
|
worker;
|
|
1302
1302
|
channel;
|
|
@@ -1314,7 +1314,7 @@ class $s {
|
|
|
1314
1314
|
}
|
|
1315
1315
|
setupErrorHandling() {
|
|
1316
1316
|
this.worker.onerror = (e) => {
|
|
1317
|
-
this.state = "error", this.lastError = new Error(e.message || "Worker error"), this.onError?.(this.lastError), this.eventBus.emit(
|
|
1317
|
+
this.state = "error", this.lastError = new Error(e.message || "Worker error"), this.onError?.(this.lastError), this.eventBus.emit(O.WorkerError, {
|
|
1318
1318
|
type: this.type,
|
|
1319
1319
|
workerId: this.getWorkerId(),
|
|
1320
1320
|
error: this.lastError
|
|
@@ -1322,13 +1322,13 @@ class $s {
|
|
|
1322
1322
|
};
|
|
1323
1323
|
}
|
|
1324
1324
|
async initialize(e) {
|
|
1325
|
-
this.eventBus.emit(
|
|
1325
|
+
this.eventBus.emit(O.WorkerStarted, {
|
|
1326
1326
|
type: this.type,
|
|
1327
1327
|
workerId: this.getWorkerId()
|
|
1328
1328
|
}), await this.channel.send(ft.Configure, {
|
|
1329
1329
|
config: e,
|
|
1330
1330
|
initial: !0
|
|
1331
|
-
}), this.eventBus.emit(
|
|
1331
|
+
}), this.eventBus.emit(O.WorkerReady, {
|
|
1332
1332
|
type: this.type,
|
|
1333
1333
|
workerId: this.getWorkerId()
|
|
1334
1334
|
});
|
|
@@ -1819,9 +1819,9 @@ class ur {
|
|
|
1819
1819
|
if (o)
|
|
1820
1820
|
return this.mergeTaskMeta(o, { isPreload: s, sessionId: r, clipId: h, trackId: l });
|
|
1821
1821
|
let p, m;
|
|
1822
|
-
const
|
|
1822
|
+
const y = new Promise((k, x) => {
|
|
1823
1823
|
p = k, m = x;
|
|
1824
|
-
}),
|
|
1824
|
+
}), v = {
|
|
1825
1825
|
resourceId: e.id,
|
|
1826
1826
|
resource: e,
|
|
1827
1827
|
bytesLoaded: 0,
|
|
@@ -1831,17 +1831,17 @@ class ur {
|
|
|
1831
1831
|
sessionId: r,
|
|
1832
1832
|
clipId: h,
|
|
1833
1833
|
trackId: l,
|
|
1834
|
-
promise:
|
|
1834
|
+
promise: y,
|
|
1835
1835
|
resolve: p,
|
|
1836
1836
|
reject: m
|
|
1837
1837
|
};
|
|
1838
|
-
if (
|
|
1839
|
-
this.taskQueue.push(
|
|
1838
|
+
if (v.isPreload)
|
|
1839
|
+
this.taskQueue.push(v);
|
|
1840
1840
|
else {
|
|
1841
1841
|
const k = this.taskQueue.findIndex((x) => x.isPreload);
|
|
1842
|
-
k < 0 ? this.taskQueue.push(
|
|
1842
|
+
k < 0 ? this.taskQueue.push(v) : this.taskQueue.splice(k, 0, v);
|
|
1843
1843
|
}
|
|
1844
|
-
return this.queuedTasks.set(
|
|
1844
|
+
return this.queuedTasks.set(v.resourceId, v), v;
|
|
1845
1845
|
}
|
|
1846
1846
|
/**
|
|
1847
1847
|
* Get next task from queue if under concurrent limit
|
|
@@ -1910,9 +1910,9 @@ class ur {
|
|
|
1910
1910
|
this.activeTasks.clear(), this.taskQueue = [], this.queuedTasks.clear(), this.concurrentCount = 0, this.concurrentPreloadCount = 0;
|
|
1911
1911
|
}
|
|
1912
1912
|
}
|
|
1913
|
-
class
|
|
1913
|
+
class De {
|
|
1914
1914
|
constructor(e, s) {
|
|
1915
|
-
this.onProgress = e, this.highWaterMark = s?.highWaterMark ??
|
|
1915
|
+
this.onProgress = e, this.highWaterMark = s?.highWaterMark ?? De.DEFAULT_HIGH_WATER_MARK, this.chunkSize = s?.chunkSize ?? De.DEFAULT_CHUNK_SIZE, this.retryCount = s?.retryCount ?? De.DEFAULT_RETRY_COUNT, this.retryDelay = s?.retryDelay ?? De.DEFAULT_RETRY_DELAY;
|
|
1916
1916
|
}
|
|
1917
1917
|
// Default values as fallback
|
|
1918
1918
|
static DEFAULT_HIGH_WATER_MARK = 1024 * 1024;
|
|
@@ -2096,27 +2096,27 @@ function pr(a) {
|
|
|
2096
2096
|
var zi = {};
|
|
2097
2097
|
(function(a) {
|
|
2098
2098
|
var e = /* @__PURE__ */ function() {
|
|
2099
|
-
var t = /* @__PURE__ */ new Date(), n = 4, c = 3, d = 2, f = 1, g = n,
|
|
2100
|
-
setLogLevel: function(
|
|
2101
|
-
|
|
2099
|
+
var t = /* @__PURE__ */ new Date(), n = 4, c = 3, d = 2, f = 1, g = n, _ = {
|
|
2100
|
+
setLogLevel: function(w) {
|
|
2101
|
+
w == this.debug ? g = f : w == this.info ? g = d : w == this.warn ? g = c : (w == this.error, g = n);
|
|
2102
2102
|
},
|
|
2103
|
-
debug: function(
|
|
2104
|
-
console.debug === void 0 && (console.debug = console.log), f >= g && console.debug("[" + e.getDurationString(/* @__PURE__ */ new Date() - t, 1e3) + "]", "[" +
|
|
2103
|
+
debug: function(w, C) {
|
|
2104
|
+
console.debug === void 0 && (console.debug = console.log), f >= g && console.debug("[" + e.getDurationString(/* @__PURE__ */ new Date() - t, 1e3) + "]", "[" + w + "]", C);
|
|
2105
2105
|
},
|
|
2106
|
-
log: function(
|
|
2107
|
-
this.debug(
|
|
2106
|
+
log: function(w, C) {
|
|
2107
|
+
this.debug(w.msg);
|
|
2108
2108
|
},
|
|
2109
|
-
info: function(
|
|
2110
|
-
d >= g && console.info("[" + e.getDurationString(/* @__PURE__ */ new Date() - t, 1e3) + "]", "[" +
|
|
2109
|
+
info: function(w, C) {
|
|
2110
|
+
d >= g && console.info("[" + e.getDurationString(/* @__PURE__ */ new Date() - t, 1e3) + "]", "[" + w + "]", C);
|
|
2111
2111
|
},
|
|
2112
|
-
warn: function(
|
|
2113
|
-
c >= g && console.warn("[" + e.getDurationString(/* @__PURE__ */ new Date() - t, 1e3) + "]", "[" +
|
|
2112
|
+
warn: function(w, C) {
|
|
2113
|
+
c >= g && console.warn("[" + e.getDurationString(/* @__PURE__ */ new Date() - t, 1e3) + "]", "[" + w + "]", C);
|
|
2114
2114
|
},
|
|
2115
|
-
error: function(
|
|
2116
|
-
n >= g && console.error("[" + e.getDurationString(/* @__PURE__ */ new Date() - t, 1e3) + "]", "[" +
|
|
2115
|
+
error: function(w, C) {
|
|
2116
|
+
n >= g && console.error("[" + e.getDurationString(/* @__PURE__ */ new Date() - t, 1e3) + "]", "[" + w + "]", C);
|
|
2117
2117
|
}
|
|
2118
2118
|
};
|
|
2119
|
-
return
|
|
2119
|
+
return _;
|
|
2120
2120
|
}();
|
|
2121
2121
|
e.getDurationString = function(t, n) {
|
|
2122
2122
|
var c;
|
|
@@ -2126,12 +2126,12 @@ var zi = {};
|
|
|
2126
2126
|
return P.join(".");
|
|
2127
2127
|
}
|
|
2128
2128
|
t < 0 ? (c = !0, t = -t) : c = !1;
|
|
2129
|
-
var f = n || 1, g = t / f,
|
|
2130
|
-
g -=
|
|
2131
|
-
var
|
|
2132
|
-
g -=
|
|
2129
|
+
var f = n || 1, g = t / f, _ = Math.floor(g / 3600);
|
|
2130
|
+
g -= _ * 3600;
|
|
2131
|
+
var w = Math.floor(g / 60);
|
|
2132
|
+
g -= w * 60;
|
|
2133
2133
|
var C = g * 1e3;
|
|
2134
|
-
return g = Math.floor(g), C -= g * 1e3, C = Math.floor(C), (c ? "-" : "") +
|
|
2134
|
+
return g = Math.floor(g), C -= g * 1e3, C = Math.floor(C), (c ? "-" : "") + _ + ":" + d(w, 2) + ":" + d(g, 2) + "." + d(C, 3);
|
|
2135
2135
|
}, e.printRanges = function(t) {
|
|
2136
2136
|
var n = t.length;
|
|
2137
2137
|
if (n > 0) {
|
|
@@ -2418,8 +2418,8 @@ var zi = {};
|
|
|
2418
2418
|
var n = this._dataView.getFloat64(this.position, t ?? this.endianness);
|
|
2419
2419
|
return this.position += 8, n;
|
|
2420
2420
|
}, r.endianness = new Int8Array(new Int16Array([1]).buffer)[0] > 0, r.memcpy = function(t, n, c, d, f) {
|
|
2421
|
-
var g = new Uint8Array(t, n, f),
|
|
2422
|
-
g.set(
|
|
2421
|
+
var g = new Uint8Array(t, n, f), _ = new Uint8Array(c, d, f);
|
|
2422
|
+
g.set(_);
|
|
2423
2423
|
}, r.arrayToNative = function(t, n) {
|
|
2424
2424
|
return n == this.endianness ? t : this.flipArrayEndianness(t);
|
|
2425
2425
|
}, r.nativeToEndian = function(t, n) {
|
|
@@ -2630,7 +2630,7 @@ var zi = {};
|
|
|
2630
2630
|
return t(this, n);
|
|
2631
2631
|
if (typeof t == "object" && !(t instanceof Array))
|
|
2632
2632
|
return t.set(this, n, c);
|
|
2633
|
-
var f = null, g = "ASCII",
|
|
2633
|
+
var f = null, g = "ASCII", _ = this.position;
|
|
2634
2634
|
switch (typeof t == "string" && /:/.test(t) && (d = t.split(":"), t = d[0], f = parseInt(d[1])), typeof t == "string" && /,/.test(t) && (d = t.split(","), t = d[0], g = parseInt(d[1])), t) {
|
|
2635
2635
|
case "uint8":
|
|
2636
2636
|
this.writeUint8(n);
|
|
@@ -2709,15 +2709,15 @@ var zi = {};
|
|
|
2709
2709
|
break;
|
|
2710
2710
|
default:
|
|
2711
2711
|
if (t.length == 3) {
|
|
2712
|
-
for (var
|
|
2713
|
-
this.writeType(
|
|
2712
|
+
for (var w = t[1], C = 0; C < n.length; C++)
|
|
2713
|
+
this.writeType(w, n[C]);
|
|
2714
2714
|
break;
|
|
2715
2715
|
} else {
|
|
2716
2716
|
this.writeStruct(t, n);
|
|
2717
2717
|
break;
|
|
2718
2718
|
}
|
|
2719
2719
|
}
|
|
2720
|
-
f != null && (this.position =
|
|
2720
|
+
f != null && (this.position = _, this._realloc(f), this.position = _ + f);
|
|
2721
2721
|
}, r.prototype.writeUint64 = function(t) {
|
|
2722
2722
|
var n = Math.floor(t / h);
|
|
2723
2723
|
this.writeUint32(n), this.writeUint32(t & 4294967295);
|
|
@@ -2794,12 +2794,12 @@ var zi = {};
|
|
|
2794
2794
|
}
|
|
2795
2795
|
n && (e.debug("MultiBufferStream", "Appending new buffer (fileStart: " + t.fileStart + " - Length: " + t.byteLength + ")"), this.buffers.push(t), c === 0 && (this.buffer = t));
|
|
2796
2796
|
}, l.prototype.logBufferLevel = function(t) {
|
|
2797
|
-
var n, c, d, f, g = [],
|
|
2797
|
+
var n, c, d, f, g = [], _, w = "";
|
|
2798
2798
|
for (d = 0, f = 0, n = 0; n < this.buffers.length; n++)
|
|
2799
|
-
c = this.buffers[n], n === 0 ? (
|
|
2800
|
-
g.length > 0 && (
|
|
2799
|
+
c = this.buffers[n], n === 0 ? (_ = {}, g.push(_), _.start = c.fileStart, _.end = c.fileStart + c.byteLength, w += "[" + _.start + "-") : _.end === c.fileStart ? _.end = c.fileStart + c.byteLength : (_ = {}, _.start = c.fileStart, w += g[g.length - 1].end - 1 + "], [" + _.start + "-", _.end = c.fileStart + c.byteLength, g.push(_)), d += c.usedBytes, f += c.byteLength;
|
|
2800
|
+
g.length > 0 && (w += _.end - 1 + "]");
|
|
2801
2801
|
var C = t ? e.info : e.debug;
|
|
2802
|
-
this.buffers.length === 0 ? C("MultiBufferStream", "No more buffer in memory") : C("MultiBufferStream", "" + this.buffers.length + " stored buffer(s) (" + d + "/" + f + " bytes), continuous ranges: " +
|
|
2802
|
+
this.buffers.length === 0 ? C("MultiBufferStream", "No more buffer in memory") : C("MultiBufferStream", "" + this.buffers.length + " stored buffer(s) (" + d + "/" + f + " bytes), continuous ranges: " + w);
|
|
2803
2803
|
}, l.prototype.cleanBuffers = function() {
|
|
2804
2804
|
var t, n;
|
|
2805
2805
|
for (t = 0; t < this.buffers.length; t++)
|
|
@@ -2850,42 +2850,42 @@ var zi = {};
|
|
|
2850
2850
|
}, a.MultiBufferStream = l;
|
|
2851
2851
|
var u = function() {
|
|
2852
2852
|
var t = 3, n = 4, c = 5, d = 6, f = [];
|
|
2853
|
-
f[t] = "ES_Descriptor", f[n] = "DecoderConfigDescriptor", f[c] = "DecoderSpecificInfo", f[d] = "SLConfigDescriptor", this.getDescriptorName = function(
|
|
2854
|
-
return f[
|
|
2853
|
+
f[t] = "ES_Descriptor", f[n] = "DecoderConfigDescriptor", f[c] = "DecoderSpecificInfo", f[d] = "SLConfigDescriptor", this.getDescriptorName = function(w) {
|
|
2854
|
+
return f[w];
|
|
2855
2855
|
};
|
|
2856
|
-
var g = this,
|
|
2857
|
-
return this.parseOneDescriptor = function(
|
|
2856
|
+
var g = this, _ = {};
|
|
2857
|
+
return this.parseOneDescriptor = function(w) {
|
|
2858
2858
|
var C = 0, U, E, I;
|
|
2859
|
-
for (U =
|
|
2860
|
-
C = (C << 7) + (I & 127), I =
|
|
2861
|
-
return C = (C << 7) + (I & 127), e.debug("MPEG4DescriptorParser", "Found " + (f[U] || "Descriptor " + U) + ", size " + C + " at position " +
|
|
2862
|
-
},
|
|
2863
|
-
this.tag =
|
|
2864
|
-
},
|
|
2865
|
-
this.data =
|
|
2866
|
-
},
|
|
2859
|
+
for (U = w.readUint8(), I = w.readUint8(); I & 128; )
|
|
2860
|
+
C = (C << 7) + (I & 127), I = w.readUint8();
|
|
2861
|
+
return C = (C << 7) + (I & 127), e.debug("MPEG4DescriptorParser", "Found " + (f[U] || "Descriptor " + U) + ", size " + C + " at position " + w.getPosition()), f[U] ? E = new _[f[U]](C) : E = new _.Descriptor(C), E.parse(w), E;
|
|
2862
|
+
}, _.Descriptor = function(w, C) {
|
|
2863
|
+
this.tag = w, this.size = C, this.descs = [];
|
|
2864
|
+
}, _.Descriptor.prototype.parse = function(w) {
|
|
2865
|
+
this.data = w.readUint8Array(this.size);
|
|
2866
|
+
}, _.Descriptor.prototype.findDescriptor = function(w) {
|
|
2867
2867
|
for (var C = 0; C < this.descs.length; C++)
|
|
2868
|
-
if (this.descs[C].tag ==
|
|
2868
|
+
if (this.descs[C].tag == w)
|
|
2869
2869
|
return this.descs[C];
|
|
2870
2870
|
return null;
|
|
2871
|
-
},
|
|
2872
|
-
for (var C =
|
|
2873
|
-
var U = g.parseOneDescriptor(
|
|
2871
|
+
}, _.Descriptor.prototype.parseRemainingDescriptors = function(w) {
|
|
2872
|
+
for (var C = w.position; w.position < C + this.size; ) {
|
|
2873
|
+
var U = g.parseOneDescriptor(w);
|
|
2874
2874
|
this.descs.push(U);
|
|
2875
2875
|
}
|
|
2876
|
-
},
|
|
2877
|
-
|
|
2878
|
-
},
|
|
2879
|
-
if (this.ES_ID =
|
|
2880
|
-
var C =
|
|
2881
|
-
this.URL =
|
|
2876
|
+
}, _.ES_Descriptor = function(w) {
|
|
2877
|
+
_.Descriptor.call(this, t, w);
|
|
2878
|
+
}, _.ES_Descriptor.prototype = new _.Descriptor(), _.ES_Descriptor.prototype.parse = function(w) {
|
|
2879
|
+
if (this.ES_ID = w.readUint16(), this.flags = w.readUint8(), this.size -= 3, this.flags & 128 ? (this.dependsOn_ES_ID = w.readUint16(), this.size -= 2) : this.dependsOn_ES_ID = 0, this.flags & 64) {
|
|
2880
|
+
var C = w.readUint8();
|
|
2881
|
+
this.URL = w.readString(C), this.size -= C + 1;
|
|
2882
2882
|
} else
|
|
2883
2883
|
this.URL = "";
|
|
2884
|
-
this.flags & 32 ? (this.OCR_ES_ID =
|
|
2885
|
-
},
|
|
2884
|
+
this.flags & 32 ? (this.OCR_ES_ID = w.readUint16(), this.size -= 2) : this.OCR_ES_ID = 0, this.parseRemainingDescriptors(w);
|
|
2885
|
+
}, _.ES_Descriptor.prototype.getOTI = function(w) {
|
|
2886
2886
|
var C = this.findDescriptor(n);
|
|
2887
2887
|
return C ? C.oti : 0;
|
|
2888
|
-
},
|
|
2888
|
+
}, _.ES_Descriptor.prototype.getAudioConfig = function(w) {
|
|
2889
2889
|
var C = this.findDescriptor(n);
|
|
2890
2890
|
if (!C) return null;
|
|
2891
2891
|
var U = C.findDescriptor(c);
|
|
@@ -2894,15 +2894,15 @@ var zi = {};
|
|
|
2894
2894
|
return E === 31 && U.data.length >= 2 && (E = 32 + ((U.data[0] & 7) << 3) + ((U.data[1] & 224) >> 5)), E;
|
|
2895
2895
|
} else
|
|
2896
2896
|
return null;
|
|
2897
|
-
},
|
|
2898
|
-
|
|
2899
|
-
},
|
|
2900
|
-
this.oti =
|
|
2901
|
-
},
|
|
2902
|
-
|
|
2903
|
-
},
|
|
2904
|
-
|
|
2905
|
-
},
|
|
2897
|
+
}, _.DecoderConfigDescriptor = function(w) {
|
|
2898
|
+
_.Descriptor.call(this, n, w);
|
|
2899
|
+
}, _.DecoderConfigDescriptor.prototype = new _.Descriptor(), _.DecoderConfigDescriptor.prototype.parse = function(w) {
|
|
2900
|
+
this.oti = w.readUint8(), this.streamType = w.readUint8(), this.upStream = (this.streamType >> 1 & 1) !== 0, this.streamType = this.streamType >>> 2, this.bufferSize = w.readUint24(), this.maxBitrate = w.readUint32(), this.avgBitrate = w.readUint32(), this.size -= 13, this.parseRemainingDescriptors(w);
|
|
2901
|
+
}, _.DecoderSpecificInfo = function(w) {
|
|
2902
|
+
_.Descriptor.call(this, c, w);
|
|
2903
|
+
}, _.DecoderSpecificInfo.prototype = new _.Descriptor(), _.SLConfigDescriptor = function(w) {
|
|
2904
|
+
_.Descriptor.call(this, d, w);
|
|
2905
|
+
}, _.SLConfigDescriptor.prototype = new _.Descriptor(), this;
|
|
2906
2906
|
};
|
|
2907
2907
|
a.MPEG4DescriptorParser = u;
|
|
2908
2908
|
var o = {
|
|
@@ -3067,7 +3067,7 @@ var zi = {};
|
|
|
3067
3067
|
}
|
|
3068
3068
|
return n;
|
|
3069
3069
|
}, o.parseOneBox = function(t, n, c) {
|
|
3070
|
-
var d, f = t.getPosition(), g = 0,
|
|
3070
|
+
var d, f = t.getPosition(), g = 0, _, w;
|
|
3071
3071
|
if (t.getEndPosition() - f < 8)
|
|
3072
3072
|
return e.debug("BoxParser", "Not enough data in stream to parse the type and size of the box"), { code: o.ERR_NOT_ENOUGH_DATA };
|
|
3073
3073
|
if (c && c < 8)
|
|
@@ -3076,7 +3076,7 @@ var zi = {};
|
|
|
3076
3076
|
if (e.debug("BoxParser", "Found box of type '" + U + "' and size " + C + " at position " + f), g = 8, U == "uuid") {
|
|
3077
3077
|
if (t.getEndPosition() - t.getPosition() < 16 || c - g < 16)
|
|
3078
3078
|
return t.seek(f), e.debug("BoxParser", "Not enough bytes left in the parent box to parse a UUID box"), { code: o.ERR_NOT_ENOUGH_DATA };
|
|
3079
|
-
|
|
3079
|
+
w = o.parseUUID(t), g += 16, E = w;
|
|
3080
3080
|
}
|
|
3081
3081
|
if (C == 1) {
|
|
3082
3082
|
if (t.getEndPosition() - t.getPosition() < 8 || c && c - g < 8)
|
|
@@ -3088,7 +3088,7 @@ var zi = {};
|
|
|
3088
3088
|
else if (U !== "mdat")
|
|
3089
3089
|
return e.error("BoxParser", "Unlimited box size not supported for type: '" + U + "'"), d = new o.Box(U, C), { code: o.OK, box: d, size: d.size };
|
|
3090
3090
|
}
|
|
3091
|
-
return C !== 0 && C < g ? (e.error("BoxParser", "Box of type " + U + " has an invalid size " + C + " (too small to be a box)"), { code: o.ERR_NOT_ENOUGH_DATA, type: U, size: C, hdr_size: g, start: f }) : C !== 0 && c && C > c ? (e.error("BoxParser", "Box of type '" + U + "' has a size " + C + " greater than its container size " + c), { code: o.ERR_NOT_ENOUGH_DATA, type: U, size: C, hdr_size: g, start: f }) : C !== 0 && f + C > t.getEndPosition() ? (t.seek(f), e.info("BoxParser", "Not enough data in stream to parse the entire '" + U + "' box"), { code: o.ERR_NOT_ENOUGH_DATA, type: U, size: C, hdr_size: g, start: f }) : n ? { code: o.OK, type: U, size: C, hdr_size: g, start: f } : (o[U + "Box"] ? d = new o[U + "Box"](C) : U !== "uuid" ? (e.warn("BoxParser", "Unknown box type: '" + U + "'"), d = new o.Box(U, C), d.has_unparsed_data = !0) : o.UUIDBoxes[
|
|
3091
|
+
return C !== 0 && C < g ? (e.error("BoxParser", "Box of type " + U + " has an invalid size " + C + " (too small to be a box)"), { code: o.ERR_NOT_ENOUGH_DATA, type: U, size: C, hdr_size: g, start: f }) : C !== 0 && c && C > c ? (e.error("BoxParser", "Box of type '" + U + "' has a size " + C + " greater than its container size " + c), { code: o.ERR_NOT_ENOUGH_DATA, type: U, size: C, hdr_size: g, start: f }) : C !== 0 && f + C > t.getEndPosition() ? (t.seek(f), e.info("BoxParser", "Not enough data in stream to parse the entire '" + U + "' box"), { code: o.ERR_NOT_ENOUGH_DATA, type: U, size: C, hdr_size: g, start: f }) : n ? { code: o.OK, type: U, size: C, hdr_size: g, start: f } : (o[U + "Box"] ? d = new o[U + "Box"](C) : U !== "uuid" ? (e.warn("BoxParser", "Unknown box type: '" + U + "'"), d = new o.Box(U, C), d.has_unparsed_data = !0) : o.UUIDBoxes[w] ? d = new o.UUIDBoxes[w](C) : (e.warn("BoxParser", "Unknown uuid type: '" + w + "'"), d = new o.Box(U, C), d.uuid = w, d.has_unparsed_data = !0), d.hdr_size = g, d.start = f, d.write === o.Box.prototype.write && d.type !== "mdat" && (e.info("BoxParser", "'" + E + "' box writing not yet implemented, keeping unparsed data in memory for later write"), d.parseDataAndRewind(t)), d.parse(t), _ = t.getPosition() - (d.start + d.size), _ < 0 ? (e.warn("BoxParser", "Parsing of box '" + E + "' did not read the entire indicated box data size (missing " + -_ + " bytes), seeking forward"), t.seek(d.start + d.size)) : _ > 0 && (e.error("BoxParser", "Parsing of box '" + E + "' read " + _ + " more bytes than the indicated box data size, seeking backwards"), d.size !== 0 && t.seek(d.start + d.size)), { code: o.OK, box: d, size: d.size });
|
|
3092
3092
|
}, o.Box.prototype.parse = function(t) {
|
|
3093
3093
|
this.type != "mdat" ? this.data = t.readUint8Array(this.size - this.hdr_size) : this.size === 0 ? t.seek(t.getEndPosition()) : t.seek(this.start + this.size);
|
|
3094
3094
|
}, o.Box.prototype.parseDataAndRewind = function(t) {
|
|
@@ -3242,8 +3242,8 @@ var zi = {};
|
|
|
3242
3242
|
for (var c = 0; c < this.num_ind_sub + 1; c++) {
|
|
3243
3243
|
var d = {};
|
|
3244
3244
|
this.ind_subs.push(d);
|
|
3245
|
-
var f = t.readUint8(), g = t.readUint8(),
|
|
3246
|
-
d.fscod = f >> 6, d.bsid = f >> 1 & 31, d.bsmod = (f & 1) << 4 | g >> 4 & 15, d.acmod = g >> 1 & 7, d.lfeon = g & 1, d.num_dep_sub =
|
|
3245
|
+
var f = t.readUint8(), g = t.readUint8(), _ = t.readUint8();
|
|
3246
|
+
d.fscod = f >> 6, d.bsid = f >> 1 & 31, d.bsmod = (f & 1) << 4 | g >> 4 & 15, d.acmod = g >> 1 & 7, d.lfeon = g & 1, d.num_dep_sub = _ >> 1 & 15, d.num_dep_sub > 0 && (d.chan_loc = (_ & 1) << 8 | t.readUint8());
|
|
3247
3247
|
}
|
|
3248
3248
|
}), o.createFullBoxCtor("dfLa", "FLACSpecificBox", function(t) {
|
|
3249
3249
|
var n = 127, c = 128, d = [], f = [
|
|
@@ -3257,11 +3257,11 @@ var zi = {};
|
|
|
3257
3257
|
"RESERVED"
|
|
3258
3258
|
];
|
|
3259
3259
|
do {
|
|
3260
|
-
var g = t.readUint8(),
|
|
3260
|
+
var g = t.readUint8(), _ = Math.min(
|
|
3261
3261
|
g & n,
|
|
3262
3262
|
f.length - 1
|
|
3263
3263
|
);
|
|
3264
|
-
if (
|
|
3264
|
+
if (_ ? t.readUint8Array(t.readUint24()) : (t.readUint8Array(13), this.samplerate = t.readUint32() >> 12, t.readUint8Array(20)), d.push(f[_]), g & c)
|
|
3265
3265
|
break;
|
|
3266
3266
|
} while (!0);
|
|
3267
3267
|
this.numMetadataBlocks = d.length + " (" + d.join(", ") + ")";
|
|
@@ -3345,9 +3345,9 @@ var zi = {};
|
|
|
3345
3345
|
var I = this[E];
|
|
3346
3346
|
U += "<tr>", U += "<td rowspan='" + I.length + "'>" + I.completeness + "</td>", U += "<td rowspan='" + I.length + "'>" + I.nalu_type + "</td>";
|
|
3347
3347
|
for (var P = 0; P < I.length; P++) {
|
|
3348
|
-
var
|
|
3349
|
-
P !== 0 && (U += "<tr>"), U += "<td>", U +=
|
|
3350
|
-
return
|
|
3348
|
+
var B = I[P];
|
|
3349
|
+
P !== 0 && (U += "<tr>"), U += "<td>", U += B.data.reduce(function(R, L) {
|
|
3350
|
+
return R + L.toString(16).padStart(2, "0");
|
|
3351
3351
|
}, "0x"), U += "</td></tr>";
|
|
3352
3352
|
}
|
|
3353
3353
|
}
|
|
@@ -3355,12 +3355,12 @@ var zi = {};
|
|
|
3355
3355
|
};
|
|
3356
3356
|
var g = t.readUint8();
|
|
3357
3357
|
for (n = 0; n < g; n++) {
|
|
3358
|
-
var
|
|
3359
|
-
this.nalu_arrays.push(
|
|
3360
|
-
var
|
|
3361
|
-
for (c = 0; c <
|
|
3358
|
+
var _ = [];
|
|
3359
|
+
this.nalu_arrays.push(_), f = t.readUint8(), _.completeness = (f & 128) >> 7, _.nalu_type = f & 63;
|
|
3360
|
+
var w = t.readUint16();
|
|
3361
|
+
for (c = 0; c < w; c++) {
|
|
3362
3362
|
var C = {};
|
|
3363
|
-
|
|
3363
|
+
_.push(C), d = t.readUint16(), C.data = t.readUint8Array(d);
|
|
3364
3364
|
}
|
|
3365
3365
|
}
|
|
3366
3366
|
}), o.createFullBoxCtor("iinf", "ItemInfoBox", function(t) {
|
|
@@ -3404,44 +3404,44 @@ var zi = {};
|
|
|
3404
3404
|
}
|
|
3405
3405
|
var g = t.readUint16();
|
|
3406
3406
|
f.extents = [];
|
|
3407
|
-
for (var
|
|
3408
|
-
var
|
|
3409
|
-
if (f.extents.push(
|
|
3407
|
+
for (var _ = 0; _ < g; _++) {
|
|
3408
|
+
var w = {};
|
|
3409
|
+
if (f.extents.push(w), this.version === 1 || this.version === 2)
|
|
3410
3410
|
switch (this.index_size) {
|
|
3411
3411
|
case 0:
|
|
3412
|
-
|
|
3412
|
+
w.extent_index = 0;
|
|
3413
3413
|
break;
|
|
3414
3414
|
case 4:
|
|
3415
|
-
|
|
3415
|
+
w.extent_index = t.readUint32();
|
|
3416
3416
|
break;
|
|
3417
3417
|
case 8:
|
|
3418
|
-
|
|
3418
|
+
w.extent_index = t.readUint64();
|
|
3419
3419
|
break;
|
|
3420
3420
|
default:
|
|
3421
3421
|
throw "Error reading extent index";
|
|
3422
3422
|
}
|
|
3423
3423
|
switch (this.offset_size) {
|
|
3424
3424
|
case 0:
|
|
3425
|
-
|
|
3425
|
+
w.extent_offset = 0;
|
|
3426
3426
|
break;
|
|
3427
3427
|
case 4:
|
|
3428
|
-
|
|
3428
|
+
w.extent_offset = t.readUint32();
|
|
3429
3429
|
break;
|
|
3430
3430
|
case 8:
|
|
3431
|
-
|
|
3431
|
+
w.extent_offset = t.readUint64();
|
|
3432
3432
|
break;
|
|
3433
3433
|
default:
|
|
3434
3434
|
throw "Error reading extent index";
|
|
3435
3435
|
}
|
|
3436
3436
|
switch (this.length_size) {
|
|
3437
3437
|
case 0:
|
|
3438
|
-
|
|
3438
|
+
w.extent_length = 0;
|
|
3439
3439
|
break;
|
|
3440
3440
|
case 4:
|
|
3441
|
-
|
|
3441
|
+
w.extent_length = t.readUint32();
|
|
3442
3442
|
break;
|
|
3443
3443
|
case 8:
|
|
3444
|
-
|
|
3444
|
+
w.extent_length = t.readUint64();
|
|
3445
3445
|
break;
|
|
3446
3446
|
default:
|
|
3447
3447
|
throw "Error reading extent index";
|
|
@@ -3464,8 +3464,8 @@ var zi = {};
|
|
|
3464
3464
|
this.associations.push(d), this.version < 1 ? d.id = t.readUint16() : d.id = t.readUint32();
|
|
3465
3465
|
var f = t.readUint8();
|
|
3466
3466
|
for (d.props = [], c = 0; c < f; c++) {
|
|
3467
|
-
var g = t.readUint8(),
|
|
3468
|
-
d.props.push(
|
|
3467
|
+
var g = t.readUint8(), _ = {};
|
|
3468
|
+
d.props.push(_), _.essential = (g & 128) >> 7 === 1, this.flags & 1 ? _.property_index = (g & 127) << 8 | t.readUint8() : _.property_index = g & 127;
|
|
3469
3469
|
}
|
|
3470
3470
|
}
|
|
3471
3471
|
}), o.createFullBoxCtor("iref", "ItemReferenceBox", function(t) {
|
|
@@ -3515,9 +3515,9 @@ var zi = {};
|
|
|
3515
3515
|
var I = this[E];
|
|
3516
3516
|
U += "<tr>", U += "<td rowspan='" + I.length + "'>" + I.completeness + "</td>", U += "<td rowspan='" + I.length + "'>" + I.nalu_type + "</td>";
|
|
3517
3517
|
for (var P = 0; P < I.length; P++) {
|
|
3518
|
-
var
|
|
3519
|
-
P !== 0 && (U += "<tr>"), U += "<td>", U +=
|
|
3520
|
-
return
|
|
3518
|
+
var B = I[P];
|
|
3519
|
+
P !== 0 && (U += "<tr>"), U += "<td>", U += B.data.reduce(function(R, L) {
|
|
3520
|
+
return R + L.toString(16).padStart(2, "0");
|
|
3521
3521
|
}, "0x"), U += "</td></tr>";
|
|
3522
3522
|
}
|
|
3523
3523
|
}
|
|
@@ -3527,12 +3527,12 @@ var zi = {};
|
|
|
3527
3527
|
for (n = 0; n < f; n++) {
|
|
3528
3528
|
var g = [];
|
|
3529
3529
|
this.nalu_arrays.push(g), d = t.readUint8(), g.completeness = (d & 128) >> 7, g.nalu_type = d & 63;
|
|
3530
|
-
var
|
|
3531
|
-
for (c = 0; c <
|
|
3532
|
-
var
|
|
3533
|
-
g.push(
|
|
3530
|
+
var _ = t.readUint16();
|
|
3531
|
+
for (c = 0; c < _; c++) {
|
|
3532
|
+
var w = {};
|
|
3533
|
+
g.push(w);
|
|
3534
3534
|
var C = t.readUint16();
|
|
3535
|
-
|
|
3535
|
+
w.data = t.readUint8Array(C);
|
|
3536
3536
|
}
|
|
3537
3537
|
}
|
|
3538
3538
|
}), o.createBoxCtor("lsel", "LayerSelectorProperty", function(t) {
|
|
@@ -3710,10 +3710,10 @@ var zi = {};
|
|
|
3710
3710
|
this.entries.push(d), d.sample_count = t.readInt32(), d.group_description_index = t.readInt32();
|
|
3711
3711
|
}
|
|
3712
3712
|
});
|
|
3713
|
-
function
|
|
3713
|
+
function y(t, n) {
|
|
3714
3714
|
this.bad_pixel_row = t, this.bad_pixel_column = n;
|
|
3715
3715
|
}
|
|
3716
|
-
|
|
3716
|
+
y.prototype.toString = function() {
|
|
3717
3717
|
return "[row: " + this.bad_pixel_row + ", column: " + this.bad_pixel_column + "]";
|
|
3718
3718
|
}, o.createFullBoxCtor("sbpm", "SensorBadPixelsMapBox", function(t) {
|
|
3719
3719
|
var n;
|
|
@@ -3726,7 +3726,7 @@ var zi = {};
|
|
|
3726
3726
|
this.bad_columns.push(t.readUint32());
|
|
3727
3727
|
for (n = 0; n < this.num_bad_pixels; n++) {
|
|
3728
3728
|
var d = t.readUint32(), f = t.readUint32();
|
|
3729
|
-
this.bad_pixels.push(new
|
|
3729
|
+
this.bad_pixels.push(new y(d, f));
|
|
3730
3730
|
}
|
|
3731
3731
|
}), o.createFullBoxCtor("schm", "SchemeTypeBox", function(t) {
|
|
3732
3732
|
this.scheme_type = t.readString(4), this.scheme_version = t.readUint32(), this.flags & 1 && (this.scheme_uri = t.readString(this.size - this.hdr_size - 8));
|
|
@@ -3802,8 +3802,8 @@ var zi = {};
|
|
|
3802
3802
|
var d = {};
|
|
3803
3803
|
this.subsegments.push(d), d.ranges = [];
|
|
3804
3804
|
for (var f = t.readUint32(), g = 0; g < f; g++) {
|
|
3805
|
-
var
|
|
3806
|
-
d.ranges.push(
|
|
3805
|
+
var _ = {};
|
|
3806
|
+
d.ranges.push(_), _.level = t.readUint8(), _.range_size = t.readUint24();
|
|
3807
3807
|
}
|
|
3808
3808
|
}
|
|
3809
3809
|
}), o.createFullBoxCtor("stco", "ChunkOffsetBox", function(t) {
|
|
@@ -3895,8 +3895,8 @@ var zi = {};
|
|
|
3895
3895
|
var g = {};
|
|
3896
3896
|
if (this.entries[n] = g, g.sample_delta = t.readUint32(), g.subsamples = [], f = t.readUint16(), f > 0)
|
|
3897
3897
|
for (c = 0; c < f; c++) {
|
|
3898
|
-
var
|
|
3899
|
-
g.subsamples.push(
|
|
3898
|
+
var _ = {};
|
|
3899
|
+
g.subsamples.push(_), this.version == 1 ? _.size = t.readUint32() : _.size = t.readUint16(), _.priority = t.readUint8(), _.discardable = t.readUint8(), _.codec_specific_parameters = t.readUint32();
|
|
3900
3900
|
}
|
|
3901
3901
|
}
|
|
3902
3902
|
}), o.createFullBoxCtor("tenc", "TrackEncryptionBox", function(t) {
|
|
@@ -4043,15 +4043,15 @@ var zi = {};
|
|
|
4043
4043
|
var n, c, d = {
|
|
4044
4044
|
held_bits: void 0,
|
|
4045
4045
|
num_held_bits: 0,
|
|
4046
|
-
stream_read_1_bytes: function(
|
|
4047
|
-
this.held_bits =
|
|
4046
|
+
stream_read_1_bytes: function(B) {
|
|
4047
|
+
this.held_bits = B.readUint8(), this.num_held_bits = 8;
|
|
4048
4048
|
},
|
|
4049
|
-
stream_read_2_bytes: function(
|
|
4050
|
-
this.held_bits =
|
|
4049
|
+
stream_read_2_bytes: function(B) {
|
|
4050
|
+
this.held_bits = B.readUint16(), this.num_held_bits = 16;
|
|
4051
4051
|
},
|
|
4052
|
-
extract_bits: function(
|
|
4053
|
-
var
|
|
4054
|
-
return this.num_held_bits -=
|
|
4052
|
+
extract_bits: function(B) {
|
|
4053
|
+
var R = this.held_bits >> this.num_held_bits - B & (1 << B) - 1;
|
|
4054
|
+
return this.num_held_bits -= B, R;
|
|
4055
4055
|
}
|
|
4056
4056
|
};
|
|
4057
4057
|
if (d.stream_read_1_bytes(t), d.extract_bits(5), this.lengthSizeMinusOne = d.extract_bits(2), this.ptl_present_flag = d.extract_bits(1), this.ptl_present_flag) {
|
|
@@ -4069,8 +4069,8 @@ var zi = {};
|
|
|
4069
4069
|
d.extract_bits(6);
|
|
4070
4070
|
if (this.num_sublayers > 1) {
|
|
4071
4071
|
for (d.stream_read_1_bytes(t), this.ptl_sublayer_present_mask = 0, c = this.num_sublayers - 2; c >= 0; --c) {
|
|
4072
|
-
var
|
|
4073
|
-
this.ptl_sublayer_present_mask |=
|
|
4072
|
+
var _ = d.extract_bits(1);
|
|
4073
|
+
this.ptl_sublayer_present_mask |= _ << c;
|
|
4074
4074
|
}
|
|
4075
4075
|
for (c = this.num_sublayers; c <= 8 && this.num_sublayers > 1; ++c)
|
|
4076
4076
|
d.extract_bits(1);
|
|
@@ -4083,14 +4083,14 @@ var zi = {};
|
|
|
4083
4083
|
}
|
|
4084
4084
|
this.max_picture_width = t.readUint16(), this.max_picture_height = t.readUint16(), this.avg_frame_rate = t.readUint16();
|
|
4085
4085
|
}
|
|
4086
|
-
var
|
|
4086
|
+
var w = 12, C = 13;
|
|
4087
4087
|
this.nalu_arrays = [];
|
|
4088
4088
|
var U = t.readUint8();
|
|
4089
4089
|
for (n = 0; n < U; n++) {
|
|
4090
4090
|
var E = [];
|
|
4091
4091
|
this.nalu_arrays.push(E), d.stream_read_1_bytes(t), E.completeness = d.extract_bits(1), d.extract_bits(2), E.nalu_type = d.extract_bits(5);
|
|
4092
4092
|
var I = 1;
|
|
4093
|
-
for (E.nalu_type != C && E.nalu_type !=
|
|
4093
|
+
for (E.nalu_type != C && E.nalu_type != w && (I = t.readUint16()), c = 0; c < I; c++) {
|
|
4094
4094
|
var P = t.readUint16();
|
|
4095
4095
|
E.push({
|
|
4096
4096
|
data: t.readUint8Array(P),
|
|
@@ -4192,13 +4192,13 @@ var zi = {};
|
|
|
4192
4192
|
c = ".CA";
|
|
4193
4193
|
else {
|
|
4194
4194
|
c = ".C";
|
|
4195
|
-
var
|
|
4195
|
+
var _ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", w = 0, C = 0;
|
|
4196
4196
|
for (t = 0; t <= g; ++t)
|
|
4197
|
-
for (
|
|
4198
|
-
var U =
|
|
4199
|
-
c +=
|
|
4197
|
+
for (w = w << 8 | d[t], C += 8; C >= 5; ) {
|
|
4198
|
+
var U = w >> C - 5 & 31;
|
|
4199
|
+
c += _[U], C -= 5, w &= (1 << C) - 1;
|
|
4200
4200
|
}
|
|
4201
|
-
C && (
|
|
4201
|
+
C && (w <<= 5 - C, c += _[w & 31]);
|
|
4202
4202
|
}
|
|
4203
4203
|
}
|
|
4204
4204
|
n += c;
|
|
@@ -4473,27 +4473,27 @@ var zi = {};
|
|
|
4473
4473
|
}
|
|
4474
4474
|
return !0;
|
|
4475
4475
|
};
|
|
4476
|
-
var
|
|
4476
|
+
var v = function() {
|
|
4477
4477
|
};
|
|
4478
|
-
|
|
4478
|
+
v.prototype.parseSample = function(t) {
|
|
4479
4479
|
var n, c, d = new s(t.buffer);
|
|
4480
4480
|
for (n = []; !d.isEos(); )
|
|
4481
4481
|
c = o.parseOneBox(d, !1), c.code === o.OK && c.box.type === "vttc" && n.push(c.box);
|
|
4482
4482
|
return n;
|
|
4483
|
-
},
|
|
4483
|
+
}, v.prototype.getText = function(t, n, c) {
|
|
4484
4484
|
function d(U, E, I) {
|
|
4485
4485
|
return I = I || "0", U = U + "", U.length >= E ? U : new Array(E - U.length + 1).join(I) + U;
|
|
4486
4486
|
}
|
|
4487
4487
|
function f(U) {
|
|
4488
|
-
var E = Math.floor(U / 3600), I = Math.floor((U - E * 3600) / 60), P = Math.floor(U - E * 3600 - I * 60),
|
|
4489
|
-
return "" + d(E, 2) + ":" + d(I, 2) + ":" + d(P, 2) + "." + d(
|
|
4488
|
+
var E = Math.floor(U / 3600), I = Math.floor((U - E * 3600) / 60), P = Math.floor(U - E * 3600 - I * 60), B = Math.floor((U - E * 3600 - I * 60 - P) * 1e3);
|
|
4489
|
+
return "" + d(E, 2) + ":" + d(I, 2) + ":" + d(P, 2) + "." + d(B, 3);
|
|
4490
4490
|
}
|
|
4491
|
-
for (var g = this.parseSample(c),
|
|
4492
|
-
var C = g[
|
|
4493
|
-
|
|
4494
|
-
`,
|
|
4491
|
+
for (var g = this.parseSample(c), _ = "", w = 0; w < g.length; w++) {
|
|
4492
|
+
var C = g[w];
|
|
4493
|
+
_ += f(t) + " --> " + f(n) + `\r
|
|
4494
|
+
`, _ += C.payl.text;
|
|
4495
4495
|
}
|
|
4496
|
-
return
|
|
4496
|
+
return _;
|
|
4497
4497
|
};
|
|
4498
4498
|
var k = function() {
|
|
4499
4499
|
};
|
|
@@ -4516,35 +4516,35 @@ var zi = {};
|
|
|
4516
4516
|
}, x.prototype.parseConfig = function(t) {
|
|
4517
4517
|
var n, c = new s(t.buffer);
|
|
4518
4518
|
return c.readUint32(), n = c.readCString(), n;
|
|
4519
|
-
}, a.VTTin4Parser =
|
|
4520
|
-
var
|
|
4519
|
+
}, a.VTTin4Parser = v, a.XMLSubtitlein4Parser = k, a.Textin4Parser = x;
|
|
4520
|
+
var b = function(t) {
|
|
4521
4521
|
this.stream = t || new l(), this.boxes = [], this.mdats = [], this.moofs = [], this.isProgressive = !1, this.moovStartFound = !1, this.onMoovStart = null, this.moovStartSent = !1, this.onReady = null, this.readySent = !1, this.onSegment = null, this.onSamples = null, this.onError = null, this.sampleListBuilt = !1, this.fragmentedTracks = [], this.extractedTracks = [], this.isFragmentationInitialized = !1, this.sampleProcessingStarted = !1, this.nextMoofNumber = 0, this.itemListBuilt = !1, this.items = [], this.entity_groups = [], this.onSidx = null, this.sidxSent = !1;
|
|
4522
4522
|
};
|
|
4523
|
-
|
|
4523
|
+
b.prototype.setSegmentOptions = function(t, n, c) {
|
|
4524
4524
|
var d = this.getTrackById(t);
|
|
4525
4525
|
if (d) {
|
|
4526
4526
|
var f = {};
|
|
4527
4527
|
this.fragmentedTracks.push(f), f.id = t, f.user = n, f.trak = d, d.nextSample = 0, f.segmentStream = null, f.nb_samples = 1e3, f.rapAlignement = !0, c && (c.nbSamples && (f.nb_samples = c.nbSamples), c.rapAlignement && (f.rapAlignement = c.rapAlignement));
|
|
4528
4528
|
}
|
|
4529
|
-
},
|
|
4529
|
+
}, b.prototype.unsetSegmentOptions = function(t) {
|
|
4530
4530
|
for (var n = -1, c = 0; c < this.fragmentedTracks.length; c++) {
|
|
4531
4531
|
var d = this.fragmentedTracks[c];
|
|
4532
4532
|
d.id == t && (n = c);
|
|
4533
4533
|
}
|
|
4534
4534
|
n > -1 && this.fragmentedTracks.splice(n, 1);
|
|
4535
|
-
},
|
|
4535
|
+
}, b.prototype.setExtractionOptions = function(t, n, c) {
|
|
4536
4536
|
var d = this.getTrackById(t);
|
|
4537
4537
|
if (d) {
|
|
4538
4538
|
var f = {};
|
|
4539
4539
|
this.extractedTracks.push(f), f.id = t, f.user = n, f.trak = d, d.nextSample = 0, f.nb_samples = 1e3, f.samples = [], c && c.nbSamples && (f.nb_samples = c.nbSamples);
|
|
4540
4540
|
}
|
|
4541
|
-
},
|
|
4541
|
+
}, b.prototype.unsetExtractionOptions = function(t) {
|
|
4542
4542
|
for (var n = -1, c = 0; c < this.extractedTracks.length; c++) {
|
|
4543
4543
|
var d = this.extractedTracks[c];
|
|
4544
4544
|
d.id == t && (n = c);
|
|
4545
4545
|
}
|
|
4546
4546
|
n > -1 && this.extractedTracks.splice(n, 1);
|
|
4547
|
-
},
|
|
4547
|
+
}, b.prototype.parse = function() {
|
|
4548
4548
|
var t, n, c = !1;
|
|
4549
4549
|
if (!(this.restoreParsePosition && !this.restoreParsePosition()))
|
|
4550
4550
|
for (; ; )
|
|
@@ -4576,24 +4576,24 @@ var zi = {};
|
|
|
4576
4576
|
}
|
|
4577
4577
|
this.updateUsedBytes && this.updateUsedBytes(n, t);
|
|
4578
4578
|
}
|
|
4579
|
-
},
|
|
4579
|
+
}, b.prototype.checkBuffer = function(t) {
|
|
4580
4580
|
if (t == null)
|
|
4581
4581
|
throw "Buffer must be defined and non empty";
|
|
4582
4582
|
if (t.fileStart === void 0)
|
|
4583
4583
|
throw "Buffer must have a fileStart property";
|
|
4584
4584
|
return t.byteLength === 0 ? (e.warn("ISOFile", "Ignoring empty buffer (fileStart: " + t.fileStart + ")"), this.stream.logBufferLevel(), !1) : (e.info("ISOFile", "Processing buffer (fileStart: " + t.fileStart + ")"), t.usedBytes = 0, this.stream.insertBuffer(t), this.stream.logBufferLevel(), this.stream.initialized() ? !0 : (e.warn("ISOFile", "Not ready to start parsing"), !1));
|
|
4585
|
-
},
|
|
4585
|
+
}, b.prototype.appendBuffer = function(t, n) {
|
|
4586
4586
|
var c;
|
|
4587
4587
|
if (this.checkBuffer(t))
|
|
4588
4588
|
return this.parse(), this.moovStartFound && !this.moovStartSent && (this.moovStartSent = !0, this.onMoovStart && this.onMoovStart()), this.moov ? (this.sampleListBuilt || (this.buildSampleLists(), this.sampleListBuilt = !0), this.updateSampleLists(), this.onReady && !this.readySent && (this.readySent = !0, this.onReady(this.getInfo())), this.processSamples(n), this.nextSeekPosition ? (c = this.nextSeekPosition, this.nextSeekPosition = void 0) : c = this.nextParsePosition, this.stream.getEndFilePositionAfter && (c = this.stream.getEndFilePositionAfter(c))) : this.nextParsePosition ? c = this.nextParsePosition : c = 0, this.sidx && this.onSidx && !this.sidxSent && (this.onSidx(this.sidx), this.sidxSent = !0), this.meta && (this.flattenItemInfo && !this.itemListBuilt && (this.flattenItemInfo(), this.itemListBuilt = !0), this.processItems && this.processItems(this.onItem)), this.stream.cleanBuffers && (e.info("ISOFile", "Done processing buffer (fileStart: " + t.fileStart + ") - next buffer to fetch should have a fileStart position of " + c), this.stream.logBufferLevel(), this.stream.cleanBuffers(), this.stream.logBufferLevel(!0), e.info("ISOFile", "Sample data size in memory: " + this.getAllocatedSampleDataSize())), c;
|
|
4589
|
-
},
|
|
4590
|
-
var t, n, c = {}, d, f, g,
|
|
4589
|
+
}, b.prototype.getInfo = function() {
|
|
4590
|
+
var t, n, c = {}, d, f, g, _, w = (/* @__PURE__ */ new Date("1904-01-01T00:00:00Z")).getTime();
|
|
4591
4591
|
if (this.moov)
|
|
4592
|
-
for (c.hasMoov = !0, c.duration = this.moov.mvhd.duration, c.timescale = this.moov.mvhd.timescale, c.isFragmented = this.moov.mvex != null, c.isFragmented && this.moov.mvex.mehd && (c.fragment_duration = this.moov.mvex.mehd.fragment_duration), c.isProgressive = this.isProgressive, c.hasIOD = this.moov.iods != null, c.brands = [], c.brands.push(this.ftyp.major_brand), c.brands = c.brands.concat(this.ftyp.compatible_brands), c.created = new Date(
|
|
4593
|
-
if (d = this.moov.traks[t],
|
|
4592
|
+
for (c.hasMoov = !0, c.duration = this.moov.mvhd.duration, c.timescale = this.moov.mvhd.timescale, c.isFragmented = this.moov.mvex != null, c.isFragmented && this.moov.mvex.mehd && (c.fragment_duration = this.moov.mvex.mehd.fragment_duration), c.isProgressive = this.isProgressive, c.hasIOD = this.moov.iods != null, c.brands = [], c.brands.push(this.ftyp.major_brand), c.brands = c.brands.concat(this.ftyp.compatible_brands), c.created = new Date(w + this.moov.mvhd.creation_time * 1e3), c.modified = new Date(w + this.moov.mvhd.modification_time * 1e3), c.tracks = [], c.audioTracks = [], c.videoTracks = [], c.subtitleTracks = [], c.metadataTracks = [], c.hintTracks = [], c.otherTracks = [], t = 0; t < this.moov.traks.length; t++) {
|
|
4593
|
+
if (d = this.moov.traks[t], _ = d.mdia.minf.stbl.stsd.entries[0], f = {}, c.tracks.push(f), f.id = d.tkhd.track_id, f.name = d.mdia.hdlr.name, f.references = [], d.tref)
|
|
4594
4594
|
for (n = 0; n < d.tref.boxes.length; n++)
|
|
4595
4595
|
g = {}, f.references.push(g), g.type = d.tref.boxes[n].type, g.track_ids = d.tref.boxes[n].track_ids;
|
|
4596
|
-
d.edts && (f.edits = d.edts.elst.entries), f.created = new Date(
|
|
4596
|
+
d.edts && (f.edits = d.edts.elst.entries), f.created = new Date(w + d.tkhd.creation_time * 1e3), f.modified = new Date(w + d.tkhd.modification_time * 1e3), f.movie_duration = d.tkhd.duration, f.movie_timescale = c.timescale, f.layer = d.tkhd.layer, f.alternate_group = d.tkhd.alternate_group, f.volume = d.tkhd.volume, f.matrix = d.tkhd.matrix, f.track_width = d.tkhd.width / 65536, f.track_height = d.tkhd.height / 65536, f.timescale = d.mdia.mdhd.timescale, f.cts_shift = d.mdia.minf.stbl.cslg, f.duration = d.mdia.mdhd.duration, f.samples_duration = d.samples_duration, f.codec = _.getCodec(), f.kind = d.udta && d.udta.kinds.length ? d.udta.kinds[0] : { schemeURI: "", value: "" }, f.language = d.mdia.elng ? d.mdia.elng.extended_language : d.mdia.mdhd.languageString, f.nb_samples = d.samples.length, f.size = d.samples_size, f.bitrate = f.size * 8 * f.timescale / f.samples_duration, _.isAudio() ? (f.type = "audio", c.audioTracks.push(f), f.audio = {}, f.audio.sample_rate = _.getSampleRate(), f.audio.channel_count = _.getChannelCount(), f.audio.sample_size = _.getSampleSize()) : _.isVideo() ? (f.type = "video", c.videoTracks.push(f), f.video = {}, f.video.width = _.getWidth(), f.video.height = _.getHeight()) : _.isSubtitle() ? (f.type = "subtitles", c.subtitleTracks.push(f)) : _.isHint() ? (f.type = "metadata", c.hintTracks.push(f)) : _.isMetadata() ? (f.type = "metadata", c.metadataTracks.push(f)) : (f.type = "metadata", c.otherTracks.push(f));
|
|
4597
4597
|
}
|
|
4598
4598
|
else
|
|
4599
4599
|
c.hasMoov = !1;
|
|
@@ -4603,9 +4603,9 @@ var zi = {};
|
|
|
4603
4603
|
c.mime += '"; profiles="', c.mime += this.ftyp.compatible_brands.join(), c.mime += '"';
|
|
4604
4604
|
}
|
|
4605
4605
|
return c;
|
|
4606
|
-
},
|
|
4606
|
+
}, b.prototype.setNextSeekPositionFromSample = function(t) {
|
|
4607
4607
|
t && (this.nextSeekPosition ? this.nextSeekPosition = Math.min(t.offset + t.alreadyRead, this.nextSeekPosition) : this.nextSeekPosition = t.offset + t.alreadyRead);
|
|
4608
|
-
},
|
|
4608
|
+
}, b.prototype.processSamples = function(t) {
|
|
4609
4609
|
var n, c;
|
|
4610
4610
|
if (this.sampleProcessingStarted) {
|
|
4611
4611
|
if (this.isFragmentationInitialized && this.onSegment !== null)
|
|
@@ -4627,9 +4627,9 @@ var zi = {};
|
|
|
4627
4627
|
var g = this.extractedTracks[n];
|
|
4628
4628
|
for (c = g.trak; c.nextSample < c.samples.length && this.sampleProcessingStarted; ) {
|
|
4629
4629
|
e.debug("ISOFile", "Exporting on track #" + g.id + " sample #" + c.nextSample);
|
|
4630
|
-
var
|
|
4631
|
-
if (
|
|
4632
|
-
c.nextSample++, g.samples.push(
|
|
4630
|
+
var _ = this.getSample(c, c.nextSample);
|
|
4631
|
+
if (_)
|
|
4632
|
+
c.nextSample++, g.samples.push(_);
|
|
4633
4633
|
else {
|
|
4634
4634
|
this.setNextSeekPositionFromSample(c.samples[c.nextSample]);
|
|
4635
4635
|
break;
|
|
@@ -4639,65 +4639,65 @@ var zi = {};
|
|
|
4639
4639
|
}
|
|
4640
4640
|
}
|
|
4641
4641
|
}
|
|
4642
|
-
},
|
|
4642
|
+
}, b.prototype.getBox = function(t) {
|
|
4643
4643
|
var n = this.getBoxes(t, !0);
|
|
4644
4644
|
return n.length ? n[0] : null;
|
|
4645
|
-
},
|
|
4645
|
+
}, b.prototype.getBoxes = function(t, n) {
|
|
4646
4646
|
var c = [];
|
|
4647
|
-
return
|
|
4648
|
-
},
|
|
4647
|
+
return b._sweep.call(this, t, c, n), c;
|
|
4648
|
+
}, b._sweep = function(t, n, c) {
|
|
4649
4649
|
this.type && this.type == t && n.push(this);
|
|
4650
4650
|
for (var d in this.boxes) {
|
|
4651
4651
|
if (n.length && c) return;
|
|
4652
|
-
|
|
4652
|
+
b._sweep.call(this.boxes[d], t, n, c);
|
|
4653
4653
|
}
|
|
4654
|
-
},
|
|
4654
|
+
}, b.prototype.getTrackSamplesInfo = function(t) {
|
|
4655
4655
|
var n = this.getTrackById(t);
|
|
4656
4656
|
if (n)
|
|
4657
4657
|
return n.samples;
|
|
4658
|
-
},
|
|
4658
|
+
}, b.prototype.getTrackSample = function(t, n) {
|
|
4659
4659
|
var c = this.getTrackById(t), d = this.getSample(c, n);
|
|
4660
4660
|
return d;
|
|
4661
|
-
},
|
|
4661
|
+
}, b.prototype.releaseUsedSamples = function(t, n) {
|
|
4662
4662
|
var c = 0, d = this.getTrackById(t);
|
|
4663
4663
|
d.lastValidSample || (d.lastValidSample = 0);
|
|
4664
4664
|
for (var f = d.lastValidSample; f < n; f++)
|
|
4665
4665
|
c += this.releaseSample(d, f);
|
|
4666
4666
|
e.info("ISOFile", "Track #" + t + " released samples up to " + n + " (released size: " + c + ", remaining: " + this.samplesDataSize + ")"), d.lastValidSample = n;
|
|
4667
|
-
},
|
|
4667
|
+
}, b.prototype.start = function() {
|
|
4668
4668
|
this.sampleProcessingStarted = !0, this.processSamples(!1);
|
|
4669
|
-
},
|
|
4669
|
+
}, b.prototype.stop = function() {
|
|
4670
4670
|
this.sampleProcessingStarted = !1;
|
|
4671
|
-
},
|
|
4671
|
+
}, b.prototype.flush = function() {
|
|
4672
4672
|
e.info("ISOFile", "Flushing remaining samples"), this.updateSampleLists(), this.processSamples(!0), this.stream.cleanBuffers(), this.stream.logBufferLevel(!0);
|
|
4673
|
-
},
|
|
4674
|
-
var d, f, g = 1 / 0,
|
|
4673
|
+
}, b.prototype.seekTrack = function(t, n, c) {
|
|
4674
|
+
var d, f, g = 1 / 0, _ = 0, w = 0, C;
|
|
4675
4675
|
if (c.samples.length === 0)
|
|
4676
4676
|
return e.info("ISOFile", "No sample in track, cannot seek! Using time " + e.getDurationString(0, 1) + " and offset: 0"), { offset: 0, time: 0 };
|
|
4677
4677
|
for (d = 0; d < c.samples.length; d++) {
|
|
4678
4678
|
if (f = c.samples[d], d === 0)
|
|
4679
|
-
|
|
4679
|
+
w = 0, C = f.timescale;
|
|
4680
4680
|
else if (f.cts > t * f.timescale) {
|
|
4681
|
-
|
|
4681
|
+
w = d - 1;
|
|
4682
4682
|
break;
|
|
4683
4683
|
}
|
|
4684
|
-
n && f.is_sync && (
|
|
4684
|
+
n && f.is_sync && (_ = d);
|
|
4685
4685
|
}
|
|
4686
|
-
for (n && (
|
|
4687
|
-
|
|
4688
|
-
return g = c.samples[
|
|
4689
|
-
},
|
|
4686
|
+
for (n && (w = _), t = c.samples[w].cts, c.nextSample = w; c.samples[w].alreadyRead === c.samples[w].size && c.samples[w + 1]; )
|
|
4687
|
+
w++;
|
|
4688
|
+
return g = c.samples[w].offset + c.samples[w].alreadyRead, e.info("ISOFile", "Seeking to " + (n ? "RAP" : "") + " sample #" + c.nextSample + " on track " + c.tkhd.track_id + ", time " + e.getDurationString(t, C) + " and offset: " + g), { offset: g, time: t / C };
|
|
4689
|
+
}, b.prototype.getTrackDuration = function(t) {
|
|
4690
4690
|
var n;
|
|
4691
4691
|
return t.samples ? (n = t.samples[t.samples.length - 1], (n.cts + n.duration) / n.timescale) : 1 / 0;
|
|
4692
|
-
},
|
|
4693
|
-
var c = this.moov, d, f, g,
|
|
4692
|
+
}, b.prototype.seek = function(t, n) {
|
|
4693
|
+
var c = this.moov, d, f, g, _ = { offset: 1 / 0, time: 1 / 0 };
|
|
4694
4694
|
if (this.moov) {
|
|
4695
4695
|
for (g = 0; g < c.traks.length; g++)
|
|
4696
|
-
d = c.traks[g], !(t > this.getTrackDuration(d)) && (f = this.seekTrack(t, n, d), f.offset <
|
|
4697
|
-
return e.info("ISOFile", "Seeking at time " + e.getDurationString(
|
|
4696
|
+
d = c.traks[g], !(t > this.getTrackDuration(d)) && (f = this.seekTrack(t, n, d), f.offset < _.offset && (_.offset = f.offset), f.time < _.time && (_.time = f.time));
|
|
4697
|
+
return e.info("ISOFile", "Seeking at time " + e.getDurationString(_.time, 1) + " needs a buffer with a fileStart position of " + _.offset), _.offset === 1 / 0 ? _ = { offset: this.nextParsePosition, time: 0 } : _.offset = this.stream.getEndFilePositionAfter(_.offset), e.info("ISOFile", "Adjusted seek position (after checking data already in buffer): " + _.offset), _;
|
|
4698
4698
|
} else
|
|
4699
4699
|
throw "Cannot seek: moov not received!";
|
|
4700
|
-
},
|
|
4700
|
+
}, b.prototype.equal = function(t) {
|
|
4701
4701
|
for (var n = 0; n < this.boxes.length && n < t.boxes.length; ) {
|
|
4702
4702
|
var c = this.boxes[n], d = t.boxes[n];
|
|
4703
4703
|
if (!o.boxEqual(c, d))
|
|
@@ -4705,26 +4705,26 @@ var zi = {};
|
|
|
4705
4705
|
n++;
|
|
4706
4706
|
}
|
|
4707
4707
|
return !0;
|
|
4708
|
-
}, a.ISOFile =
|
|
4708
|
+
}, a.ISOFile = b, b.prototype.lastBoxStartPosition = 0, b.prototype.parsingMdat = null, b.prototype.nextParsePosition = 0, b.prototype.discardMdatData = !1, b.prototype.processIncompleteBox = function(t) {
|
|
4709
4709
|
var n, c, d;
|
|
4710
4710
|
return t.type === "mdat" ? (n = new o[t.type + "Box"](t.size), this.parsingMdat = n, this.boxes.push(n), this.mdats.push(n), n.start = t.start, n.hdr_size = t.hdr_size, this.stream.addUsedBytes(n.hdr_size), this.lastBoxStartPosition = n.start + n.size, d = this.stream.seek(n.start + n.size, !1, this.discardMdatData), d ? (this.parsingMdat = null, !0) : (this.moovStartFound ? this.nextParsePosition = this.stream.findEndContiguousBuf() : this.nextParsePosition = n.start + n.size, !1)) : (t.type === "moov" && (this.moovStartFound = !0, this.mdats.length === 0 && (this.isProgressive = !0)), c = this.stream.mergeNextBuffer ? this.stream.mergeNextBuffer() : !1, c ? (this.nextParsePosition = this.stream.getEndPosition(), !0) : (t.type ? this.moovStartFound ? this.nextParsePosition = this.stream.getEndPosition() : this.nextParsePosition = this.stream.getPosition() + t.size : this.nextParsePosition = this.stream.getEndPosition(), !1));
|
|
4711
|
-
},
|
|
4711
|
+
}, b.prototype.hasIncompleteMdat = function() {
|
|
4712
4712
|
return this.parsingMdat !== null;
|
|
4713
|
-
},
|
|
4713
|
+
}, b.prototype.processIncompleteMdat = function() {
|
|
4714
4714
|
var t, n;
|
|
4715
4715
|
return t = this.parsingMdat, n = this.stream.seek(t.start + t.size, !1, this.discardMdatData), n ? (e.debug("ISOFile", "Found 'mdat' end in buffered data"), this.parsingMdat = null, !0) : (this.nextParsePosition = this.stream.findEndContiguousBuf(), !1);
|
|
4716
|
-
},
|
|
4716
|
+
}, b.prototype.restoreParsePosition = function() {
|
|
4717
4717
|
return this.stream.seek(this.lastBoxStartPosition, !0, this.discardMdatData);
|
|
4718
|
-
},
|
|
4718
|
+
}, b.prototype.saveParsePosition = function() {
|
|
4719
4719
|
this.lastBoxStartPosition = this.stream.getPosition();
|
|
4720
|
-
},
|
|
4720
|
+
}, b.prototype.updateUsedBytes = function(t, n) {
|
|
4721
4721
|
this.stream.addUsedBytes && (t.type === "mdat" ? (this.stream.addUsedBytes(t.hdr_size), this.discardMdatData && this.stream.addUsedBytes(t.size - t.hdr_size)) : this.stream.addUsedBytes(t.size));
|
|
4722
|
-
},
|
|
4722
|
+
}, b.prototype.add = o.Box.prototype.add, b.prototype.addBox = o.Box.prototype.addBox, b.prototype.init = function(t) {
|
|
4723
4723
|
var n = t || {};
|
|
4724
4724
|
this.add("ftyp").set("major_brand", n.brands && n.brands[0] || "iso4").set("minor_version", 0).set("compatible_brands", n.brands || ["iso4"]);
|
|
4725
4725
|
var c = this.add("moov");
|
|
4726
4726
|
return c.add("mvhd").set("timescale", n.timescale || 600).set("rate", n.rate || 65536).set("creation_time", 0).set("modification_time", 0).set("duration", n.duration || 0).set("volume", n.width ? 0 : 256).set("matrix", [65536, 0, 0, 0, 65536, 0, 0, 0, 1073741824]).set("next_track_id", 1), c.add("mvex"), this;
|
|
4727
|
-
},
|
|
4727
|
+
}, b.prototype.addTrack = function(t) {
|
|
4728
4728
|
this.moov || this.init(t);
|
|
4729
4729
|
var n = t || {};
|
|
4730
4730
|
n.width = n.width || 320, n.height = n.height || 320, n.id = n.id || this.moov.mvhd.next_track_id, n.type = n.type || "avc1";
|
|
@@ -4736,14 +4736,14 @@ var zi = {};
|
|
|
4736
4736
|
if (o[n.type + "SampleEntry"] !== void 0) {
|
|
4737
4737
|
var g = new o[n.type + "SampleEntry"]();
|
|
4738
4738
|
g.data_reference_index = 1;
|
|
4739
|
-
var
|
|
4740
|
-
for (var
|
|
4741
|
-
for (var C = o.sampleEntryCodes[
|
|
4739
|
+
var _ = "";
|
|
4740
|
+
for (var w in o.sampleEntryCodes)
|
|
4741
|
+
for (var C = o.sampleEntryCodes[w], U = 0; U < C.length; U++)
|
|
4742
4742
|
if (C.indexOf(n.type) > -1) {
|
|
4743
|
-
|
|
4743
|
+
_ = w;
|
|
4744
4744
|
break;
|
|
4745
4745
|
}
|
|
4746
|
-
switch (
|
|
4746
|
+
switch (_) {
|
|
4747
4747
|
case "Visual":
|
|
4748
4748
|
if (f.add("vmhd").set("graphicsmode", 0).set("opcolor", [0, 0, 0]), g.set("width", n.width).set("height", n.height).set("horizresolution", 72 << 16).set("vertresolution", 72 << 16).set("frame_count", 1).set("compressorname", n.type + " Compressor").set("depth", 24), n.avcDecoderConfigRecord) {
|
|
4749
4749
|
var E = new o.avcCBox();
|
|
@@ -4776,8 +4776,8 @@ var zi = {};
|
|
|
4776
4776
|
f.add("nmhd");
|
|
4777
4777
|
break;
|
|
4778
4778
|
}
|
|
4779
|
-
n.description && g.addBox(n.description), n.description_boxes && n.description_boxes.forEach(function(
|
|
4780
|
-
g.addBox(
|
|
4779
|
+
n.description && g.addBox(n.description), n.description_boxes && n.description_boxes.forEach(function(B) {
|
|
4780
|
+
g.addBox(B);
|
|
4781
4781
|
}), f.add("dinf").add("dref").addEntry(new o["url Box"]().set("flags", 1));
|
|
4782
4782
|
var P = f.add("stbl");
|
|
4783
4783
|
return P.add("stsd").addEntry(g), P.add("stts").set("sample_counts", []).set("sample_deltas", []), P.add("stsc").set("first_chunk", []).set("samples_per_chunk", []).set("sample_description_index", []), P.add("stco").set("chunk_offsets", []), P.add("stsz").set("sample_sizes", []), this.moov.mvex.add("trex").set("track_id", n.id).set("default_sample_description_index", n.default_sample_description_index || 1).set("default_sample_duration", n.default_sample_duration || 0).set("default_sample_size", n.default_sample_size || 0).set("default_sample_flags", n.default_sample_flags || 0), this.buildTrakSampleLists(c), n.id;
|
|
@@ -4785,92 +4785,92 @@ var zi = {};
|
|
|
4785
4785
|
}, o.Box.prototype.computeSize = function(t) {
|
|
4786
4786
|
var n = t || new r();
|
|
4787
4787
|
n.endianness = r.BIG_ENDIAN, this.write(n);
|
|
4788
|
-
},
|
|
4788
|
+
}, b.prototype.addSample = function(t, n, c) {
|
|
4789
4789
|
var d = c || {}, f = {}, g = this.getTrackById(t);
|
|
4790
4790
|
if (g !== null) {
|
|
4791
4791
|
f.number = g.samples.length, f.track_id = g.tkhd.track_id, f.timescale = g.mdia.mdhd.timescale, f.description_index = d.sample_description_index ? d.sample_description_index - 1 : 0, f.description = g.mdia.minf.stbl.stsd.entries[f.description_index], f.data = n, f.size = n.byteLength, f.alreadyRead = f.size, f.duration = d.duration || 1, f.cts = d.cts || 0, f.dts = d.dts || 0, f.is_sync = d.is_sync || !1, f.is_leading = d.is_leading || 0, f.depends_on = d.depends_on || 0, f.is_depended_on = d.is_depended_on || 0, f.has_redundancy = d.has_redundancy || 0, f.degradation_priority = d.degradation_priority || 0, f.offset = 0, f.subsamples = d.subsamples, g.samples.push(f), g.samples_size += f.size, g.samples_duration += f.duration, g.first_dts === void 0 && (g.first_dts = d.dts), this.processSamples();
|
|
4792
|
-
var
|
|
4793
|
-
return this.addBox(
|
|
4792
|
+
var _ = this.createSingleSampleMoof(f);
|
|
4793
|
+
return this.addBox(_), _.computeSize(), _.trafs[0].truns[0].data_offset = _.size + 8, this.add("mdat").data = new Uint8Array(n), f;
|
|
4794
4794
|
}
|
|
4795
|
-
},
|
|
4795
|
+
}, b.prototype.createSingleSampleMoof = function(t) {
|
|
4796
4796
|
var n = 0;
|
|
4797
4797
|
t.is_sync ? n = 1 << 25 : n = 65536;
|
|
4798
4798
|
var c = new o.moofBox();
|
|
4799
4799
|
c.add("mfhd").set("sequence_number", this.nextMoofNumber), this.nextMoofNumber++;
|
|
4800
4800
|
var d = c.add("traf"), f = this.getTrackById(t.track_id);
|
|
4801
4801
|
return d.add("tfhd").set("track_id", t.track_id).set("flags", o.TFHD_FLAG_DEFAULT_BASE_IS_MOOF), d.add("tfdt").set("baseMediaDecodeTime", t.dts - (f.first_dts || 0)), d.add("trun").set("flags", o.TRUN_FLAGS_DATA_OFFSET | o.TRUN_FLAGS_DURATION | o.TRUN_FLAGS_SIZE | o.TRUN_FLAGS_FLAGS | o.TRUN_FLAGS_CTS_OFFSET).set("data_offset", 0).set("first_sample_flags", 0).set("sample_count", 1).set("sample_duration", [t.duration]).set("sample_size", [t.size]).set("sample_flags", [n]).set("sample_composition_time_offset", [t.cts - t.dts]), c;
|
|
4802
|
-
},
|
|
4803
|
-
var t, n, c, d, f, g,
|
|
4802
|
+
}, b.prototype.lastMoofIndex = 0, b.prototype.samplesDataSize = 0, b.prototype.resetTables = function() {
|
|
4803
|
+
var t, n, c, d, f, g, _, w;
|
|
4804
4804
|
for (this.initial_duration = this.moov.mvhd.duration, this.moov.mvhd.duration = 0, t = 0; t < this.moov.traks.length; t++) {
|
|
4805
|
-
n = this.moov.traks[t], n.tkhd.duration = 0, n.mdia.mdhd.duration = 0, c = n.mdia.minf.stbl.stco || n.mdia.minf.stbl.co64, c.chunk_offsets = [], d = n.mdia.minf.stbl.stsc, d.first_chunk = [], d.samples_per_chunk = [], d.sample_description_index = [], f = n.mdia.minf.stbl.stsz || n.mdia.minf.stbl.stz2, f.sample_sizes = [], g = n.mdia.minf.stbl.stts, g.sample_counts = [], g.sample_deltas = [],
|
|
4806
|
-
var C = n.mdia.minf.stbl.boxes.indexOf(
|
|
4805
|
+
n = this.moov.traks[t], n.tkhd.duration = 0, n.mdia.mdhd.duration = 0, c = n.mdia.minf.stbl.stco || n.mdia.minf.stbl.co64, c.chunk_offsets = [], d = n.mdia.minf.stbl.stsc, d.first_chunk = [], d.samples_per_chunk = [], d.sample_description_index = [], f = n.mdia.minf.stbl.stsz || n.mdia.minf.stbl.stz2, f.sample_sizes = [], g = n.mdia.minf.stbl.stts, g.sample_counts = [], g.sample_deltas = [], _ = n.mdia.minf.stbl.ctts, _ && (_.sample_counts = [], _.sample_offsets = []), w = n.mdia.minf.stbl.stss;
|
|
4806
|
+
var C = n.mdia.minf.stbl.boxes.indexOf(w);
|
|
4807
4807
|
C != -1 && (n.mdia.minf.stbl.boxes[C] = null);
|
|
4808
4808
|
}
|
|
4809
|
-
},
|
|
4810
|
-
var g,
|
|
4809
|
+
}, b.initSampleGroups = function(t, n, c, d, f) {
|
|
4810
|
+
var g, _, w, C;
|
|
4811
4811
|
function U(E, I, P) {
|
|
4812
4812
|
this.grouping_type = E, this.grouping_type_parameter = I, this.sbgp = P, this.last_sample_in_run = -1, this.entry_index = -1;
|
|
4813
4813
|
}
|
|
4814
|
-
for (n && (n.sample_groups_info = []), t.sample_groups_info || (t.sample_groups_info = []),
|
|
4815
|
-
for (C = c[
|
|
4816
|
-
d[g].grouping_type === c[
|
|
4814
|
+
for (n && (n.sample_groups_info = []), t.sample_groups_info || (t.sample_groups_info = []), _ = 0; _ < c.length; _++) {
|
|
4815
|
+
for (C = c[_].grouping_type + "/" + c[_].grouping_type_parameter, w = new U(c[_].grouping_type, c[_].grouping_type_parameter, c[_]), n && (n.sample_groups_info[C] = w), t.sample_groups_info[C] || (t.sample_groups_info[C] = w), g = 0; g < d.length; g++)
|
|
4816
|
+
d[g].grouping_type === c[_].grouping_type && (w.description = d[g], w.description.used = !0);
|
|
4817
4817
|
if (f)
|
|
4818
4818
|
for (g = 0; g < f.length; g++)
|
|
4819
|
-
f[g].grouping_type === c[
|
|
4819
|
+
f[g].grouping_type === c[_].grouping_type && (w.fragment_description = f[g], w.fragment_description.used = !0, w.is_fragment = !0);
|
|
4820
4820
|
}
|
|
4821
4821
|
if (n) {
|
|
4822
4822
|
if (f)
|
|
4823
|
-
for (
|
|
4824
|
-
!f[
|
|
4823
|
+
for (_ = 0; _ < f.length; _++)
|
|
4824
|
+
!f[_].used && f[_].version >= 2 && (C = f[_].grouping_type + "/0", w = new U(f[_].grouping_type, 0), w.is_fragment = !0, n.sample_groups_info[C] || (n.sample_groups_info[C] = w));
|
|
4825
4825
|
} else
|
|
4826
|
-
for (
|
|
4827
|
-
!d[
|
|
4828
|
-
},
|
|
4826
|
+
for (_ = 0; _ < d.length; _++)
|
|
4827
|
+
!d[_].used && d[_].version >= 2 && (C = d[_].grouping_type + "/0", w = new U(d[_].grouping_type, 0), t.sample_groups_info[C] || (t.sample_groups_info[C] = w));
|
|
4828
|
+
}, b.setSampleGroupProperties = function(t, n, c, d) {
|
|
4829
4829
|
var f, g;
|
|
4830
4830
|
n.sample_groups = [];
|
|
4831
4831
|
for (f in d)
|
|
4832
4832
|
if (n.sample_groups[f] = {}, n.sample_groups[f].grouping_type = d[f].grouping_type, n.sample_groups[f].grouping_type_parameter = d[f].grouping_type_parameter, c >= d[f].last_sample_in_run && (d[f].last_sample_in_run < 0 && (d[f].last_sample_in_run = 0), d[f].entry_index++, d[f].entry_index <= d[f].sbgp.entries.length - 1 && (d[f].last_sample_in_run += d[f].sbgp.entries[d[f].entry_index].sample_count)), d[f].entry_index <= d[f].sbgp.entries.length - 1 ? n.sample_groups[f].group_description_index = d[f].sbgp.entries[d[f].entry_index].group_description_index : n.sample_groups[f].group_description_index = -1, n.sample_groups[f].group_description_index !== 0) {
|
|
4833
|
-
var
|
|
4834
|
-
d[f].fragment_description ?
|
|
4833
|
+
var _;
|
|
4834
|
+
d[f].fragment_description ? _ = d[f].fragment_description : _ = d[f].description, n.sample_groups[f].group_description_index > 0 ? (n.sample_groups[f].group_description_index > 65535 ? g = (n.sample_groups[f].group_description_index >> 16) - 1 : g = n.sample_groups[f].group_description_index - 1, _ && g >= 0 && (n.sample_groups[f].description = _.entries[g])) : _ && _.version >= 2 && _.default_group_description_index > 0 && (n.sample_groups[f].description = _.entries[_.default_group_description_index - 1]);
|
|
4835
4835
|
}
|
|
4836
|
-
},
|
|
4836
|
+
}, b.process_sdtp = function(t, n, c) {
|
|
4837
4837
|
n && (t ? (n.is_leading = t.is_leading[c], n.depends_on = t.sample_depends_on[c], n.is_depended_on = t.sample_is_depended_on[c], n.has_redundancy = t.sample_has_redundancy[c]) : (n.is_leading = 0, n.depends_on = 0, n.is_depended_on = 0, n.has_redundancy = 0));
|
|
4838
|
-
},
|
|
4838
|
+
}, b.prototype.buildSampleLists = function() {
|
|
4839
4839
|
var t, n;
|
|
4840
4840
|
for (t = 0; t < this.moov.traks.length; t++)
|
|
4841
4841
|
n = this.moov.traks[t], this.buildTrakSampleLists(n);
|
|
4842
|
-
},
|
|
4843
|
-
var n, c, d, f, g,
|
|
4844
|
-
if (t.samples = [], t.samples_duration = 0, t.samples_size = 0, c = t.mdia.minf.stbl.stco || t.mdia.minf.stbl.co64, d = t.mdia.minf.stbl.stsc, f = t.mdia.minf.stbl.stsz || t.mdia.minf.stbl.stz2, g = t.mdia.minf.stbl.stts,
|
|
4842
|
+
}, b.prototype.buildTrakSampleLists = function(t) {
|
|
4843
|
+
var n, c, d, f, g, _, w, C, U, E, I, P, B, R, L, j, K, X, J, he, Me, It, _e, Ve;
|
|
4844
|
+
if (t.samples = [], t.samples_duration = 0, t.samples_size = 0, c = t.mdia.minf.stbl.stco || t.mdia.minf.stbl.co64, d = t.mdia.minf.stbl.stsc, f = t.mdia.minf.stbl.stsz || t.mdia.minf.stbl.stz2, g = t.mdia.minf.stbl.stts, _ = t.mdia.minf.stbl.ctts, w = t.mdia.minf.stbl.stss, C = t.mdia.minf.stbl.stsd, U = t.mdia.minf.stbl.subs, P = t.mdia.minf.stbl.stdp, E = t.mdia.minf.stbl.sbgps, I = t.mdia.minf.stbl.sgpds, X = -1, J = -1, he = -1, Me = -1, It = 0, _e = 0, Ve = 0, b.initSampleGroups(t, null, E, I), !(typeof f > "u")) {
|
|
4845
4845
|
for (n = 0; n < f.sample_sizes.length; n++) {
|
|
4846
4846
|
var W = {};
|
|
4847
|
-
W.number = n, W.track_id = t.tkhd.track_id, W.timescale = t.mdia.mdhd.timescale, W.alreadyRead = 0, t.samples[n] = W, W.size = f.sample_sizes[n], t.samples_size += W.size, n === 0 ? (
|
|
4847
|
+
W.number = n, W.track_id = t.tkhd.track_id, W.timescale = t.mdia.mdhd.timescale, W.alreadyRead = 0, t.samples[n] = W, W.size = f.sample_sizes[n], t.samples_size += W.size, n === 0 ? (R = 1, B = 0, W.chunk_index = R, W.chunk_run_index = B, K = d.samples_per_chunk[B], j = 0, B + 1 < d.first_chunk.length ? L = d.first_chunk[B + 1] - 1 : L = 1 / 0) : n < K ? (W.chunk_index = R, W.chunk_run_index = B) : (R++, W.chunk_index = R, j = 0, R <= L || (B++, B + 1 < d.first_chunk.length ? L = d.first_chunk[B + 1] - 1 : L = 1 / 0), W.chunk_run_index = B, K += d.samples_per_chunk[B]), W.description_index = d.sample_description_index[W.chunk_run_index] - 1, W.description = C.entries[W.description_index], W.offset = c.chunk_offsets[W.chunk_index - 1] + j, j += W.size, n > X && (J++, X < 0 && (X = 0), X += g.sample_counts[J]), n > 0 ? (t.samples[n - 1].duration = g.sample_deltas[J], t.samples_duration += t.samples[n - 1].duration, W.dts = t.samples[n - 1].dts + t.samples[n - 1].duration) : W.dts = 0, _ ? (n >= he && (Me++, he < 0 && (he = 0), he += _.sample_counts[Me]), W.cts = t.samples[n].dts + _.sample_offsets[Me]) : W.cts = W.dts, w ? (n == w.sample_numbers[It] - 1 ? (W.is_sync = !0, It++) : (W.is_sync = !1, W.degradation_priority = 0), U && U.entries[_e].sample_delta + Ve == n + 1 && (W.subsamples = U.entries[_e].subsamples, Ve += U.entries[_e].sample_delta, _e++)) : W.is_sync = !0, b.process_sdtp(t.mdia.minf.stbl.sdtp, W, W.number), P ? W.degradation_priority = P.priority[n] : W.degradation_priority = 0, U && U.entries[_e].sample_delta + Ve == n && (W.subsamples = U.entries[_e].subsamples, Ve += U.entries[_e].sample_delta), (E.length > 0 || I.length > 0) && b.setSampleGroupProperties(t, W, n, t.sample_groups_info);
|
|
4848
4848
|
}
|
|
4849
4849
|
n > 0 && (t.samples[n - 1].duration = Math.max(t.mdia.mdhd.duration - t.samples[n - 1].dts, 0), t.samples_duration += t.samples[n - 1].duration);
|
|
4850
4850
|
}
|
|
4851
|
-
},
|
|
4852
|
-
var t, n, c, d, f, g,
|
|
4851
|
+
}, b.prototype.updateSampleLists = function() {
|
|
4852
|
+
var t, n, c, d, f, g, _, w, C, U, E, I, P, B, R;
|
|
4853
4853
|
if (this.moov !== void 0) {
|
|
4854
4854
|
for (; this.lastMoofIndex < this.moofs.length; )
|
|
4855
4855
|
if (C = this.moofs[this.lastMoofIndex], this.lastMoofIndex++, C.type == "moof")
|
|
4856
4856
|
for (U = C, t = 0; t < U.trafs.length; t++) {
|
|
4857
|
-
for (E = U.trafs[t], I = this.getTrackById(E.tfhd.track_id), P = this.getTrexById(E.tfhd.track_id), E.tfhd.flags & o.TFHD_FLAG_SAMPLE_DESC ? d = E.tfhd.default_sample_description_index : d = P ? P.default_sample_description_index : 1, E.tfhd.flags & o.TFHD_FLAG_SAMPLE_DUR ? f = E.tfhd.default_sample_duration : f = P ? P.default_sample_duration : 0, E.tfhd.flags & o.TFHD_FLAG_SAMPLE_SIZE ? g = E.tfhd.default_sample_size : g = P ? P.default_sample_size : 0, E.tfhd.flags & o.TFHD_FLAG_SAMPLE_FLAGS ?
|
|
4858
|
-
var
|
|
4859
|
-
for (c = 0; c <
|
|
4860
|
-
|
|
4861
|
-
var
|
|
4862
|
-
|
|
4857
|
+
for (E = U.trafs[t], I = this.getTrackById(E.tfhd.track_id), P = this.getTrexById(E.tfhd.track_id), E.tfhd.flags & o.TFHD_FLAG_SAMPLE_DESC ? d = E.tfhd.default_sample_description_index : d = P ? P.default_sample_description_index : 1, E.tfhd.flags & o.TFHD_FLAG_SAMPLE_DUR ? f = E.tfhd.default_sample_duration : f = P ? P.default_sample_duration : 0, E.tfhd.flags & o.TFHD_FLAG_SAMPLE_SIZE ? g = E.tfhd.default_sample_size : g = P ? P.default_sample_size : 0, E.tfhd.flags & o.TFHD_FLAG_SAMPLE_FLAGS ? _ = E.tfhd.default_sample_flags : _ = P ? P.default_sample_flags : 0, E.sample_number = 0, E.sbgps.length > 0 && b.initSampleGroups(I, E, E.sbgps, I.mdia.minf.stbl.sgpds, E.sgpds), n = 0; n < E.truns.length; n++) {
|
|
4858
|
+
var L = E.truns[n];
|
|
4859
|
+
for (c = 0; c < L.sample_count; c++) {
|
|
4860
|
+
B = {}, B.moof_number = this.lastMoofIndex, B.number_in_traf = E.sample_number, E.sample_number++, B.number = I.samples.length, E.first_sample_index = I.samples.length, I.samples.push(B), B.track_id = I.tkhd.track_id, B.timescale = I.mdia.mdhd.timescale, B.description_index = d - 1, B.description = I.mdia.minf.stbl.stsd.entries[B.description_index], B.size = g, L.flags & o.TRUN_FLAGS_SIZE && (B.size = L.sample_size[c]), I.samples_size += B.size, B.duration = f, L.flags & o.TRUN_FLAGS_DURATION && (B.duration = L.sample_duration[c]), I.samples_duration += B.duration, I.first_traf_merged || c > 0 ? B.dts = I.samples[I.samples.length - 2].dts + I.samples[I.samples.length - 2].duration : (E.tfdt ? B.dts = E.tfdt.baseMediaDecodeTime : B.dts = 0, I.first_traf_merged = !0), B.cts = B.dts, L.flags & o.TRUN_FLAGS_CTS_OFFSET && (B.cts = B.dts + L.sample_composition_time_offset[c]), R = _, L.flags & o.TRUN_FLAGS_FLAGS ? R = L.sample_flags[c] : c === 0 && L.flags & o.TRUN_FLAGS_FIRST_FLAG && (R = L.first_sample_flags), B.is_sync = !(R >> 16 & 1), B.is_leading = R >> 26 & 3, B.depends_on = R >> 24 & 3, B.is_depended_on = R >> 22 & 3, B.has_redundancy = R >> 20 & 3, B.degradation_priority = R & 65535;
|
|
4861
|
+
var j = !!(E.tfhd.flags & o.TFHD_FLAG_BASE_DATA_OFFSET), K = !!(E.tfhd.flags & o.TFHD_FLAG_DEFAULT_BASE_IS_MOOF), X = !!(L.flags & o.TRUN_FLAGS_DATA_OFFSET), J = 0;
|
|
4862
|
+
j ? J = E.tfhd.base_data_offset : K || n === 0 ? J = U.start : J = w, n === 0 && c === 0 ? X ? B.offset = J + L.data_offset : B.offset = J : B.offset = w, w = B.offset + B.size, (E.sbgps.length > 0 || E.sgpds.length > 0 || I.mdia.minf.stbl.sbgps.length > 0 || I.mdia.minf.stbl.sgpds.length > 0) && b.setSampleGroupProperties(I, B, B.number_in_traf, E.sample_groups_info);
|
|
4863
4863
|
}
|
|
4864
4864
|
}
|
|
4865
4865
|
if (E.subs) {
|
|
4866
4866
|
I.has_fragment_subsamples = !0;
|
|
4867
4867
|
var he = E.first_sample_index;
|
|
4868
4868
|
for (n = 0; n < E.subs.entries.length; n++)
|
|
4869
|
-
he += E.subs.entries[n].sample_delta,
|
|
4869
|
+
he += E.subs.entries[n].sample_delta, B = I.samples[he - 1], B.subsamples = E.subs.entries[n].subsamples;
|
|
4870
4870
|
}
|
|
4871
4871
|
}
|
|
4872
4872
|
}
|
|
4873
|
-
},
|
|
4873
|
+
}, b.prototype.getSample = function(t, n) {
|
|
4874
4874
|
var c, d = t.samples[n];
|
|
4875
4875
|
if (!this.moov)
|
|
4876
4876
|
return null;
|
|
@@ -4902,19 +4902,19 @@ var zi = {};
|
|
|
4902
4902
|
} else
|
|
4903
4903
|
return null;
|
|
4904
4904
|
}
|
|
4905
|
-
},
|
|
4905
|
+
}, b.prototype.releaseSample = function(t, n) {
|
|
4906
4906
|
var c = t.samples[n];
|
|
4907
4907
|
return c.data ? (this.samplesDataSize -= c.size, c.data = null, c.alreadyRead = 0, c.size) : 0;
|
|
4908
|
-
},
|
|
4908
|
+
}, b.prototype.getAllocatedSampleDataSize = function() {
|
|
4909
4909
|
return this.samplesDataSize;
|
|
4910
|
-
},
|
|
4910
|
+
}, b.prototype.getCodecs = function() {
|
|
4911
4911
|
var t, n = "";
|
|
4912
4912
|
for (t = 0; t < this.moov.traks.length; t++) {
|
|
4913
4913
|
var c = this.moov.traks[t];
|
|
4914
4914
|
t > 0 && (n += ","), n += c.mdia.minf.stbl.stsd.entries[0].getCodec();
|
|
4915
4915
|
}
|
|
4916
4916
|
return n;
|
|
4917
|
-
},
|
|
4917
|
+
}, b.prototype.getTrexById = function(t) {
|
|
4918
4918
|
var n;
|
|
4919
4919
|
if (!this.moov || !this.moov.mvex) return null;
|
|
4920
4920
|
for (n = 0; n < this.moov.mvex.trexs.length; n++) {
|
|
@@ -4922,7 +4922,7 @@ var zi = {};
|
|
|
4922
4922
|
if (c.track_id == t) return c;
|
|
4923
4923
|
}
|
|
4924
4924
|
return null;
|
|
4925
|
-
},
|
|
4925
|
+
}, b.prototype.getTrackById = function(t) {
|
|
4926
4926
|
if (this.moov === void 0)
|
|
4927
4927
|
return null;
|
|
4928
4928
|
for (var n = 0; n < this.moov.traks.length; n++) {
|
|
@@ -4930,7 +4930,7 @@ var zi = {};
|
|
|
4930
4930
|
if (c.tkhd.track_id == t) return c;
|
|
4931
4931
|
}
|
|
4932
4932
|
return null;
|
|
4933
|
-
},
|
|
4933
|
+
}, b.prototype.itemsDataSize = 0, b.prototype.flattenItemInfo = function() {
|
|
4934
4934
|
var t = this.items, n = this.entity_groups, c, d, f, g = this.meta;
|
|
4935
4935
|
if (g != null && g.hdlr !== void 0 && g.iinf !== void 0) {
|
|
4936
4936
|
for (c = 0; c < g.iinf.item_infos.length; c++)
|
|
@@ -4940,8 +4940,8 @@ var zi = {};
|
|
|
4940
4940
|
entity_group = {}, entity_group.id = g.grpl.boxes[c].group_id, entity_group.entity_ids = g.grpl.boxes[c].entity_ids, entity_group.type = g.grpl.boxes[c].type, n[entity_group.id] = entity_group;
|
|
4941
4941
|
if (g.iloc)
|
|
4942
4942
|
for (c = 0; c < g.iloc.items.length; c++) {
|
|
4943
|
-
var
|
|
4944
|
-
switch (f = t[
|
|
4943
|
+
var _ = g.iloc.items[c];
|
|
4944
|
+
switch (f = t[_.item_ID], _.data_reference_index !== 0 && (e.warn("Item storage with reference to other files: not supported"), f.source = g.dinf.boxes[_.data_reference_index - 1]), _.construction_method) {
|
|
4945
4945
|
case 0:
|
|
4946
4946
|
break;
|
|
4947
4947
|
case 1:
|
|
@@ -4950,14 +4950,14 @@ var zi = {};
|
|
|
4950
4950
|
e.warn("Item storage with construction_method : not supported");
|
|
4951
4951
|
break;
|
|
4952
4952
|
}
|
|
4953
|
-
for (f.extents = [], f.size = 0, d = 0; d <
|
|
4954
|
-
f.extents[d] = {}, f.extents[d].offset =
|
|
4953
|
+
for (f.extents = [], f.size = 0, d = 0; d < _.extents.length; d++)
|
|
4954
|
+
f.extents[d] = {}, f.extents[d].offset = _.extents[d].extent_offset + _.base_offset, _.construction_method == 1 && (f.extents[d].offset += g.idat.start + g.idat.hdr_size), f.extents[d].length = _.extents[d].extent_length, f.extents[d].alreadyRead = 0, f.size += f.extents[d].length;
|
|
4955
4955
|
}
|
|
4956
4956
|
if (g.pitm && (t[g.pitm.item_id].primary = !0), g.iref)
|
|
4957
4957
|
for (c = 0; c < g.iref.references.length; c++) {
|
|
4958
|
-
var
|
|
4959
|
-
for (d = 0; d <
|
|
4960
|
-
t[
|
|
4958
|
+
var w = g.iref.references[c];
|
|
4959
|
+
for (d = 0; d < w.references.length; d++)
|
|
4960
|
+
t[w.from_item_ID].ref_to.push({ type: w.type, id: w.references[d] });
|
|
4961
4961
|
}
|
|
4962
4962
|
if (g.iprp)
|
|
4963
4963
|
for (var C = 0; C < g.iprp.ipmas.length; C++) {
|
|
@@ -4975,7 +4975,7 @@ var zi = {};
|
|
|
4975
4975
|
}
|
|
4976
4976
|
}
|
|
4977
4977
|
}
|
|
4978
|
-
},
|
|
4978
|
+
}, b.prototype.getItem = function(t) {
|
|
4979
4979
|
var n, c;
|
|
4980
4980
|
if (!this.meta)
|
|
4981
4981
|
return null;
|
|
@@ -4989,8 +4989,8 @@ var zi = {};
|
|
|
4989
4989
|
var g = this.stream.findPosition(!0, f.offset + f.alreadyRead, !1);
|
|
4990
4990
|
if (g > -1) {
|
|
4991
4991
|
n = this.stream.buffers[g];
|
|
4992
|
-
var
|
|
4993
|
-
if (f.length - f.alreadyRead <=
|
|
4992
|
+
var _ = n.byteLength - (f.offset + f.alreadyRead - n.fileStart);
|
|
4993
|
+
if (f.length - f.alreadyRead <= _)
|
|
4994
4994
|
e.debug("ISOFile", "Getting item #" + t + " extent #" + d + " data (alreadyRead: " + f.alreadyRead + " offset: " + (f.offset + f.alreadyRead - n.fileStart) + " read size: " + (f.length - f.alreadyRead) + " full extent size: " + f.length + " full item size: " + c.size + ")"), r.memcpy(
|
|
4995
4995
|
c.data.buffer,
|
|
4996
4996
|
c.alreadyRead,
|
|
@@ -4999,19 +4999,19 @@ var zi = {};
|
|
|
4999
4999
|
f.length - f.alreadyRead
|
|
5000
5000
|
), n.usedBytes += f.length - f.alreadyRead, this.stream.logBufferLevel(), c.alreadyRead += f.length - f.alreadyRead, f.alreadyRead = f.length;
|
|
5001
5001
|
else
|
|
5002
|
-
return e.debug("ISOFile", "Getting item #" + t + " extent #" + d + " partial data (alreadyRead: " + f.alreadyRead + " offset: " + (f.offset + f.alreadyRead - n.fileStart) + " read size: " +
|
|
5002
|
+
return e.debug("ISOFile", "Getting item #" + t + " extent #" + d + " partial data (alreadyRead: " + f.alreadyRead + " offset: " + (f.offset + f.alreadyRead - n.fileStart) + " read size: " + _ + " full extent size: " + f.length + " full item size: " + c.size + ")"), r.memcpy(
|
|
5003
5003
|
c.data.buffer,
|
|
5004
5004
|
c.alreadyRead,
|
|
5005
5005
|
n,
|
|
5006
5006
|
f.offset + f.alreadyRead - n.fileStart,
|
|
5007
|
-
|
|
5008
|
-
), f.alreadyRead +=
|
|
5007
|
+
_
|
|
5008
|
+
), f.alreadyRead += _, c.alreadyRead += _, n.usedBytes += _, this.stream.logBufferLevel(), null;
|
|
5009
5009
|
} else
|
|
5010
5010
|
return null;
|
|
5011
5011
|
}
|
|
5012
5012
|
}
|
|
5013
5013
|
return c.alreadyRead === c.size ? c : null;
|
|
5014
|
-
},
|
|
5014
|
+
}, b.prototype.releaseItem = function(t) {
|
|
5015
5015
|
var n = this.items[t];
|
|
5016
5016
|
if (n.data) {
|
|
5017
5017
|
this.itemsDataSize -= n.size, n.data = null, n.alreadyRead = 0;
|
|
@@ -5022,64 +5022,64 @@ var zi = {};
|
|
|
5022
5022
|
return n.size;
|
|
5023
5023
|
} else
|
|
5024
5024
|
return 0;
|
|
5025
|
-
},
|
|
5025
|
+
}, b.prototype.processItems = function(t) {
|
|
5026
5026
|
for (var n in this.items) {
|
|
5027
5027
|
var c = this.items[n];
|
|
5028
5028
|
this.getItem(c.id), t && !c.sent && (t(c), c.sent = !0, c.data = null);
|
|
5029
5029
|
}
|
|
5030
|
-
},
|
|
5030
|
+
}, b.prototype.hasItem = function(t) {
|
|
5031
5031
|
for (var n in this.items) {
|
|
5032
5032
|
var c = this.items[n];
|
|
5033
5033
|
if (c.name === t)
|
|
5034
5034
|
return c.id;
|
|
5035
5035
|
}
|
|
5036
5036
|
return -1;
|
|
5037
|
-
},
|
|
5037
|
+
}, b.prototype.getMetaHandler = function() {
|
|
5038
5038
|
return this.meta ? this.meta.hdlr.handler : null;
|
|
5039
|
-
},
|
|
5039
|
+
}, b.prototype.getPrimaryItem = function() {
|
|
5040
5040
|
return !this.meta || !this.meta.pitm ? null : this.getItem(this.meta.pitm.item_id);
|
|
5041
|
-
},
|
|
5041
|
+
}, b.prototype.itemToFragmentedTrackFile = function(t) {
|
|
5042
5042
|
var n = t || {}, c = null;
|
|
5043
5043
|
if (n.itemId ? c = this.getItem(n.itemId) : c = this.getPrimaryItem(), c == null) return null;
|
|
5044
|
-
var d = new
|
|
5044
|
+
var d = new b();
|
|
5045
5045
|
d.discardMdatData = !1;
|
|
5046
5046
|
var f = { type: c.type, description_boxes: c.properties.boxes };
|
|
5047
5047
|
c.properties.ispe && (f.width = c.properties.ispe.image_width, f.height = c.properties.ispe.image_height);
|
|
5048
5048
|
var g = d.addTrack(f);
|
|
5049
5049
|
return g ? (d.addSample(g, c.data), d) : null;
|
|
5050
|
-
},
|
|
5050
|
+
}, b.prototype.write = function(t) {
|
|
5051
5051
|
for (var n = 0; n < this.boxes.length; n++)
|
|
5052
5052
|
this.boxes[n].write(t);
|
|
5053
|
-
},
|
|
5053
|
+
}, b.prototype.createFragment = function(t, n, c) {
|
|
5054
5054
|
var d = this.getTrackById(t), f = this.getSample(d, n);
|
|
5055
5055
|
if (f == null)
|
|
5056
5056
|
return this.setNextSeekPositionFromSample(d.samples[n]), null;
|
|
5057
5057
|
var g = c || new r();
|
|
5058
5058
|
g.endianness = r.BIG_ENDIAN;
|
|
5059
|
-
var
|
|
5060
|
-
|
|
5061
|
-
var
|
|
5062
|
-
return
|
|
5063
|
-
},
|
|
5059
|
+
var _ = this.createSingleSampleMoof(f);
|
|
5060
|
+
_.write(g), _.trafs[0].truns[0].data_offset = _.size + 8, e.debug("MP4Box", "Adjusting data_offset with new value " + _.trafs[0].truns[0].data_offset), g.adjustUint32(_.trafs[0].truns[0].data_offset_position, _.trafs[0].truns[0].data_offset);
|
|
5061
|
+
var w = new o.mdatBox();
|
|
5062
|
+
return w.data = f.data, w.write(g), g;
|
|
5063
|
+
}, b.writeInitializationSegment = function(t, n, c, d) {
|
|
5064
5064
|
var f;
|
|
5065
5065
|
e.debug("ISOFile", "Generating initialization segment");
|
|
5066
5066
|
var g = new r();
|
|
5067
5067
|
g.endianness = r.BIG_ENDIAN, t.write(g);
|
|
5068
|
-
var
|
|
5069
|
-
for (c &&
|
|
5070
|
-
|
|
5068
|
+
var _ = n.add("mvex");
|
|
5069
|
+
for (c && _.add("mehd").set("fragment_duration", c), f = 0; f < n.traks.length; f++)
|
|
5070
|
+
_.add("trex").set("track_id", n.traks[f].tkhd.track_id).set("default_sample_description_index", 1).set("default_sample_duration", d).set("default_sample_size", 0).set("default_sample_flags", 65536);
|
|
5071
5071
|
return n.write(g), g.buffer;
|
|
5072
|
-
},
|
|
5072
|
+
}, b.prototype.save = function(t) {
|
|
5073
5073
|
var n = new r();
|
|
5074
5074
|
n.endianness = r.BIG_ENDIAN, this.write(n), n.save(t);
|
|
5075
|
-
},
|
|
5075
|
+
}, b.prototype.getBuffer = function() {
|
|
5076
5076
|
var t = new r();
|
|
5077
5077
|
return t.endianness = r.BIG_ENDIAN, this.write(t), t.buffer;
|
|
5078
|
-
},
|
|
5078
|
+
}, b.prototype.initializeSegmentation = function() {
|
|
5079
5079
|
var t, n, c, d;
|
|
5080
5080
|
for (this.onSegment === null && e.warn("MP4Box", "No segmentation callback set!"), this.isFragmentationInitialized || (this.isFragmentationInitialized = !0, this.nextMoofNumber = 0, this.resetTables()), n = [], t = 0; t < this.fragmentedTracks.length; t++) {
|
|
5081
5081
|
var f = new o.moovBox();
|
|
5082
|
-
f.mvhd = this.moov.mvhd, f.boxes.push(f.mvhd), c = this.getTrackById(this.fragmentedTracks[t].id), f.boxes.push(c), f.traks.push(c), d = {}, d.id = c.tkhd.track_id, d.user = this.fragmentedTracks[t].user, d.buffer =
|
|
5082
|
+
f.mvhd = this.moov.mvhd, f.boxes.push(f.mvhd), c = this.getTrackById(this.fragmentedTracks[t].id), f.boxes.push(c), f.traks.push(c), d = {}, d.id = c.tkhd.track_id, d.user = this.fragmentedTracks[t].user, d.buffer = b.writeInitializationSegment(this.ftyp, f, this.moov.mvex && this.moov.mvex.mehd ? this.moov.mvex.mehd.fragment_duration : void 0, this.moov.traks[t].samples.length > 0 ? this.moov.traks[t].samples[0].duration : 0), n.push(d);
|
|
5083
5083
|
}
|
|
5084
5084
|
return n;
|
|
5085
5085
|
}, o.Box.prototype.printHeader = function(t) {
|
|
@@ -5095,7 +5095,7 @@ var zi = {};
|
|
|
5095
5095
|
var c = t.indent;
|
|
5096
5096
|
t.indent += " ", this.boxes[n].print(t), t.indent = c;
|
|
5097
5097
|
}
|
|
5098
|
-
},
|
|
5098
|
+
}, b.prototype.print = function(t) {
|
|
5099
5099
|
t.indent = "";
|
|
5100
5100
|
for (var n = 0; n < this.boxes.length; n++)
|
|
5101
5101
|
this.boxes[n] && this.boxes[n].print(t);
|
|
@@ -5106,7 +5106,7 @@ var zi = {};
|
|
|
5106
5106
|
};
|
|
5107
5107
|
var T = {};
|
|
5108
5108
|
T.createFile = function(t, n) {
|
|
5109
|
-
var c = t !== void 0 ? t : !0, d = new
|
|
5109
|
+
var c = t !== void 0 ? t : !0, d = new b(n);
|
|
5110
5110
|
return d.discardMdatData = !c, d;
|
|
5111
5111
|
}, a.createFile = T.createFile;
|
|
5112
5112
|
})(zi);
|
|
@@ -5203,27 +5203,27 @@ class Qt {
|
|
|
5203
5203
|
return;
|
|
5204
5204
|
}
|
|
5205
5205
|
this.videoTimestampOffset === null && (this.videoTimestampOffset = o);
|
|
5206
|
-
const m = o - this.videoTimestampOffset,
|
|
5206
|
+
const m = o - this.videoTimestampOffset, y = new EncodedVideoChunk({
|
|
5207
5207
|
type: u.is_sync ? "key" : "delta",
|
|
5208
5208
|
timestamp: m,
|
|
5209
5209
|
duration: p,
|
|
5210
5210
|
data: u.data
|
|
5211
5211
|
});
|
|
5212
|
-
this.videoController.enqueue(
|
|
5212
|
+
this.videoController.enqueue(y);
|
|
5213
5213
|
} else if (r.type === "audio") {
|
|
5214
5214
|
if (!this.audioController) {
|
|
5215
|
-
const
|
|
5216
|
-
this.mp4boxFile.releaseUsedSamples(e,
|
|
5215
|
+
const v = s[s.length - 1].number;
|
|
5216
|
+
this.mp4boxFile.releaseUsedSamples(e, v + 1);
|
|
5217
5217
|
return;
|
|
5218
5218
|
}
|
|
5219
5219
|
this.audioTimestampOffset === null && (this.audioTimestampOffset = o);
|
|
5220
|
-
const m = o - this.audioTimestampOffset,
|
|
5220
|
+
const m = o - this.audioTimestampOffset, y = new EncodedAudioChunk({
|
|
5221
5221
|
type: "key",
|
|
5222
5222
|
timestamp: m,
|
|
5223
5223
|
duration: p,
|
|
5224
5224
|
data: u.data
|
|
5225
5225
|
});
|
|
5226
|
-
this.audioController.enqueue(
|
|
5226
|
+
this.audioController.enqueue(y);
|
|
5227
5227
|
}
|
|
5228
5228
|
}
|
|
5229
5229
|
const l = s[s.length - 1].number;
|
|
@@ -5370,14 +5370,14 @@ class Ni extends Error {
|
|
|
5370
5370
|
super(`Waiter for clip ${e} was replaced by a newer waiter`), this.clipId = e, this.name = "WaiterReplacedError";
|
|
5371
5371
|
}
|
|
5372
5372
|
}
|
|
5373
|
-
class
|
|
5373
|
+
class Dt extends Error {
|
|
5374
5374
|
constructor(e, s) {
|
|
5375
5375
|
super(
|
|
5376
5376
|
`Empty stream received for resource ${e}. File offset: ${s}. This indicates the file is being written or is corrupted.`
|
|
5377
5377
|
), this.resourceId = e, this.fileOffset = s, this.name = "EmptyStreamError";
|
|
5378
5378
|
}
|
|
5379
5379
|
}
|
|
5380
|
-
class
|
|
5380
|
+
class Le extends Error {
|
|
5381
5381
|
constructor(e, s) {
|
|
5382
5382
|
super(`Resource ${e} is corrupted: ${s}`), this.resourceId = e, this.reason = s, this.name = "ResourceCorruptedError";
|
|
5383
5383
|
}
|
|
@@ -5410,10 +5410,10 @@ class wr {
|
|
|
5410
5410
|
const r = s?.resourceId || "unknown", h = ge.createFile();
|
|
5411
5411
|
let l = null, u = null;
|
|
5412
5412
|
const o = [];
|
|
5413
|
-
let p, m,
|
|
5413
|
+
let p, m, y, v = 0, k = null;
|
|
5414
5414
|
const x = new Promise((n, c) => {
|
|
5415
5415
|
l = n, u = c;
|
|
5416
|
-
}),
|
|
5416
|
+
}), b = {
|
|
5417
5417
|
byteEnd: 0,
|
|
5418
5418
|
extracted: !s?.onFirstFrameReady,
|
|
5419
5419
|
index: null,
|
|
@@ -5429,44 +5429,44 @@ class wr {
|
|
|
5429
5429
|
try {
|
|
5430
5430
|
T.moovParsed = !0, k = n;
|
|
5431
5431
|
const c = this.buildIndex(h, n);
|
|
5432
|
-
if (
|
|
5433
|
-
const U = c.tracks.video.gopIndex[0], E = c.tracks.video.samples, P = U.keyframeSampleIndex + U.sampleCount,
|
|
5434
|
-
|
|
5432
|
+
if (b.index = c, n.isProgressive === !0 && s?.onFirstFrameReady && c.tracks.video?.gopIndex[0]) {
|
|
5433
|
+
const U = c.tracks.video.gopIndex[0], E = c.tracks.video.samples, P = U.keyframeSampleIndex + U.sampleCount, B = E[P - 1];
|
|
5434
|
+
B && (b.byteEnd = B.byteOffset + B.byteLength);
|
|
5435
5435
|
}
|
|
5436
|
-
const { config: f, trackId: g, timescale:
|
|
5437
|
-
p = f, m = g,
|
|
5438
|
-
T.moovParsed && T.audioComplete &&
|
|
5436
|
+
const { config: f, trackId: g, timescale: _, expectedSamples: w, isComplete: C } = this.setupAudioExtraction(h, n);
|
|
5437
|
+
p = f, m = g, y = _, v = w, T.audioComplete = C, C && setTimeout(() => {
|
|
5438
|
+
T.moovParsed && T.audioComplete && b.extracted && l?.({ index: c });
|
|
5439
5439
|
}, 0);
|
|
5440
5440
|
} catch (c) {
|
|
5441
5441
|
u?.(c);
|
|
5442
5442
|
}
|
|
5443
5443
|
}, h.onSamples = (n, c, d) => {
|
|
5444
5444
|
if (n === m && p) {
|
|
5445
|
-
const f =
|
|
5445
|
+
const f = y || p.sampleRate;
|
|
5446
5446
|
if (d && d.length > 0)
|
|
5447
5447
|
for (const g of d)
|
|
5448
5448
|
try {
|
|
5449
|
-
const
|
|
5449
|
+
const _ = new EncodedAudioChunk({
|
|
5450
5450
|
type: g.is_sync ? "key" : "delta",
|
|
5451
5451
|
timestamp: Math.round(g.cts / f * 1e6),
|
|
5452
5452
|
duration: Math.round(g.duration / f * 1e6),
|
|
5453
5453
|
data: g.data
|
|
5454
5454
|
});
|
|
5455
|
-
o.push(
|
|
5456
|
-
} catch (
|
|
5457
|
-
console.warn("[MP4IndexParser] Failed to create audio chunk:",
|
|
5455
|
+
o.push(_);
|
|
5456
|
+
} catch (_) {
|
|
5457
|
+
console.warn("[MP4IndexParser] Failed to create audio chunk:", _);
|
|
5458
5458
|
}
|
|
5459
|
-
|
|
5459
|
+
v !== 1 / 0 && o.length >= v && (T.audioComplete = !0);
|
|
5460
5460
|
}
|
|
5461
5461
|
}, await this.processStreamData(
|
|
5462
5462
|
e,
|
|
5463
5463
|
h,
|
|
5464
5464
|
s,
|
|
5465
|
-
|
|
5465
|
+
b,
|
|
5466
5466
|
T,
|
|
5467
5467
|
r
|
|
5468
5468
|
), h.flush(), await new Promise((n) => setTimeout(n, 100)), T.moovParsed && T.audioComplete) {
|
|
5469
|
-
const n =
|
|
5469
|
+
const n = b.index || this.buildIndex(h, k);
|
|
5470
5470
|
l({
|
|
5471
5471
|
index: n,
|
|
5472
5472
|
audioSamples: o,
|
|
@@ -5497,18 +5497,18 @@ class wr {
|
|
|
5497
5497
|
try {
|
|
5498
5498
|
let p = !1;
|
|
5499
5499
|
for (; ; ) {
|
|
5500
|
-
const { done: m, value:
|
|
5500
|
+
const { done: m, value: y } = await o.read();
|
|
5501
5501
|
if (m)
|
|
5502
5502
|
break;
|
|
5503
|
-
if (
|
|
5503
|
+
if (y) {
|
|
5504
5504
|
p = !0;
|
|
5505
|
-
const
|
|
5506
|
-
if (this.handleFirstGOPExtraction(
|
|
5505
|
+
const v = this.prepareBuffer(y, l.fileOffset);
|
|
5506
|
+
if (this.handleFirstGOPExtraction(v, y, r, h, l), s.appendBuffer(v), l.fileOffset += v.byteLength, l.moovParsed && l.audioComplete && h.extracted)
|
|
5507
5507
|
break;
|
|
5508
5508
|
}
|
|
5509
5509
|
}
|
|
5510
5510
|
if (!p)
|
|
5511
|
-
throw new
|
|
5511
|
+
throw new Dt(u, l.fileOffset);
|
|
5512
5512
|
} finally {
|
|
5513
5513
|
o.releaseLock();
|
|
5514
5514
|
}
|
|
@@ -5639,11 +5639,11 @@ class wr {
|
|
|
5639
5639
|
const u = l.samples || [];
|
|
5640
5640
|
let o = null;
|
|
5641
5641
|
for (const p of u) {
|
|
5642
|
-
const m = (p.duration || 0) / r * 1e6,
|
|
5643
|
-
o === null && (o =
|
|
5644
|
-
const
|
|
5642
|
+
const m = (p.duration || 0) / r * 1e6, y = (p.cts || 0) / r * 1e6;
|
|
5643
|
+
o === null && (o = y);
|
|
5644
|
+
const v = y - o;
|
|
5645
5645
|
h.push({
|
|
5646
|
-
timestamp:
|
|
5646
|
+
timestamp: v,
|
|
5647
5647
|
// Normalized PTS (display timestamp)
|
|
5648
5648
|
duration: m,
|
|
5649
5649
|
byteOffset: p.offset || 0,
|
|
@@ -5689,8 +5689,8 @@ class wr {
|
|
|
5689
5689
|
for (let o = 0; o < l.sampleCount; o++) {
|
|
5690
5690
|
const p = l.keyframeSampleIndex + o, m = u[p];
|
|
5691
5691
|
if (!m) continue;
|
|
5692
|
-
const
|
|
5693
|
-
if (
|
|
5692
|
+
const y = m.byteOffset - r;
|
|
5693
|
+
if (y < 0 || y + m.byteLength > e.length) {
|
|
5694
5694
|
if (o === 0)
|
|
5695
5695
|
return console.warn(
|
|
5696
5696
|
"[MP4IndexParser] First GOP keyframe not fully downloaded, skipping cover decode"
|
|
@@ -5699,21 +5699,21 @@ class wr {
|
|
|
5699
5699
|
sampleOffset: m.byteOffset,
|
|
5700
5700
|
sampleLength: m.byteLength,
|
|
5701
5701
|
byteStart: r,
|
|
5702
|
-
relativeOffset:
|
|
5702
|
+
relativeOffset: y,
|
|
5703
5703
|
bufferLength: e.length,
|
|
5704
5704
|
isKeyframe: m.isKeyframe,
|
|
5705
5705
|
sampleIndex: o
|
|
5706
5706
|
});
|
|
5707
5707
|
continue;
|
|
5708
5708
|
}
|
|
5709
|
-
const
|
|
5709
|
+
const v = e.slice(y, y + m.byteLength);
|
|
5710
5710
|
try {
|
|
5711
5711
|
h.push(
|
|
5712
5712
|
new EncodedVideoChunk({
|
|
5713
5713
|
type: m.isKeyframe ? "key" : "delta",
|
|
5714
5714
|
timestamp: m.timestamp,
|
|
5715
5715
|
duration: m.duration,
|
|
5716
|
-
data:
|
|
5716
|
+
data: v
|
|
5717
5717
|
})
|
|
5718
5718
|
);
|
|
5719
5719
|
} catch (k) {
|
|
@@ -5793,22 +5793,22 @@ class Sr {
|
|
|
5793
5793
|
parseHeader(e, s) {
|
|
5794
5794
|
if (s + 3 >= e.length || e[s] !== 255 || ((e[s + 1] ?? 0) & 224) !== 224)
|
|
5795
5795
|
return null;
|
|
5796
|
-
const r = (e[s + 1] ?? 0) >> 3 & 3, h = (e[s + 1] ?? 0) >> 1 & 3, l = (e[s + 2] ?? 0) >> 4 & 15, u = (e[s + 2] ?? 0) >> 2 & 3, o = (e[s + 2] ?? 0) >> 1 & 1, p = (e[s + 3] ?? 0) >> 6 & 3, m = this.getVersion(r),
|
|
5797
|
-
if (!m || !
|
|
5796
|
+
const r = (e[s + 1] ?? 0) >> 3 & 3, h = (e[s + 1] ?? 0) >> 1 & 3, l = (e[s + 2] ?? 0) >> 4 & 15, u = (e[s + 2] ?? 0) >> 2 & 3, o = (e[s + 2] ?? 0) >> 1 & 1, p = (e[s + 3] ?? 0) >> 6 & 3, m = this.getVersion(r), y = this.getLayer(h);
|
|
5797
|
+
if (!m || !y)
|
|
5798
5798
|
return null;
|
|
5799
|
-
const
|
|
5800
|
-
if (!
|
|
5799
|
+
const v = br[m]?.[u] ?? null;
|
|
5800
|
+
if (!v)
|
|
5801
5801
|
return null;
|
|
5802
|
-
const k = `${m === 1 ? 1 : 2}-${
|
|
5802
|
+
const k = `${m === 1 ? 1 : 2}-${y}`, x = vr[k]?.[l] ?? null;
|
|
5803
5803
|
if (x === null)
|
|
5804
5804
|
return null;
|
|
5805
|
-
const
|
|
5805
|
+
const b = this.getSamplesPerFrame(m, y), T = this.calculateFrameSize(y, x, v, o);
|
|
5806
5806
|
return !T || T < 24 ? null : {
|
|
5807
5807
|
frameSize: T,
|
|
5808
|
-
sampleRate:
|
|
5808
|
+
sampleRate: v,
|
|
5809
5809
|
channels: p === 3 ? 1 : 2,
|
|
5810
5810
|
bitrateKbps: x || null,
|
|
5811
|
-
samplesPerFrame:
|
|
5811
|
+
samplesPerFrame: b
|
|
5812
5812
|
};
|
|
5813
5813
|
}
|
|
5814
5814
|
getVersion(e) {
|
|
@@ -5861,7 +5861,7 @@ class Cr {
|
|
|
5861
5861
|
isPreloadingEnabled = !0;
|
|
5862
5862
|
constructor(e) {
|
|
5863
5863
|
const s = e.config || {}, r = s.maxConcurrent ?? 3, h = s.preloadConcurrency ?? 2;
|
|
5864
|
-
this.taskManager = new ur(r, h), this.streamFactory = new
|
|
5864
|
+
this.taskManager = new ur(r, h), this.streamFactory = new De(e.onProgress, s), this.eventBus = e.eventBus, this.onStateChange = e.onStateChange, this.cacheManager = e.cacheManager;
|
|
5865
5865
|
}
|
|
5866
5866
|
async setModel(e) {
|
|
5867
5867
|
this.model = e;
|
|
@@ -5912,7 +5912,7 @@ class Cr {
|
|
|
5912
5912
|
try {
|
|
5913
5913
|
await this.ensureIndexParsed(e.resourceId);
|
|
5914
5914
|
} catch (r) {
|
|
5915
|
-
if (r instanceof
|
|
5915
|
+
if (r instanceof Le || r instanceof Dt) {
|
|
5916
5916
|
await this.loadWithOPFSCache(e);
|
|
5917
5917
|
return;
|
|
5918
5918
|
}
|
|
@@ -6002,7 +6002,7 @@ class Cr {
|
|
|
6002
6002
|
this.parsingIndexes.add(e);
|
|
6003
6003
|
try {
|
|
6004
6004
|
if (!await this.cacheManager.hasResourceInCache(e))
|
|
6005
|
-
throw new
|
|
6005
|
+
throw new Le(e, "File not found in OPFS or is empty");
|
|
6006
6006
|
const r = await this.createOPFSReadStream(e), h = {
|
|
6007
6007
|
resourceId: e,
|
|
6008
6008
|
resource: { id: e, type: "video", uri: "" },
|
|
@@ -6013,7 +6013,7 @@ class Cr {
|
|
|
6013
6013
|
};
|
|
6014
6014
|
await this.parseIndexFromStream(h, r);
|
|
6015
6015
|
} catch (s) {
|
|
6016
|
-
if (s instanceof
|
|
6016
|
+
if (s instanceof Dt || s instanceof Le) {
|
|
6017
6017
|
console.warn(`[ResourceLoader] Corrupted cache detected for ${e}, clearing...`);
|
|
6018
6018
|
try {
|
|
6019
6019
|
await this.cacheManager.resourceCache.deleteResource(e), this.cacheManager.mp4IndexCache.delete(e);
|
|
@@ -6037,7 +6037,7 @@ class Cr {
|
|
|
6037
6037
|
const h = await s.getProjectDir(r, "resource"), l = `${e}.mp4`;
|
|
6038
6038
|
return (await (await h.getFileHandle(l, { create: !1 })).getFile()).stream();
|
|
6039
6039
|
} catch (h) {
|
|
6040
|
-
throw Ue(h, "NotFoundError") ? new
|
|
6040
|
+
throw Ue(h, "NotFoundError") ? new Le(e, "File not found in OPFS") : h;
|
|
6041
6041
|
}
|
|
6042
6042
|
}
|
|
6043
6043
|
/**
|
|
@@ -6089,10 +6089,10 @@ class Cr {
|
|
|
6089
6089
|
async loadAndParseAudioFile(e) {
|
|
6090
6090
|
const { resourceId: s } = e;
|
|
6091
6091
|
try {
|
|
6092
|
-
const h = await (await this.fetchBlob(e.resource.uri, e.controller.signal)).arrayBuffer(), l = new Uint8Array(h), u = new Sr(), { frames: o, config: p } = u.push(l), m = u.flush(),
|
|
6092
|
+
const h = await (await this.fetchBlob(e.resource.uri, e.controller.signal)).arrayBuffer(), l = new Uint8Array(h), u = new Sr(), { frames: o, config: p } = u.push(l), m = u.flush(), y = [...o, ...m];
|
|
6093
6093
|
if (!p)
|
|
6094
6094
|
throw new Error(`Failed to parse audio config for ${s}`);
|
|
6095
|
-
const
|
|
6095
|
+
const v = y.map((x) => new EncodedAudioChunk({
|
|
6096
6096
|
type: "key",
|
|
6097
6097
|
// MP3 frames are all key frames
|
|
6098
6098
|
timestamp: x.timestampUs,
|
|
@@ -6103,7 +6103,7 @@ class Cr {
|
|
|
6103
6103
|
sampleRate: p.sampleRate,
|
|
6104
6104
|
numberOfChannels: p.channels
|
|
6105
6105
|
};
|
|
6106
|
-
this.cacheManager.audioSampleCache.set(s,
|
|
6106
|
+
this.cacheManager.audioSampleCache.set(s, v, k);
|
|
6107
6107
|
} catch (r) {
|
|
6108
6108
|
throw console.error(`[ResourceLoader] Failed to parse audio file ${s}:`, r), r;
|
|
6109
6109
|
}
|
|
@@ -6117,7 +6117,7 @@ class Cr {
|
|
|
6117
6117
|
const l = new wr(), u = h ? this.shouldExtractCover(h) : !1, o = await l.parseFromStream(s, {
|
|
6118
6118
|
resourceId: r,
|
|
6119
6119
|
onFirstFrameReady: u ? async (p, m) => {
|
|
6120
|
-
p.resourceId = r, this.cacheManager.mp4IndexCache.set(r, p), this.eventBus?.emit(
|
|
6120
|
+
p.resourceId = r, this.cacheManager.mp4IndexCache.set(r, p), this.eventBus?.emit(O.ResourceFirstFrameReady, {
|
|
6121
6121
|
resourceId: r,
|
|
6122
6122
|
clipId: h,
|
|
6123
6123
|
index: p,
|
|
@@ -6171,8 +6171,8 @@ class Cr {
|
|
|
6171
6171
|
const r = this.model?.resources.get(e);
|
|
6172
6172
|
if (r) {
|
|
6173
6173
|
const h = r.state;
|
|
6174
|
-
r.state = s, this.eventBus?.emit(
|
|
6175
|
-
type:
|
|
6174
|
+
r.state = s, this.eventBus?.emit(O.ResourceStageChange, {
|
|
6175
|
+
type: O.ResourceStageChange,
|
|
6176
6176
|
resourceId: e,
|
|
6177
6177
|
oldState: h,
|
|
6178
6178
|
newState: s
|
|
@@ -6404,8 +6404,8 @@ class Ur {
|
|
|
6404
6404
|
o || (o = [], this.framesByClip.set(s, o));
|
|
6405
6405
|
const p = u.timestampUs ?? 0, m = this.findInsertIndex(o, p);
|
|
6406
6406
|
if (m < o.length && (o[m]?.timestampUs ?? 0) === p) {
|
|
6407
|
-
const
|
|
6408
|
-
o[m] = u, this.currentBytes -=
|
|
6407
|
+
const y = o[m];
|
|
6408
|
+
o[m] = u, this.currentBytes -= y?.sizeEstimate ?? 0, y?.close?.();
|
|
6409
6409
|
} else
|
|
6410
6410
|
o.splice(m, 0, u);
|
|
6411
6411
|
return this.currentBytes += u.sizeEstimate, u;
|
|
@@ -6458,9 +6458,9 @@ function Tr(a, e, s) {
|
|
|
6458
6458
|
{ length: e },
|
|
6459
6459
|
() => new Float32Array(s)
|
|
6460
6460
|
), h = (x) => Math.max(-1, Math.min(1, x / 32768)), l = (x) => {
|
|
6461
|
-
const
|
|
6461
|
+
const b = x === "f32" ? new Float32Array(s * e) : new Int16Array(s * e);
|
|
6462
6462
|
try {
|
|
6463
|
-
a.copyTo(
|
|
6463
|
+
a.copyTo(b, { format: x, planeIndex: 0 });
|
|
6464
6464
|
} catch {
|
|
6465
6465
|
return !1;
|
|
6466
6466
|
}
|
|
@@ -6468,7 +6468,7 @@ function Tr(a, e, s) {
|
|
|
6468
6468
|
const t = T * e;
|
|
6469
6469
|
for (let n = 0; n < e; n += 1) {
|
|
6470
6470
|
const c = r[n];
|
|
6471
|
-
c && (x === "f32" ? c[T] =
|
|
6471
|
+
c && (x === "f32" ? c[T] = b[t + n] ?? 0 : c[T] = h(b[t + n] ?? 0));
|
|
6472
6472
|
}
|
|
6473
6473
|
}
|
|
6474
6474
|
return !0;
|
|
@@ -6481,13 +6481,13 @@ function Tr(a, e, s) {
|
|
|
6481
6481
|
}
|
|
6482
6482
|
return !0;
|
|
6483
6483
|
}
|
|
6484
|
-
const
|
|
6484
|
+
const b = new Int16Array(s);
|
|
6485
6485
|
for (let T = 0; T < e; T += 1) {
|
|
6486
6486
|
const t = r[T];
|
|
6487
6487
|
if (t) {
|
|
6488
|
-
a.copyTo(
|
|
6488
|
+
a.copyTo(b, { planeIndex: T, format: "s16-planar" });
|
|
6489
6489
|
for (let n = 0; n < s; n += 1)
|
|
6490
|
-
t[n] = h(
|
|
6490
|
+
t[n] = h(b[n] ?? 0);
|
|
6491
6491
|
}
|
|
6492
6492
|
}
|
|
6493
6493
|
return !0;
|
|
@@ -6497,32 +6497,32 @@ function Tr(a, e, s) {
|
|
|
6497
6497
|
}, o = () => {
|
|
6498
6498
|
try {
|
|
6499
6499
|
for (let x = 0; x < e; x += 1) {
|
|
6500
|
-
const
|
|
6501
|
-
|
|
6500
|
+
const b = r[x];
|
|
6501
|
+
b && a.copyTo(b, { planeIndex: x });
|
|
6502
6502
|
}
|
|
6503
6503
|
return !0;
|
|
6504
6504
|
} catch {
|
|
6505
6505
|
return !1;
|
|
6506
6506
|
}
|
|
6507
|
-
}, p = a.format, m = [],
|
|
6508
|
-
|
|
6507
|
+
}, p = a.format, m = [], y = /* @__PURE__ */ new Set(), v = (x, b) => {
|
|
6508
|
+
y.has(x) || (y.add(x), m.push(b));
|
|
6509
6509
|
};
|
|
6510
6510
|
if (p)
|
|
6511
6511
|
switch (p) {
|
|
6512
6512
|
case "f32":
|
|
6513
|
-
|
|
6513
|
+
v("f32", () => l("f32"));
|
|
6514
6514
|
break;
|
|
6515
6515
|
case "s16":
|
|
6516
|
-
|
|
6516
|
+
v("s16", () => l("s16"));
|
|
6517
6517
|
break;
|
|
6518
6518
|
case "f32-planar":
|
|
6519
|
-
|
|
6519
|
+
v("f32-planar", () => u("f32-planar"));
|
|
6520
6520
|
break;
|
|
6521
6521
|
case "s16-planar":
|
|
6522
|
-
|
|
6522
|
+
v("s16-planar", () => u("s16-planar"));
|
|
6523
6523
|
break;
|
|
6524
6524
|
}
|
|
6525
|
-
|
|
6525
|
+
v("f32-planar", () => u("f32-planar")), v("f32", () => l("f32")), v("s16-planar", () => u("s16-planar")), v("s16", () => l("s16"));
|
|
6526
6526
|
let k = !1;
|
|
6527
6527
|
for (const x of m)
|
|
6528
6528
|
if (x()) {
|
|
@@ -6550,30 +6550,30 @@ class Ir {
|
|
|
6550
6550
|
s.close();
|
|
6551
6551
|
return;
|
|
6552
6552
|
}
|
|
6553
|
-
const
|
|
6553
|
+
const y = Tr(s, l, u);
|
|
6554
6554
|
s.close();
|
|
6555
|
-
const
|
|
6555
|
+
const v = {
|
|
6556
6556
|
timestampUs: p,
|
|
6557
6557
|
durationUs: m,
|
|
6558
|
-
planes:
|
|
6558
|
+
planes: y,
|
|
6559
6559
|
sampleRate: o,
|
|
6560
6560
|
numberOfChannels: l,
|
|
6561
6561
|
globalTimeUs: h
|
|
6562
6562
|
};
|
|
6563
6563
|
let k = this.audioDataByClip.get(e);
|
|
6564
6564
|
k || (k = [], this.audioDataByClip.set(e, k));
|
|
6565
|
-
const x = this.findInsertIndex(k, p),
|
|
6565
|
+
const x = this.findInsertIndex(k, p), b = 0.5 * m;
|
|
6566
6566
|
if (x < k.length) {
|
|
6567
6567
|
const T = k[x];
|
|
6568
|
-
if (Math.abs(T.timestampUs - p) <
|
|
6568
|
+
if (Math.abs(T.timestampUs - p) < b)
|
|
6569
6569
|
return;
|
|
6570
6570
|
}
|
|
6571
6571
|
if (x > 0) {
|
|
6572
6572
|
const T = k[x - 1];
|
|
6573
|
-
if (Math.abs(T.timestampUs - p) <
|
|
6573
|
+
if (Math.abs(T.timestampUs - p) < b)
|
|
6574
6574
|
return;
|
|
6575
6575
|
}
|
|
6576
|
-
k.splice(x, 0,
|
|
6576
|
+
k.splice(x, 0, v);
|
|
6577
6577
|
}
|
|
6578
6578
|
getSlotsInWindow(e, s, r) {
|
|
6579
6579
|
const h = this.audioDataByClip.get(e);
|
|
@@ -6607,28 +6607,28 @@ class Ir {
|
|
|
6607
6607
|
channels: x.numberOfChannels
|
|
6608
6608
|
}))
|
|
6609
6609
|
), null;
|
|
6610
|
-
const
|
|
6610
|
+
const v = Math.ceil(u / 1e6 * p), k = Array.from(
|
|
6611
6611
|
{ length: m },
|
|
6612
|
-
() => new Float32Array(
|
|
6612
|
+
() => new Float32Array(v)
|
|
6613
6613
|
);
|
|
6614
6614
|
for (const x of l) {
|
|
6615
|
-
const
|
|
6616
|
-
if (
|
|
6615
|
+
const b = x.planes[0]?.length ?? 0;
|
|
6616
|
+
if (b <= 0) continue;
|
|
6617
6617
|
const T = Math.round(
|
|
6618
6618
|
(x.timestampUs - s) / 1e6 * p
|
|
6619
|
-
), t = T +
|
|
6619
|
+
), t = T + b, n = Math.max(0, T), d = Math.min(v, t) - n;
|
|
6620
6620
|
if (d <= 0) continue;
|
|
6621
6621
|
const f = n - T;
|
|
6622
6622
|
for (let g = 0; g < m; g++) {
|
|
6623
|
-
const
|
|
6624
|
-
if (!
|
|
6623
|
+
const _ = x.planes[g], w = k[g];
|
|
6624
|
+
if (!_ || !w) continue;
|
|
6625
6625
|
const C = Math.min(
|
|
6626
6626
|
d,
|
|
6627
|
-
|
|
6628
|
-
|
|
6627
|
+
_.length - f,
|
|
6628
|
+
w.length - n
|
|
6629
6629
|
);
|
|
6630
|
-
C <= 0 ||
|
|
6631
|
-
|
|
6630
|
+
C <= 0 || w.set(
|
|
6631
|
+
_.subarray(f, f + C),
|
|
6632
6632
|
n
|
|
6633
6633
|
);
|
|
6634
6634
|
}
|
|
@@ -6703,8 +6703,8 @@ class Ir {
|
|
|
6703
6703
|
return { coveredDurationUs: 0, requestedDurationUs: h };
|
|
6704
6704
|
let o = 0;
|
|
6705
6705
|
for (const p of u) {
|
|
6706
|
-
const m = p.timestampUs + p.durationUs,
|
|
6707
|
-
|
|
6706
|
+
const m = p.timestampUs + p.durationUs, y = Math.max(s, p.timestampUs), v = Math.min(r, m);
|
|
6707
|
+
y < v && (o += v - y);
|
|
6708
6708
|
}
|
|
6709
6709
|
return { coveredDurationUs: o, requestedDurationUs: h };
|
|
6710
6710
|
}
|
|
@@ -6935,10 +6935,10 @@ class Ar {
|
|
|
6935
6935
|
if (l.kind === "directory" && h.startsWith(r)) {
|
|
6936
6936
|
const u = h.slice(r.length), o = l;
|
|
6937
6937
|
let p = 0, m = 0;
|
|
6938
|
-
for await (const [
|
|
6939
|
-
if (
|
|
6938
|
+
for await (const [y, v] of o.entries())
|
|
6939
|
+
if (v.kind === "file")
|
|
6940
6940
|
try {
|
|
6941
|
-
const k = await
|
|
6941
|
+
const k = await v.getFile();
|
|
6942
6942
|
p += k.size, m = Math.max(m, k.lastModified);
|
|
6943
6943
|
} catch (k) {
|
|
6944
6944
|
if (Ue(k, "NotFoundError"))
|
|
@@ -7084,10 +7084,10 @@ class Pr {
|
|
|
7084
7084
|
getGOPRangeForTime(e, s) {
|
|
7085
7085
|
const r = this.indexes.get(e);
|
|
7086
7086
|
if (!r?.tracks.video) return null;
|
|
7087
|
-
const { samples: h, gopIndex: l } = r.tracks.video, u = dt(l, s, (
|
|
7088
|
-
const k = l[
|
|
7087
|
+
const { samples: h, gopIndex: l } = r.tracks.video, u = dt(l, s, (y, v) => {
|
|
7088
|
+
const k = l[v + 1];
|
|
7089
7089
|
return {
|
|
7090
|
-
start:
|
|
7090
|
+
start: y.startTimeUs,
|
|
7091
7091
|
end: k ? k.startTimeUs : 1 / 0
|
|
7092
7092
|
};
|
|
7093
7093
|
});
|
|
@@ -7250,7 +7250,7 @@ class Rr {
|
|
|
7250
7250
|
try {
|
|
7251
7251
|
return await this.resourceCache.readRange(e, s, r);
|
|
7252
7252
|
} catch (h) {
|
|
7253
|
-
throw Ue(h, "NotFoundError") ? new
|
|
7253
|
+
throw Ue(h, "NotFoundError") ? new Le(e, "OPFS file missing") : h;
|
|
7254
7254
|
}
|
|
7255
7255
|
}
|
|
7256
7256
|
/**
|
|
@@ -7310,12 +7310,12 @@ class Rr {
|
|
|
7310
7310
|
*/
|
|
7311
7311
|
addFrame(e, s, r, h, l) {
|
|
7312
7312
|
const u = this.videoL1Cache.addFrame(e, s, r, h, l), o = e.timestamp ?? 0;
|
|
7313
|
-
return this.checkAndNotifyClipReady(s, o), l === 0 && this.eventBus?.emit(
|
|
7313
|
+
return this.checkAndNotifyClipReady(s, o), l === 0 && this.eventBus?.emit(O.CacheCover, {
|
|
7314
7314
|
timeUs: l,
|
|
7315
7315
|
clipId: s,
|
|
7316
7316
|
level: "L1",
|
|
7317
7317
|
size: u.sizeEstimate ?? 0
|
|
7318
|
-
}), this.eventBus?.emit(
|
|
7318
|
+
}), this.eventBus?.emit(O.ComposeFrameReady, {
|
|
7319
7319
|
timeUs: l,
|
|
7320
7320
|
frameNumber: Math.floor(l / r),
|
|
7321
7321
|
renderTimeMs: 0,
|
|
@@ -7407,10 +7407,10 @@ const Hi = {
|
|
|
7407
7407
|
}, Fr = {
|
|
7408
7408
|
name: "normal-50",
|
|
7409
7409
|
textStyle: { fontSize: 50 }
|
|
7410
|
-
},
|
|
7410
|
+
}, Dr = {
|
|
7411
7411
|
name: "normal-60",
|
|
7412
7412
|
textStyle: { fontSize: 60 }
|
|
7413
|
-
},
|
|
7413
|
+
}, Lr = {
|
|
7414
7414
|
name: "normal-80",
|
|
7415
7415
|
textStyle: { fontSize: 80 }
|
|
7416
7416
|
}, zr = {
|
|
@@ -7648,8 +7648,8 @@ const rn = {
|
|
|
7648
7648
|
"normal-30": Hi,
|
|
7649
7649
|
"normal-40": ve,
|
|
7650
7650
|
"normal-50": Fr,
|
|
7651
|
-
"normal-60":
|
|
7652
|
-
"normal-80":
|
|
7651
|
+
"normal-60": Dr,
|
|
7652
|
+
"normal-80": Lr,
|
|
7653
7653
|
"bold-40": zr,
|
|
7654
7654
|
"bold-50": Vi,
|
|
7655
7655
|
"bold-60": Or,
|
|
@@ -7950,8 +7950,8 @@ class un {
|
|
|
7950
7950
|
};
|
|
7951
7951
|
}
|
|
7952
7952
|
attachmentToLayerPlan(e, s, r, h) {
|
|
7953
|
-
const l = e.durationUs, u = Math.max(0, s.startUs), o = Math.min(l, u + s.durationUs), p = this.resolveAttachmentLayerType(s), m = this.buildAttachmentPayload(s, p),
|
|
7954
|
-
return
|
|
7953
|
+
const l = e.durationUs, u = Math.max(0, s.startUs), o = Math.min(l, u + s.durationUs), p = this.resolveAttachmentLayerType(s), m = this.buildAttachmentPayload(s, p), y = "ready", v = m.resourceId;
|
|
7954
|
+
return v && typeof v == "string" && this.registerResourceUsage(v, y, h), {
|
|
7955
7955
|
layerId: `${e.id}-attachment-${s.id}`,
|
|
7956
7956
|
type: p,
|
|
7957
7957
|
activeRanges: [
|
|
@@ -7961,7 +7961,7 @@ class un {
|
|
|
7961
7961
|
}
|
|
7962
7962
|
],
|
|
7963
7963
|
payload: m,
|
|
7964
|
-
status:
|
|
7964
|
+
status: y,
|
|
7965
7965
|
zIndex: r
|
|
7966
7966
|
};
|
|
7967
7967
|
}
|
|
@@ -7986,14 +7986,14 @@ class un {
|
|
|
7986
7986
|
if (s === "text") {
|
|
7987
7987
|
const h = this.getStringField(e.data, "text") || "";
|
|
7988
7988
|
let l = this.getStringField(e.data, "localeCode"), u = this.getStringField(e.data, "fontTemplate");
|
|
7989
|
-
const o = this.getStringField(e.data, "fontFamily"), p = e.data.animation, m = this.getStringField(e.data, "letterCase"),
|
|
7989
|
+
const o = this.getStringField(e.data, "fontFamily"), p = e.data.animation, m = this.getStringField(e.data, "letterCase"), y = e.data.wordTimings;
|
|
7990
7990
|
l || (l = "en-US"), u || (u = this.getDefaultFontTemplate(l));
|
|
7991
|
-
const
|
|
7991
|
+
const v = hn(l, u, o), k = {
|
|
7992
7992
|
text: h,
|
|
7993
7993
|
localeCode: l,
|
|
7994
|
-
fontConfig:
|
|
7994
|
+
fontConfig: v,
|
|
7995
7995
|
letterCase: m,
|
|
7996
|
-
wordTimings:
|
|
7996
|
+
wordTimings: y,
|
|
7997
7997
|
...r
|
|
7998
7998
|
};
|
|
7999
7999
|
return p && (k.animation = {
|
|
@@ -8362,14 +8362,14 @@ class pn {
|
|
|
8362
8362
|
if (!qt(u))
|
|
8363
8363
|
throw new Error(`Clip ${u.id} in audio track is not an audio clip`);
|
|
8364
8364
|
if (this.deps.cacheManager.audioSampleCache.has(u.resourceId)) {
|
|
8365
|
-
this.activeClips.add(u.id), this.deps.eventBus.emit(
|
|
8365
|
+
this.activeClips.add(u.id), this.deps.eventBus.emit(O.ClipActivated, { clipId: u.id });
|
|
8366
8366
|
continue;
|
|
8367
8367
|
}
|
|
8368
8368
|
await this.deps.resourceLoader.load(u.resourceId, {
|
|
8369
8369
|
isPreload: !1,
|
|
8370
8370
|
clipId: u.id,
|
|
8371
8371
|
trackId: l.id
|
|
8372
|
-
}), this.activeClips.add(u.id), this.deps.eventBus.emit(
|
|
8372
|
+
}), this.activeClips.add(u.id), this.deps.eventBus.emit(O.ClipActivated, { clipId: u.id });
|
|
8373
8373
|
}
|
|
8374
8374
|
}
|
|
8375
8375
|
}
|
|
@@ -8382,22 +8382,22 @@ class pn {
|
|
|
8382
8382
|
async ensureAudioForTimeRange(e, s, r) {
|
|
8383
8383
|
const h = this.model;
|
|
8384
8384
|
if (!h) return;
|
|
8385
|
-
const { mode: l = "blocking", loadResource: u = !0, strictMode: o = !1 } = r, m = h.getActiveClips(e, s).map(async (
|
|
8386
|
-
if (
|
|
8387
|
-
const
|
|
8388
|
-
if (
|
|
8385
|
+
const { mode: l = "blocking", loadResource: u = !0, strictMode: o = !1 } = r, m = h.getActiveClips(e, s).map(async (y) => {
|
|
8386
|
+
if (y.trackKind !== "audio" && y.trackKind !== "video" || !re(y)) return;
|
|
8387
|
+
const v = y.audioConfig?.muted ?? !1, k = y.audioConfig?.volume ?? 1;
|
|
8388
|
+
if (v || k <= 0 || h.getResource(y.resourceId)?.state === "ready" && !this.deps.cacheManager.audioSampleCache.has(y.resourceId))
|
|
8389
8389
|
return;
|
|
8390
|
-
if (!this.deps.cacheManager.audioSampleCache.has(
|
|
8390
|
+
if (!this.deps.cacheManager.audioSampleCache.has(y.resourceId)) {
|
|
8391
8391
|
if (!u)
|
|
8392
8392
|
return;
|
|
8393
|
-
h.getResource(
|
|
8393
|
+
h.getResource(y.resourceId)?.state !== "ready" && await this.deps.resourceLoader.load(y.resourceId, {
|
|
8394
8394
|
isPreload: !1,
|
|
8395
|
-
clipId:
|
|
8396
|
-
trackId:
|
|
8395
|
+
clipId: y.id,
|
|
8396
|
+
trackId: y.trackId
|
|
8397
8397
|
});
|
|
8398
8398
|
}
|
|
8399
|
-
const
|
|
8400
|
-
await this.ensureAudioWindow(
|
|
8399
|
+
const b = Math.max(0, e - y.startUs), T = Math.min(y.durationUs, s - y.startUs), t = y.trimStartUs ?? 0, n = b + t, c = T + t;
|
|
8400
|
+
await this.ensureAudioWindow(y.id, n, c, o);
|
|
8401
8401
|
});
|
|
8402
8402
|
if (l === "probe") {
|
|
8403
8403
|
Promise.all(m);
|
|
@@ -8421,9 +8421,9 @@ class pn {
|
|
|
8421
8421
|
const l = this.deps.cacheManager.audioSampleCache.get(h.resourceId);
|
|
8422
8422
|
if (!l)
|
|
8423
8423
|
return;
|
|
8424
|
-
const u = l.samples.filter((
|
|
8425
|
-
const k =
|
|
8426
|
-
return
|
|
8424
|
+
const u = l.samples.filter((v) => {
|
|
8425
|
+
const k = v.timestamp + (v.duration ?? 0);
|
|
8426
|
+
return v.timestamp < r && k > s;
|
|
8427
8427
|
});
|
|
8428
8428
|
if (u.length === 0)
|
|
8429
8429
|
return;
|
|
@@ -8445,18 +8445,18 @@ class pn {
|
|
|
8445
8445
|
);
|
|
8446
8446
|
return;
|
|
8447
8447
|
}
|
|
8448
|
-
const
|
|
8449
|
-
const k =
|
|
8448
|
+
const y = u.filter((v) => {
|
|
8449
|
+
const k = v.timestamp + (v.duration ?? 0);
|
|
8450
8450
|
return !this.deps.cacheManager.getAudioRangeCoverage(
|
|
8451
8451
|
e,
|
|
8452
|
-
|
|
8452
|
+
v.timestamp,
|
|
8453
8453
|
k,
|
|
8454
8454
|
0.95
|
|
8455
8455
|
).covered;
|
|
8456
8456
|
});
|
|
8457
|
-
|
|
8457
|
+
y.length !== 0 && await this.decodeAudioSamples(
|
|
8458
8458
|
e,
|
|
8459
|
-
|
|
8459
|
+
y,
|
|
8460
8460
|
l.metadata,
|
|
8461
8461
|
h.durationUs,
|
|
8462
8462
|
h.startUs
|
|
@@ -8471,10 +8471,10 @@ class pn {
|
|
|
8471
8471
|
if (r.description instanceof ArrayBuffer)
|
|
8472
8472
|
u = r.description;
|
|
8473
8473
|
else if (ArrayBuffer.isView(r.description)) {
|
|
8474
|
-
const m = r.description,
|
|
8475
|
-
new Uint8Array(
|
|
8474
|
+
const m = r.description, y = new ArrayBuffer(m.byteLength);
|
|
8475
|
+
new Uint8Array(y).set(
|
|
8476
8476
|
new Uint8Array(m.buffer, m.byteOffset, m.byteLength)
|
|
8477
|
-
), u =
|
|
8477
|
+
), u = y;
|
|
8478
8478
|
}
|
|
8479
8479
|
}
|
|
8480
8480
|
const o = {
|
|
@@ -8484,7 +8484,7 @@ class pn {
|
|
|
8484
8484
|
description: u
|
|
8485
8485
|
}, p = new mt(`audio-${e}`, o);
|
|
8486
8486
|
try {
|
|
8487
|
-
const
|
|
8487
|
+
const v = new ReadableStream({
|
|
8488
8488
|
start(k) {
|
|
8489
8489
|
for (const x of s)
|
|
8490
8490
|
k.enqueue(x);
|
|
@@ -8493,15 +8493,15 @@ class pn {
|
|
|
8493
8493
|
}).pipeThrough(p.createStream()).getReader();
|
|
8494
8494
|
try {
|
|
8495
8495
|
for (; ; ) {
|
|
8496
|
-
const { done: k, value: x } = await
|
|
8496
|
+
const { done: k, value: x } = await v.read();
|
|
8497
8497
|
if (k) break;
|
|
8498
8498
|
if (x) {
|
|
8499
|
-
const
|
|
8500
|
-
this.deps.cacheManager.putClipAudioData(e, x, h,
|
|
8499
|
+
const b = l + (x.timestamp ?? 0);
|
|
8500
|
+
this.deps.cacheManager.putClipAudioData(e, x, h, b);
|
|
8501
8501
|
}
|
|
8502
8502
|
}
|
|
8503
8503
|
} finally {
|
|
8504
|
-
|
|
8504
|
+
v.releaseLock();
|
|
8505
8505
|
}
|
|
8506
8506
|
} catch (m) {
|
|
8507
8507
|
throw console.error(`[AudioWindowPreparer] Decoder error for clip ${e}:`, m), m;
|
|
@@ -8520,29 +8520,33 @@ class fs {
|
|
|
8520
8520
|
const r = s - e, h = Math.max(
|
|
8521
8521
|
1,
|
|
8522
8522
|
Math.ceil(Math.max(0, r) / 1e6 * this.sampleRate)
|
|
8523
|
-
), l = new OfflineAudioContext(this.numberOfChannels, h, this.sampleRate), u =
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8523
|
+
), l = new OfflineAudioContext(this.numberOfChannels, h, this.sampleRate), u = l.createBuffer(1, h, this.sampleRate), o = l.createBufferSource();
|
|
8524
|
+
o.buffer = u;
|
|
8525
|
+
const p = l.createGain();
|
|
8526
|
+
p.gain.value = 0, o.connect(p), p.connect(l.destination), o.start(0);
|
|
8527
|
+
const m = this.getClipsInWindow(e, s);
|
|
8528
|
+
for (const v of m) {
|
|
8529
|
+
const k = Math.max(e, v.startUs), x = Math.min(s, v.startUs + v.durationUs), b = k - v.startUs, T = x - v.startUs, n = this.getModel()?.findClip(v.clipId)?.trimStartUs ?? 0, c = b + n, d = T + n, f = this.cacheManager.getClipPCMWithMetadata(
|
|
8530
|
+
v.clipId,
|
|
8531
|
+
c,
|
|
8532
|
+
d
|
|
8529
8533
|
);
|
|
8530
|
-
if (!
|
|
8534
|
+
if (!f || f.planes.length === 0)
|
|
8531
8535
|
continue;
|
|
8532
|
-
const
|
|
8533
|
-
if (
|
|
8536
|
+
const g = f.planes[0]?.length ?? 0;
|
|
8537
|
+
if (g === 0)
|
|
8534
8538
|
continue;
|
|
8535
|
-
const
|
|
8536
|
-
for (let
|
|
8537
|
-
const
|
|
8538
|
-
|
|
8539
|
-
}
|
|
8540
|
-
const
|
|
8541
|
-
|
|
8542
|
-
const
|
|
8543
|
-
|
|
8544
|
-
const
|
|
8545
|
-
|
|
8539
|
+
const _ = l.createBuffer(f.planes.length, g, f.sampleRate);
|
|
8540
|
+
for (let I = 0; I < f.planes.length; I++) {
|
|
8541
|
+
const P = f.planes[I];
|
|
8542
|
+
P && _.copyToChannel(new Float32Array(P), I);
|
|
8543
|
+
}
|
|
8544
|
+
const w = l.createBufferSource();
|
|
8545
|
+
w.buffer = _;
|
|
8546
|
+
const C = l.createGain();
|
|
8547
|
+
C.gain.value = v.volume, w.connect(C), C.connect(l.destination);
|
|
8548
|
+
const E = (k - e) / 1e6;
|
|
8549
|
+
w.start(E);
|
|
8546
8550
|
}
|
|
8547
8551
|
return await l.startRendering();
|
|
8548
8552
|
}
|
|
@@ -8673,8 +8677,8 @@ class gn {
|
|
|
8673
8677
|
const h = s?.mode ?? "blocking", l = Math.floor(Math.max(0, e) / this.PREVIEW_BLOCK_DURATION_US);
|
|
8674
8678
|
if (h === "probe") {
|
|
8675
8679
|
this.getOrCreateMixedBlock(l);
|
|
8676
|
-
const m = (l + 1) * this.PREVIEW_BLOCK_DURATION_US - Math.max(0, e),
|
|
8677
|
-
m > 0 && m <=
|
|
8680
|
+
const m = (l + 1) * this.PREVIEW_BLOCK_DURATION_US - Math.max(0, e), y = Math.floor(this.PREVIEW_SCHEDULE_AHEAD_SEC * 1e6);
|
|
8681
|
+
m > 0 && m <= y && this.getOrCreateMixedBlock(l + 1);
|
|
8678
8682
|
return;
|
|
8679
8683
|
}
|
|
8680
8684
|
await this.getOrCreateMixedBlock(l);
|
|
@@ -8800,26 +8804,26 @@ class gn {
|
|
|
8800
8804
|
}
|
|
8801
8805
|
if (this.previewScheduleToken !== s) return;
|
|
8802
8806
|
const o = this.playbackRate || 1, p = this.previewFirstBlockOffsetUs;
|
|
8803
|
-
let m = this.previewNextScheduleTime,
|
|
8804
|
-
const
|
|
8805
|
-
if (m <
|
|
8806
|
-
const c =
|
|
8807
|
-
m = c,
|
|
8807
|
+
let m = this.previewNextScheduleTime, y = p > 0 ? p / 1e6 : 0;
|
|
8808
|
+
const v = e.currentTime;
|
|
8809
|
+
if (m < v + 0.01) {
|
|
8810
|
+
const c = v + 0.02, d = Math.max(0, (c - m) * o);
|
|
8811
|
+
m = c, y += d;
|
|
8808
8812
|
}
|
|
8809
|
-
if (
|
|
8813
|
+
if (y >= u.duration) {
|
|
8810
8814
|
this.previewFirstBlockOffsetUs = 0, this.previewNextBlockIndex = h + 1, this.previewNextScheduleTime = m;
|
|
8811
8815
|
return;
|
|
8812
8816
|
}
|
|
8813
|
-
const k = Math.max(0, u.duration -
|
|
8817
|
+
const k = Math.max(0, u.duration - y);
|
|
8814
8818
|
if (k <= 0) return;
|
|
8815
8819
|
const x = e.createBufferSource();
|
|
8816
8820
|
x.buffer = u, x.playbackRate.value = o;
|
|
8817
|
-
const
|
|
8818
|
-
|
|
8819
|
-
const n = { source: x, gain:
|
|
8821
|
+
const b = e.createGain(), T = this.volume, t = Math.min(this.PREVIEW_BLOCK_FADE_SEC, k / 2);
|
|
8822
|
+
b.gain.setValueAtTime(0, m), b.gain.linearRampToValueAtTime(T, m + t), b.gain.setValueAtTime(T, m + Math.max(t, k - t)), b.gain.linearRampToValueAtTime(0, m + k), x.connect(b), b.connect(e.destination), x.start(m, y);
|
|
8823
|
+
const n = { source: x, gain: b };
|
|
8820
8824
|
this.previewScheduledSources.add(n), x.onended = () => {
|
|
8821
8825
|
try {
|
|
8822
|
-
x.disconnect(),
|
|
8826
|
+
x.disconnect(), b.disconnect();
|
|
8823
8827
|
} catch {
|
|
8824
8828
|
}
|
|
8825
8829
|
this.previewScheduledSources.delete(n);
|
|
@@ -9003,17 +9007,38 @@ class Ye extends yn {
|
|
|
9003
9007
|
}
|
|
9004
9008
|
}
|
|
9005
9009
|
class _n {
|
|
9010
|
+
// ~85ms @ 48kHz, balances overhead and muxer friendliness
|
|
9006
9011
|
constructor(e) {
|
|
9007
9012
|
this.deps = e, this.mixer = new fs(e.cacheManager, () => e.preparer.getModel());
|
|
9008
9013
|
}
|
|
9009
9014
|
mixer;
|
|
9015
|
+
sampleRate = 48e3;
|
|
9016
|
+
exportChunkFrames = 4096;
|
|
9010
9017
|
/**
|
|
9011
9018
|
* Mix and encode audio for a specific segment (used by ExportScheduler)
|
|
9012
9019
|
*/
|
|
9013
9020
|
async mixAndEncodeSegment(e, s, r) {
|
|
9014
9021
|
await this.ensureAudioForSegment(e, s);
|
|
9015
|
-
const h = await this.mixer.mix(e, s)
|
|
9016
|
-
|
|
9022
|
+
const h = await this.mixer.mix(e, s);
|
|
9023
|
+
this.exportEncoder || (this.exportEncoder = new Ye(), await this.exportEncoder.initialize(), this.exportEncoderStream = this.exportEncoder.createStream(), this.exportEncoderWriter = this.exportEncoderStream.writable.getWriter(), this.startExportEncoderReader(this.exportEncoderStream.readable, r), await new Promise((l) => setTimeout(l, 10))), await this.writeAudioDataInChunks(h, e);
|
|
9024
|
+
}
|
|
9025
|
+
async writeAudioDataInChunks(e, s) {
|
|
9026
|
+
const r = e.sampleRate || this.sampleRate, h = e.numberOfChannels, l = e.length, u = [];
|
|
9027
|
+
for (let o = 0; o < h; o++)
|
|
9028
|
+
u.push(e.getChannelData(o));
|
|
9029
|
+
for (let o = 0; o < l; o += this.exportChunkFrames) {
|
|
9030
|
+
const p = Math.min(this.exportChunkFrames, l - o);
|
|
9031
|
+
if (p <= 0) break;
|
|
9032
|
+
const m = s + Math.round(o / r * 1e6), y = u.map((k) => k.subarray(o, o + p)), v = new AudioData({
|
|
9033
|
+
format: "f32-planar",
|
|
9034
|
+
sampleRate: r,
|
|
9035
|
+
numberOfFrames: p,
|
|
9036
|
+
numberOfChannels: h,
|
|
9037
|
+
timestamp: m,
|
|
9038
|
+
data: this.packPlanarF32Data(y)
|
|
9039
|
+
});
|
|
9040
|
+
await this.exportEncoderWriter?.write(v);
|
|
9041
|
+
}
|
|
9017
9042
|
}
|
|
9018
9043
|
/**
|
|
9019
9044
|
* Ensure audio clips in time range are decoded (for export)
|
|
@@ -9043,19 +9068,6 @@ class _n {
|
|
|
9043
9068
|
async finalizeExportAudio() {
|
|
9044
9069
|
this.exportEncoderWriter && (await this.exportEncoderWriter.close(), this.exportEncoderWriter = null), this.exportEncoder = null, this.exportEncoderStream = null;
|
|
9045
9070
|
}
|
|
9046
|
-
audioBufferToAudioData(e, s) {
|
|
9047
|
-
const r = e.sampleRate, h = e.numberOfChannels, l = e.length, u = [];
|
|
9048
|
-
for (let o = 0; o < h; o++)
|
|
9049
|
-
u.push(e.getChannelData(o));
|
|
9050
|
-
return new AudioData({
|
|
9051
|
-
format: "f32-planar",
|
|
9052
|
-
sampleRate: r,
|
|
9053
|
-
numberOfFrames: l,
|
|
9054
|
-
numberOfChannels: h,
|
|
9055
|
-
timestamp: s,
|
|
9056
|
-
data: this.packPlanarF32Data(u)
|
|
9057
|
-
});
|
|
9058
|
-
}
|
|
9059
9071
|
packPlanarF32Data(e) {
|
|
9060
9072
|
const s = e.length, r = e[0]?.length ?? 0, h = s * r, l = new Float32Array(h);
|
|
9061
9073
|
for (let u = 0; u < s; u++) {
|
|
@@ -9117,7 +9129,7 @@ var ni = (a, e, s) => {
|
|
|
9117
9129
|
type: a,
|
|
9118
9130
|
contents: e && new Uint8Array(e.flat(10)),
|
|
9119
9131
|
children: s
|
|
9120
|
-
}),
|
|
9132
|
+
}), Y = (a, e, s, r, h) => Q(
|
|
9121
9133
|
a,
|
|
9122
9134
|
[Z(e), ps(s), r ?? []],
|
|
9123
9135
|
h
|
|
@@ -9142,7 +9154,7 @@ var ni = (a, e, s) => {
|
|
|
9142
9154
|
a.holdsAvc ? ce("avc1") : [],
|
|
9143
9155
|
ce("mp41")
|
|
9144
9156
|
]);
|
|
9145
|
-
},
|
|
9157
|
+
}, Lt = (a) => ({ type: "mdat", largeSize: a }), Cn = (a) => ({ type: "free", size: a }), ot = (a, e, s = !1) => Q("moov", null, [
|
|
9146
9158
|
xn(e, a),
|
|
9147
9159
|
...a.map((r) => kn(r, e)),
|
|
9148
9160
|
s ? io(a) : null
|
|
@@ -9154,7 +9166,7 @@ var ni = (a, e, s) => {
|
|
|
9154
9166
|
return o.presentationTimestamp + o.duration;
|
|
9155
9167
|
})
|
|
9156
9168
|
), Wt), r = Math.max(...e.map((u) => u.id)) + 1, h = !We(a) || !We(s), l = h ? Ie : M;
|
|
9157
|
-
return
|
|
9169
|
+
return Y("mvhd", +h, 0, [
|
|
9158
9170
|
l(a),
|
|
9159
9171
|
// Creation time
|
|
9160
9172
|
l(a),
|
|
@@ -9184,7 +9196,7 @@ var ni = (a, e, s) => {
|
|
|
9184
9196
|
s ? s.presentationTimestamp + s.duration : 0,
|
|
9185
9197
|
Wt
|
|
9186
9198
|
), h = !We(e) || !We(r), l = h ? Ie : M, u;
|
|
9187
|
-
return a.info.type === "video" ? u = typeof a.info.rotation == "number" ? ms(a.info.rotation) : a.info.rotation : u = gs,
|
|
9199
|
+
return a.info.type === "video" ? u = typeof a.info.rotation == "number" ? ms(a.info.rotation) : a.info.rotation : u = gs, Y("tkhd", +h, 3, [
|
|
9188
9200
|
l(e),
|
|
9189
9201
|
// Creation time
|
|
9190
9202
|
l(e),
|
|
@@ -9221,7 +9233,7 @@ var ni = (a, e, s) => {
|
|
|
9221
9233
|
s ? s.presentationTimestamp + s.duration : 0,
|
|
9222
9234
|
a.timescale
|
|
9223
9235
|
), h = !We(e) || !We(r), l = h ? Ie : M;
|
|
9224
|
-
return
|
|
9236
|
+
return Y("mdhd", +h, 0, [
|
|
9225
9237
|
l(e),
|
|
9226
9238
|
// Creation time
|
|
9227
9239
|
l(e),
|
|
@@ -9235,7 +9247,7 @@ var ni = (a, e, s) => {
|
|
|
9235
9247
|
G(0)
|
|
9236
9248
|
// Quality
|
|
9237
9249
|
]);
|
|
9238
|
-
}, In = (a) =>
|
|
9250
|
+
}, In = (a) => Y("hdlr", 0, 0, [
|
|
9239
9251
|
ce("mhlr"),
|
|
9240
9252
|
// Component type
|
|
9241
9253
|
ce(a),
|
|
@@ -9251,8 +9263,8 @@ var ni = (a, e, s) => {
|
|
|
9251
9263
|
]), An = (a) => Q("minf", null, [
|
|
9252
9264
|
a.info.type === "video" ? Bn() : Pn(),
|
|
9253
9265
|
Mn(),
|
|
9254
|
-
|
|
9255
|
-
]), Bn = () =>
|
|
9266
|
+
Dn(a)
|
|
9267
|
+
]), Bn = () => Y("vmhd", 0, 1, [
|
|
9256
9268
|
G(0),
|
|
9257
9269
|
// Graphics mode
|
|
9258
9270
|
G(0),
|
|
@@ -9261,22 +9273,22 @@ var ni = (a, e, s) => {
|
|
|
9261
9273
|
// Opcolor G
|
|
9262
9274
|
G(0)
|
|
9263
9275
|
// Opcolor B
|
|
9264
|
-
]), Pn = () =>
|
|
9276
|
+
]), Pn = () => Y("smhd", 0, 0, [
|
|
9265
9277
|
G(0),
|
|
9266
9278
|
// Balance
|
|
9267
9279
|
G(0)
|
|
9268
9280
|
// Reserved
|
|
9269
9281
|
]), Mn = () => Q("dinf", null, [
|
|
9270
9282
|
Rn()
|
|
9271
|
-
]), Rn = () =>
|
|
9283
|
+
]), Rn = () => Y("dref", 0, 0, [
|
|
9272
9284
|
M(1)
|
|
9273
9285
|
// Entry count
|
|
9274
9286
|
], [
|
|
9275
9287
|
Fn()
|
|
9276
|
-
]), Fn = () =>
|
|
9288
|
+
]), Fn = () => Y("url ", 0, 1), Dn = (a) => {
|
|
9277
9289
|
const e = a.compositionTimeOffsetTable.length > 1 || a.compositionTimeOffsetTable.some((s) => s.sampleCompositionTimeOffset !== 0);
|
|
9278
9290
|
return Q("stbl", null, [
|
|
9279
|
-
|
|
9291
|
+
Ln(a),
|
|
9280
9292
|
Qn(a),
|
|
9281
9293
|
Xn(a),
|
|
9282
9294
|
Zn(a),
|
|
@@ -9284,7 +9296,7 @@ var ni = (a, e, s) => {
|
|
|
9284
9296
|
eo(a),
|
|
9285
9297
|
e ? to(a) : null
|
|
9286
9298
|
]);
|
|
9287
|
-
},
|
|
9299
|
+
}, Ln = (a) => Y("stsd", 0, 0, [
|
|
9288
9300
|
M(1)
|
|
9289
9301
|
// Entry count
|
|
9290
9302
|
], [
|
|
@@ -9374,7 +9386,7 @@ var ni = (a, e, s) => {
|
|
|
9374
9386
|
if (!e.colorSpace)
|
|
9375
9387
|
throw new Error("'colorSpace' is required in the decoder config for VP9.");
|
|
9376
9388
|
let s = e.codec.split("."), r = Number(s[1]), h = Number(s[2]), o = (Number(s[3]) << 4) + (0 << 1) + Number(e.colorSpace.fullRange);
|
|
9377
|
-
return
|
|
9389
|
+
return Y("vpcC", 1, 0, [
|
|
9378
9390
|
Z(r),
|
|
9379
9391
|
// Profile
|
|
9380
9392
|
Z(h),
|
|
@@ -9423,7 +9435,7 @@ var ni = (a, e, s) => {
|
|
|
9423
9435
|
go[e.info.codec](e)
|
|
9424
9436
|
]), qn = (a) => {
|
|
9425
9437
|
let e = new Uint8Array(a.info.decoderConfig.description);
|
|
9426
|
-
return
|
|
9438
|
+
return Y("esds", 0, 0, [
|
|
9427
9439
|
// https://stackoverflow.com/a/54803118
|
|
9428
9440
|
M(58753152),
|
|
9429
9441
|
// TAG(3) = Object Descriptor ([2])
|
|
@@ -9481,7 +9493,7 @@ var ni = (a, e, s) => {
|
|
|
9481
9493
|
Z(0)
|
|
9482
9494
|
// ChannelMappingFamily
|
|
9483
9495
|
]);
|
|
9484
|
-
}, Qn = (a) =>
|
|
9496
|
+
}, Qn = (a) => Y("stts", 0, 0, [
|
|
9485
9497
|
M(a.timeToSampleTable.length),
|
|
9486
9498
|
// Number of entries
|
|
9487
9499
|
a.timeToSampleTable.map((e) => [
|
|
@@ -9495,13 +9507,13 @@ var ni = (a, e, s) => {
|
|
|
9495
9507
|
if (a.samples.every((s) => s.type === "key"))
|
|
9496
9508
|
return null;
|
|
9497
9509
|
let e = [...a.samples.entries()].filter(([, s]) => s.type === "key");
|
|
9498
|
-
return
|
|
9510
|
+
return Y("stss", 0, 0, [
|
|
9499
9511
|
M(e.length),
|
|
9500
9512
|
// Number of entries
|
|
9501
9513
|
e.map(([s]) => M(s + 1))
|
|
9502
9514
|
// Sync sample table
|
|
9503
9515
|
]);
|
|
9504
|
-
}, Zn = (a) =>
|
|
9516
|
+
}, Zn = (a) => Y("stsc", 0, 0, [
|
|
9505
9517
|
M(a.compactlyCodedChunkTable.length),
|
|
9506
9518
|
// Number of entries
|
|
9507
9519
|
a.compactlyCodedChunkTable.map((e) => [
|
|
@@ -9513,24 +9525,24 @@ var ni = (a, e, s) => {
|
|
|
9513
9525
|
M(1)
|
|
9514
9526
|
// Sample description index
|
|
9515
9527
|
])
|
|
9516
|
-
]), Jn = (a) =>
|
|
9528
|
+
]), Jn = (a) => Y("stsz", 0, 0, [
|
|
9517
9529
|
M(0),
|
|
9518
9530
|
// Sample size (0 means non-constant size)
|
|
9519
9531
|
M(a.samples.length),
|
|
9520
9532
|
// Number of entries
|
|
9521
9533
|
a.samples.map((e) => M(e.size))
|
|
9522
9534
|
// Sample size table
|
|
9523
|
-
]), eo = (a) => a.finalizedChunks.length > 0 && gt(a.finalizedChunks).offset >= 2 ** 32 ?
|
|
9535
|
+
]), eo = (a) => a.finalizedChunks.length > 0 && gt(a.finalizedChunks).offset >= 2 ** 32 ? Y("co64", 0, 0, [
|
|
9524
9536
|
M(a.finalizedChunks.length),
|
|
9525
9537
|
// Number of entries
|
|
9526
9538
|
a.finalizedChunks.map((e) => Ie(e.offset))
|
|
9527
9539
|
// Chunk offset table
|
|
9528
|
-
]) :
|
|
9540
|
+
]) : Y("stco", 0, 0, [
|
|
9529
9541
|
M(a.finalizedChunks.length),
|
|
9530
9542
|
// Number of entries
|
|
9531
9543
|
a.finalizedChunks.map((e) => M(e.offset))
|
|
9532
9544
|
// Chunk offset table
|
|
9533
|
-
]), to = (a) =>
|
|
9545
|
+
]), to = (a) => Y("ctts", 0, 0, [
|
|
9534
9546
|
M(a.compositionTimeOffsetTable.length),
|
|
9535
9547
|
// Number of entries
|
|
9536
9548
|
a.compositionTimeOffsetTable.map((e) => [
|
|
@@ -9540,7 +9552,7 @@ var ni = (a, e, s) => {
|
|
|
9540
9552
|
M(e.sampleCompositionTimeOffset)
|
|
9541
9553
|
// Sample offset
|
|
9542
9554
|
])
|
|
9543
|
-
]), io = (a) => Q("mvex", null, a.map(so)), so = (a) =>
|
|
9555
|
+
]), io = (a) => Q("mvex", null, a.map(so)), so = (a) => Y("trex", 0, 0, [
|
|
9544
9556
|
M(a.id),
|
|
9545
9557
|
// Track ID
|
|
9546
9558
|
M(1),
|
|
@@ -9554,7 +9566,7 @@ var ni = (a, e, s) => {
|
|
|
9554
9566
|
]), Ti = (a, e) => Q("moof", null, [
|
|
9555
9567
|
ro(a),
|
|
9556
9568
|
...e.map(no)
|
|
9557
|
-
]), ro = (a) =>
|
|
9569
|
+
]), ro = (a) => Y("mfhd", 0, 0, [
|
|
9558
9570
|
M(a)
|
|
9559
9571
|
// Sequence number
|
|
9560
9572
|
]), _s = (a) => {
|
|
@@ -9572,7 +9584,7 @@ var ni = (a, e, s) => {
|
|
|
9572
9584
|
size: s.size,
|
|
9573
9585
|
flags: _s(s)
|
|
9574
9586
|
};
|
|
9575
|
-
return
|
|
9587
|
+
return Y("tfhd", 0, e, [
|
|
9576
9588
|
M(a.id),
|
|
9577
9589
|
// Track ID
|
|
9578
9590
|
M(r.duration),
|
|
@@ -9582,21 +9594,21 @@ var ni = (a, e, s) => {
|
|
|
9582
9594
|
M(r.flags)
|
|
9583
9595
|
// Default sample flags
|
|
9584
9596
|
]);
|
|
9585
|
-
}, ao = (a) =>
|
|
9597
|
+
}, ao = (a) => Y("tfdt", 1, 0, [
|
|
9586
9598
|
Ie(ue(a.currentChunk.startTimestamp, a.timescale))
|
|
9587
9599
|
// Base Media Decode Time
|
|
9588
9600
|
]), co = (a) => {
|
|
9589
|
-
let e = a.currentChunk.samples.map((T) => T.timescaleUnitsToNextSample), s = a.currentChunk.samples.map((T) => T.size), r = a.currentChunk.samples.map(_s), h = a.currentChunk.samples.map((T) => ue(T.presentationTimestamp - T.decodeTimestamp, a.timescale)), l = new Set(e), u = new Set(s), o = new Set(r), p = new Set(h), m = o.size === 2 && r[0] !== r[1],
|
|
9590
|
-
return
|
|
9601
|
+
let e = a.currentChunk.samples.map((T) => T.timescaleUnitsToNextSample), s = a.currentChunk.samples.map((T) => T.size), r = a.currentChunk.samples.map(_s), h = a.currentChunk.samples.map((T) => ue(T.presentationTimestamp - T.decodeTimestamp, a.timescale)), l = new Set(e), u = new Set(s), o = new Set(r), p = new Set(h), m = o.size === 2 && r[0] !== r[1], y = l.size > 1, v = u.size > 1, k = !m && o.size > 1, x = p.size > 1 || [...p].some((T) => T !== 0), b = 0;
|
|
9602
|
+
return b |= 1, b |= 4 * +m, b |= 256 * +y, b |= 512 * +v, b |= 1024 * +k, b |= 2048 * +x, Y("trun", 1, b, [
|
|
9591
9603
|
M(a.currentChunk.samples.length),
|
|
9592
9604
|
// Sample count
|
|
9593
9605
|
M(a.currentChunk.offset - a.currentChunk.moofOffset || 0),
|
|
9594
9606
|
// Data offset
|
|
9595
9607
|
m ? M(r[0]) : [],
|
|
9596
9608
|
a.currentChunk.samples.map((T, t) => [
|
|
9597
|
-
|
|
9609
|
+
y ? M(e[t]) : [],
|
|
9598
9610
|
// Sample duration
|
|
9599
|
-
|
|
9611
|
+
v ? M(s[t]) : [],
|
|
9600
9612
|
// Sample size
|
|
9601
9613
|
k ? M(r[t]) : [],
|
|
9602
9614
|
// Sample flags
|
|
@@ -9607,7 +9619,7 @@ var ni = (a, e, s) => {
|
|
|
9607
9619
|
}, ho = (a) => Q("mfra", null, [
|
|
9608
9620
|
...a.map(lo),
|
|
9609
9621
|
uo()
|
|
9610
|
-
]), lo = (a, e) =>
|
|
9622
|
+
]), lo = (a, e) => Y("tfra", 1, 0, [
|
|
9611
9623
|
M(a.id),
|
|
9612
9624
|
// Track ID
|
|
9613
9625
|
M(63),
|
|
@@ -9626,7 +9638,7 @@ var ni = (a, e, s) => {
|
|
|
9626
9638
|
M(1)
|
|
9627
9639
|
// Sample number
|
|
9628
9640
|
])
|
|
9629
|
-
]), uo = () =>
|
|
9641
|
+
]), uo = () => Y("mfro", 0, 0, [
|
|
9630
9642
|
// This value needs to be overwritten manually from the outside, where the actual size of the enclosing mfra box
|
|
9631
9643
|
// is known
|
|
9632
9644
|
M(0)
|
|
@@ -9863,17 +9875,17 @@ var bo = class extends di {
|
|
|
9863
9875
|
chunkSize: a.options?.chunkSize
|
|
9864
9876
|
}));
|
|
9865
9877
|
}
|
|
9866
|
-
}, Wt = 1e3, So = ["avc", "hevc", "vp9", "av1"], Co = ["aac", "opus"], xo = 2082844800, ko = ["strict", "offset", "cross-track-offset"],
|
|
9878
|
+
}, Wt = 1e3, So = ["avc", "hevc", "vp9", "av1"], Co = ["aac", "opus"], xo = 2082844800, ko = ["strict", "offset", "cross-track-offset"], F, D, wt, oe, se, ee, ze, Ne, ui, xe, ke, Xe, Ht, Ss, Vt, Cs, fi, xs, Gt, ks, pi, Us, ht, $t, le, pe, mi, Ts, Ze, vt, bt, gi, He, tt, lt, jt, Uo = class {
|
|
9867
9879
|
constructor(a) {
|
|
9868
|
-
if (N(this, Ht), N(this, Vt), N(this, fi), N(this, Gt), N(this, pi), N(this, ht), N(this, le), N(this, mi), N(this, Ze), N(this, bt), N(this, He), N(this, lt), N(this,
|
|
9880
|
+
if (N(this, Ht), N(this, Vt), N(this, fi), N(this, Gt), N(this, pi), N(this, ht), N(this, le), N(this, mi), N(this, Ze), N(this, bt), N(this, He), N(this, lt), N(this, F, void 0), N(this, D, void 0), N(this, wt, void 0), N(this, oe, void 0), N(this, se, null), N(this, ee, null), N(this, ze, Math.floor(Date.now() / 1e3) + xo), N(this, Ne, []), N(this, ui, 1), N(this, xe, []), N(this, ke, []), N(this, Xe, !1), H(this, Ht, Ss).call(this, a), a.video = qe(a.video), a.audio = qe(a.audio), a.fastStart = qe(a.fastStart), this.target = a.target, te(this, F, {
|
|
9869
9881
|
firstTimestampBehavior: "strict",
|
|
9870
9882
|
...a
|
|
9871
9883
|
}), a.target instanceof zt)
|
|
9872
|
-
te(this,
|
|
9884
|
+
te(this, D, new _o(a.target));
|
|
9873
9885
|
else if (a.target instanceof ci)
|
|
9874
|
-
te(this,
|
|
9886
|
+
te(this, D, new di(a.target));
|
|
9875
9887
|
else if (a.target instanceof yo)
|
|
9876
|
-
te(this,
|
|
9888
|
+
te(this, D, new bo(a.target));
|
|
9877
9889
|
else
|
|
9878
9890
|
throw new Error(`Invalid target: ${a.target}`);
|
|
9879
9891
|
H(this, Gt, ks).call(this), H(this, Vt, Cs).call(this);
|
|
@@ -9916,12 +9928,12 @@ var bo = class extends di {
|
|
|
9916
9928
|
throw new TypeError(
|
|
9917
9929
|
"addVideoChunkRaw's sixth argument (compositionTimeOffset), when provided, must be a real number."
|
|
9918
9930
|
);
|
|
9919
|
-
if (H(this, lt, jt).call(this), !S(this,
|
|
9931
|
+
if (H(this, lt, jt).call(this), !S(this, F).video)
|
|
9920
9932
|
throw new Error("No video track declared.");
|
|
9921
|
-
if (typeof S(this,
|
|
9922
|
-
throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${S(this,
|
|
9933
|
+
if (typeof S(this, F).fastStart == "object" && S(this, se).samples.length === S(this, F).fastStart.expectedVideoChunks)
|
|
9934
|
+
throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${S(this, F).fastStart.expectedVideoChunks}).`);
|
|
9923
9935
|
let u = H(this, ht, $t).call(this, S(this, se), a, e, s, r, h, l);
|
|
9924
|
-
if (S(this,
|
|
9936
|
+
if (S(this, F).fastStart === "fragmented" && S(this, ee)) {
|
|
9925
9937
|
for (; S(this, ke).length > 0 && S(this, ke)[0].decodeTimestamp <= u.decodeTimestamp; ) {
|
|
9926
9938
|
let o = S(this, ke).shift();
|
|
9927
9939
|
H(this, le, pe).call(this, S(this, ee), o);
|
|
@@ -9953,12 +9965,12 @@ var bo = class extends di {
|
|
|
9953
9965
|
throw new TypeError("addAudioChunkRaw's fourth argument (duration) must be a non-negative real number.");
|
|
9954
9966
|
if (h && typeof h != "object")
|
|
9955
9967
|
throw new TypeError("addAudioChunkRaw's fifth argument (meta), when provided, must be an object.");
|
|
9956
|
-
if (H(this, lt, jt).call(this), !S(this,
|
|
9968
|
+
if (H(this, lt, jt).call(this), !S(this, F).audio)
|
|
9957
9969
|
throw new Error("No audio track declared.");
|
|
9958
|
-
if (typeof S(this,
|
|
9959
|
-
throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${S(this,
|
|
9970
|
+
if (typeof S(this, F).fastStart == "object" && S(this, ee).samples.length === S(this, F).fastStart.expectedAudioChunks)
|
|
9971
|
+
throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${S(this, F).fastStart.expectedAudioChunks}).`);
|
|
9960
9972
|
let l = H(this, ht, $t).call(this, S(this, ee), a, e, s, r, h);
|
|
9961
|
-
if (S(this,
|
|
9973
|
+
if (S(this, F).fastStart === "fragmented" && S(this, se)) {
|
|
9962
9974
|
for (; S(this, xe).length > 0 && S(this, xe)[0].decodeTimestamp <= l.decodeTimestamp; ) {
|
|
9963
9975
|
let u = S(this, xe).shift();
|
|
9964
9976
|
H(this, le, pe).call(this, S(this, se), u);
|
|
@@ -9971,7 +9983,7 @@ var bo = class extends di {
|
|
|
9971
9983
|
finalize() {
|
|
9972
9984
|
if (S(this, Xe))
|
|
9973
9985
|
throw new Error("Cannot finalize a muxer more than once.");
|
|
9974
|
-
if (S(this,
|
|
9986
|
+
if (S(this, F).fastStart === "fragmented") {
|
|
9975
9987
|
for (let e of S(this, xe))
|
|
9976
9988
|
H(this, le, pe).call(this, S(this, se), e);
|
|
9977
9989
|
for (let e of S(this, ke))
|
|
@@ -9980,12 +9992,12 @@ var bo = class extends di {
|
|
|
9980
9992
|
} else
|
|
9981
9993
|
S(this, se) && H(this, Ze, vt).call(this, S(this, se)), S(this, ee) && H(this, Ze, vt).call(this, S(this, ee));
|
|
9982
9994
|
let a = [S(this, se), S(this, ee)].filter(Boolean);
|
|
9983
|
-
if (S(this,
|
|
9995
|
+
if (S(this, F).fastStart === "in-memory") {
|
|
9984
9996
|
let e;
|
|
9985
9997
|
for (let r = 0; r < 2; r++) {
|
|
9986
|
-
let h = ot(a, S(this, ze)), l = S(this,
|
|
9987
|
-
e = S(this,
|
|
9988
|
-
let u = S(this,
|
|
9998
|
+
let h = ot(a, S(this, ze)), l = S(this, D).measureBox(h);
|
|
9999
|
+
e = S(this, D).measureBox(S(this, oe));
|
|
10000
|
+
let u = S(this, D).pos + l + e;
|
|
9989
10001
|
for (let o of S(this, Ne)) {
|
|
9990
10002
|
o.offset = u;
|
|
9991
10003
|
for (let { data: p } of o.samples)
|
|
@@ -9996,31 +10008,31 @@ var bo = class extends di {
|
|
|
9996
10008
|
e >= 2 ** 32 && (S(this, oe).largeSize = !0);
|
|
9997
10009
|
}
|
|
9998
10010
|
let s = ot(a, S(this, ze));
|
|
9999
|
-
S(this,
|
|
10011
|
+
S(this, D).writeBox(s), S(this, oe).size = e, S(this, D).writeBox(S(this, oe));
|
|
10000
10012
|
for (let r of S(this, Ne))
|
|
10001
10013
|
for (let h of r.samples)
|
|
10002
|
-
S(this,
|
|
10003
|
-
} else if (S(this,
|
|
10004
|
-
let e = S(this,
|
|
10005
|
-
S(this,
|
|
10006
|
-
let r = S(this,
|
|
10007
|
-
S(this,
|
|
10014
|
+
S(this, D).write(h.data), h.data = null;
|
|
10015
|
+
} else if (S(this, F).fastStart === "fragmented") {
|
|
10016
|
+
let e = S(this, D).pos, s = ho(a);
|
|
10017
|
+
S(this, D).writeBox(s);
|
|
10018
|
+
let r = S(this, D).pos - e;
|
|
10019
|
+
S(this, D).seek(S(this, D).pos - 4), S(this, D).writeU32(r);
|
|
10008
10020
|
} else {
|
|
10009
|
-
let e = S(this,
|
|
10010
|
-
S(this, oe).size = s, S(this, oe).largeSize = s >= 2 ** 32, S(this,
|
|
10021
|
+
let e = S(this, D).offsets.get(S(this, oe)), s = S(this, D).pos - e;
|
|
10022
|
+
S(this, oe).size = s, S(this, oe).largeSize = s >= 2 ** 32, S(this, D).patchBox(S(this, oe));
|
|
10011
10023
|
let r = ot(a, S(this, ze));
|
|
10012
|
-
if (typeof S(this,
|
|
10013
|
-
S(this,
|
|
10014
|
-
let h = e - S(this,
|
|
10015
|
-
S(this,
|
|
10024
|
+
if (typeof S(this, F).fastStart == "object") {
|
|
10025
|
+
S(this, D).seek(S(this, wt)), S(this, D).writeBox(r);
|
|
10026
|
+
let h = e - S(this, D).pos;
|
|
10027
|
+
S(this, D).writeBox(Cn(h));
|
|
10016
10028
|
} else
|
|
10017
|
-
S(this,
|
|
10029
|
+
S(this, D).writeBox(r);
|
|
10018
10030
|
}
|
|
10019
|
-
H(this, He, tt).call(this), S(this,
|
|
10031
|
+
H(this, He, tt).call(this), S(this, D).finalize(), te(this, Xe, !0);
|
|
10020
10032
|
}
|
|
10021
10033
|
};
|
|
10022
|
-
|
|
10023
|
-
|
|
10034
|
+
F = /* @__PURE__ */ new WeakMap();
|
|
10035
|
+
D = /* @__PURE__ */ new WeakMap();
|
|
10024
10036
|
wt = /* @__PURE__ */ new WeakMap();
|
|
10025
10037
|
oe = /* @__PURE__ */ new WeakMap();
|
|
10026
10038
|
se = /* @__PURE__ */ new WeakMap();
|
|
@@ -10088,27 +10100,27 @@ Ss = function(a) {
|
|
|
10088
10100
|
};
|
|
10089
10101
|
Vt = /* @__PURE__ */ new WeakSet();
|
|
10090
10102
|
Cs = function() {
|
|
10091
|
-
if (S(this,
|
|
10092
|
-
holdsAvc: S(this,
|
|
10093
|
-
fragmented: S(this,
|
|
10094
|
-
})), te(this, wt, S(this,
|
|
10095
|
-
te(this, oe,
|
|
10096
|
-
else if (S(this,
|
|
10097
|
-
if (typeof S(this,
|
|
10103
|
+
if (S(this, D).writeBox(Sn({
|
|
10104
|
+
holdsAvc: S(this, F).video?.codec === "avc",
|
|
10105
|
+
fragmented: S(this, F).fastStart === "fragmented"
|
|
10106
|
+
})), te(this, wt, S(this, D).pos), S(this, F).fastStart === "in-memory")
|
|
10107
|
+
te(this, oe, Lt(!1));
|
|
10108
|
+
else if (S(this, F).fastStart !== "fragmented") {
|
|
10109
|
+
if (typeof S(this, F).fastStart == "object") {
|
|
10098
10110
|
let a = H(this, fi, xs).call(this);
|
|
10099
|
-
S(this,
|
|
10111
|
+
S(this, D).seek(S(this, D).pos + a);
|
|
10100
10112
|
}
|
|
10101
|
-
te(this, oe,
|
|
10113
|
+
te(this, oe, Lt(!0)), S(this, D).writeBox(S(this, oe));
|
|
10102
10114
|
}
|
|
10103
10115
|
H(this, He, tt).call(this);
|
|
10104
10116
|
};
|
|
10105
10117
|
fi = /* @__PURE__ */ new WeakSet();
|
|
10106
10118
|
xs = function() {
|
|
10107
|
-
if (typeof S(this,
|
|
10119
|
+
if (typeof S(this, F).fastStart != "object")
|
|
10108
10120
|
return;
|
|
10109
10121
|
let a = 0, e = [
|
|
10110
|
-
S(this,
|
|
10111
|
-
S(this,
|
|
10122
|
+
S(this, F).fastStart.expectedVideoChunks,
|
|
10123
|
+
S(this, F).fastStart.expectedAudioChunks
|
|
10112
10124
|
];
|
|
10113
10125
|
for (let s of e)
|
|
10114
10126
|
s && (a += 8 * Math.ceil(2 / 3 * s), a += 4 * s, a += 12 * Math.ceil(2 / 3 * s), a += 4 * s, a += 8 * s);
|
|
@@ -10116,18 +10128,18 @@ xs = function() {
|
|
|
10116
10128
|
};
|
|
10117
10129
|
Gt = /* @__PURE__ */ new WeakSet();
|
|
10118
10130
|
ks = function() {
|
|
10119
|
-
if (S(this,
|
|
10131
|
+
if (S(this, F).video && te(this, se, {
|
|
10120
10132
|
id: 1,
|
|
10121
10133
|
info: {
|
|
10122
10134
|
type: "video",
|
|
10123
|
-
codec: S(this,
|
|
10124
|
-
width: S(this,
|
|
10125
|
-
height: S(this,
|
|
10126
|
-
rotation: S(this,
|
|
10135
|
+
codec: S(this, F).video.codec,
|
|
10136
|
+
width: S(this, F).video.width,
|
|
10137
|
+
height: S(this, F).video.height,
|
|
10138
|
+
rotation: S(this, F).video.rotation ?? 0,
|
|
10127
10139
|
decoderConfig: null
|
|
10128
10140
|
},
|
|
10129
10141
|
// The fallback contains many common frame rates as factors
|
|
10130
|
-
timescale: S(this,
|
|
10142
|
+
timescale: S(this, F).video.frameRate ?? 57600,
|
|
10131
10143
|
samples: [],
|
|
10132
10144
|
finalizedChunks: [],
|
|
10133
10145
|
currentChunk: null,
|
|
@@ -10138,16 +10150,16 @@ ks = function() {
|
|
|
10138
10150
|
lastTimescaleUnits: null,
|
|
10139
10151
|
lastSample: null,
|
|
10140
10152
|
compactlyCodedChunkTable: []
|
|
10141
|
-
}), S(this,
|
|
10142
|
-
id: S(this,
|
|
10153
|
+
}), S(this, F).audio && (te(this, ee, {
|
|
10154
|
+
id: S(this, F).video ? 2 : 1,
|
|
10143
10155
|
info: {
|
|
10144
10156
|
type: "audio",
|
|
10145
|
-
codec: S(this,
|
|
10146
|
-
numberOfChannels: S(this,
|
|
10147
|
-
sampleRate: S(this,
|
|
10157
|
+
codec: S(this, F).audio.codec,
|
|
10158
|
+
numberOfChannels: S(this, F).audio.numberOfChannels,
|
|
10159
|
+
sampleRate: S(this, F).audio.sampleRate,
|
|
10148
10160
|
decoderConfig: null
|
|
10149
10161
|
},
|
|
10150
|
-
timescale: S(this,
|
|
10162
|
+
timescale: S(this, F).audio.sampleRate,
|
|
10151
10163
|
samples: [],
|
|
10152
10164
|
finalizedChunks: [],
|
|
10153
10165
|
currentChunk: null,
|
|
@@ -10158,19 +10170,19 @@ ks = function() {
|
|
|
10158
10170
|
lastTimescaleUnits: null,
|
|
10159
10171
|
lastSample: null,
|
|
10160
10172
|
compactlyCodedChunkTable: []
|
|
10161
|
-
}), S(this,
|
|
10173
|
+
}), S(this, F).audio.codec === "aac")) {
|
|
10162
10174
|
let a = H(this, pi, Us).call(
|
|
10163
10175
|
this,
|
|
10164
10176
|
2,
|
|
10165
10177
|
// Object type for AAC-LC, since it's the most common
|
|
10166
|
-
S(this,
|
|
10167
|
-
S(this,
|
|
10178
|
+
S(this, F).audio.sampleRate,
|
|
10179
|
+
S(this, F).audio.numberOfChannels
|
|
10168
10180
|
);
|
|
10169
10181
|
S(this, ee).info.decoderConfig = {
|
|
10170
|
-
codec: S(this,
|
|
10182
|
+
codec: S(this, F).audio.codec,
|
|
10171
10183
|
description: a,
|
|
10172
|
-
numberOfChannels: S(this,
|
|
10173
|
-
sampleRate: S(this,
|
|
10184
|
+
numberOfChannels: S(this, F).audio.numberOfChannels,
|
|
10185
|
+
sampleRate: S(this, F).audio.sampleRate
|
|
10174
10186
|
};
|
|
10175
10187
|
}
|
|
10176
10188
|
};
|
|
@@ -10187,8 +10199,8 @@ Us = function(a, e, s) {
|
|
|
10187
10199
|
};
|
|
10188
10200
|
ht = /* @__PURE__ */ new WeakSet();
|
|
10189
10201
|
$t = function(a, e, s, r, h, l, u) {
|
|
10190
|
-
let o = r / 1e6, p = (r - (u ?? 0)) / 1e6, m = h / 1e6,
|
|
10191
|
-
return o =
|
|
10202
|
+
let o = r / 1e6, p = (r - (u ?? 0)) / 1e6, m = h / 1e6, y = H(this, mi, Ts).call(this, o, p, a);
|
|
10203
|
+
return o = y.presentationTimestamp, p = y.decodeTimestamp, l?.decoderConfig && (a.info.decoderConfig === null ? a.info.decoderConfig = l.decoderConfig : Object.assign(a.info.decoderConfig, l.decoderConfig)), {
|
|
10192
10204
|
presentationTimestamp: o,
|
|
10193
10205
|
decodeTimestamp: p,
|
|
10194
10206
|
duration: m,
|
|
@@ -10201,11 +10213,11 @@ $t = function(a, e, s, r, h, l, u) {
|
|
|
10201
10213
|
};
|
|
10202
10214
|
le = /* @__PURE__ */ new WeakSet();
|
|
10203
10215
|
pe = function(a, e) {
|
|
10204
|
-
S(this,
|
|
10216
|
+
S(this, F).fastStart !== "fragmented" && a.samples.push(e);
|
|
10205
10217
|
const s = ue(e.presentationTimestamp - e.decodeTimestamp, a.timescale);
|
|
10206
10218
|
if (a.lastTimescaleUnits !== null) {
|
|
10207
10219
|
let h = ue(e.decodeTimestamp, a.timescale, !1), l = Math.round(h - a.lastTimescaleUnits);
|
|
10208
|
-
if (a.lastTimescaleUnits += l, a.lastSample.timescaleUnitsToNextSample = l, S(this,
|
|
10220
|
+
if (a.lastTimescaleUnits += l, a.lastSample.timescaleUnitsToNextSample = l, S(this, F).fastStart !== "fragmented") {
|
|
10209
10221
|
let u = gt(a.timeToSampleTable);
|
|
10210
10222
|
u.sampleCount === 1 ? (u.sampleDelta = l, u.sampleCount++) : u.sampleDelta === l ? u.sampleCount++ : (u.sampleCount--, a.timeToSampleTable.push({
|
|
10211
10223
|
sampleCount: 2,
|
|
@@ -10218,7 +10230,7 @@ pe = function(a, e) {
|
|
|
10218
10230
|
});
|
|
10219
10231
|
}
|
|
10220
10232
|
} else
|
|
10221
|
-
a.lastTimescaleUnits = 0, S(this,
|
|
10233
|
+
a.lastTimescaleUnits = 0, S(this, F).fastStart !== "fragmented" && (a.timeToSampleTable.push({
|
|
10222
10234
|
sampleCount: 1,
|
|
10223
10235
|
sampleDelta: ue(e.duration, a.timescale)
|
|
10224
10236
|
}), a.compositionTimeOffsetTable.push({
|
|
@@ -10231,9 +10243,9 @@ pe = function(a, e) {
|
|
|
10231
10243
|
r = !0;
|
|
10232
10244
|
else {
|
|
10233
10245
|
let h = e.presentationTimestamp - a.currentChunk.startTimestamp;
|
|
10234
|
-
if (S(this,
|
|
10246
|
+
if (S(this, F).fastStart === "fragmented") {
|
|
10235
10247
|
let l = S(this, se) ?? S(this, ee);
|
|
10236
|
-
const u = S(this,
|
|
10248
|
+
const u = S(this, F).minFragmentDuration ?? 1;
|
|
10237
10249
|
a === l && e.type === "key" && h >= u && (r = !0, H(this, bt, gi).call(this));
|
|
10238
10250
|
} else
|
|
10239
10251
|
r = h >= 0.5;
|
|
@@ -10245,7 +10257,7 @@ pe = function(a, e) {
|
|
|
10245
10257
|
};
|
|
10246
10258
|
mi = /* @__PURE__ */ new WeakSet();
|
|
10247
10259
|
Ts = function(a, e, s) {
|
|
10248
|
-
const r = S(this,
|
|
10260
|
+
const r = S(this, F).firstTimestampBehavior === "strict", h = s.lastDecodeTimestamp === -1;
|
|
10249
10261
|
if (r && h && e !== 0)
|
|
10250
10262
|
throw new Error(
|
|
10251
10263
|
`The first chunk for your media track must have a timestamp of 0 (received DTS=${e}).Non-zero first timestamps are often caused by directly piping frames or audio data from a MediaStreamTrack into the encoder. Their timestamps are typically relative to the age of thedocument, which is probably what you want.
|
|
@@ -10253,10 +10265,10 @@ Ts = function(a, e, s) {
|
|
|
10253
10265
|
If you want to offset all timestamps of a track such that the first one is zero, set firstTimestampBehavior: 'offset' in the options.
|
|
10254
10266
|
`
|
|
10255
10267
|
);
|
|
10256
|
-
if (S(this,
|
|
10268
|
+
if (S(this, F).firstTimestampBehavior === "offset" || S(this, F).firstTimestampBehavior === "cross-track-offset") {
|
|
10257
10269
|
s.firstDecodeTimestamp === void 0 && (s.firstDecodeTimestamp = e);
|
|
10258
10270
|
let u;
|
|
10259
|
-
S(this,
|
|
10271
|
+
S(this, F).firstTimestampBehavior === "offset" ? u = s.firstDecodeTimestamp : u = Math.min(
|
|
10260
10272
|
S(this, se)?.firstDecodeTimestamp ?? 1 / 0,
|
|
10261
10273
|
S(this, ee)?.firstDecodeTimestamp ?? 1 / 0
|
|
10262
10274
|
), e -= u, a -= u;
|
|
@@ -10269,26 +10281,26 @@ If you want to offset all timestamps of a track such that the first one is zero,
|
|
|
10269
10281
|
};
|
|
10270
10282
|
Ze = /* @__PURE__ */ new WeakSet();
|
|
10271
10283
|
vt = function(a) {
|
|
10272
|
-
if (S(this,
|
|
10284
|
+
if (S(this, F).fastStart === "fragmented")
|
|
10273
10285
|
throw new Error("Can't finalize individual chunks if 'fastStart' is set to 'fragmented'.");
|
|
10274
10286
|
if (a.currentChunk) {
|
|
10275
10287
|
if (a.finalizedChunks.push(a.currentChunk), S(this, Ne).push(a.currentChunk), (a.compactlyCodedChunkTable.length === 0 || gt(a.compactlyCodedChunkTable).samplesPerChunk !== a.currentChunk.samples.length) && a.compactlyCodedChunkTable.push({
|
|
10276
10288
|
firstChunk: a.finalizedChunks.length,
|
|
10277
10289
|
// 1-indexed
|
|
10278
10290
|
samplesPerChunk: a.currentChunk.samples.length
|
|
10279
|
-
}), S(this,
|
|
10291
|
+
}), S(this, F).fastStart === "in-memory") {
|
|
10280
10292
|
a.currentChunk.offset = 0;
|
|
10281
10293
|
return;
|
|
10282
10294
|
}
|
|
10283
|
-
a.currentChunk.offset = S(this,
|
|
10295
|
+
a.currentChunk.offset = S(this, D).pos;
|
|
10284
10296
|
for (let e of a.currentChunk.samples)
|
|
10285
|
-
S(this,
|
|
10297
|
+
S(this, D).write(e.data), e.data = null;
|
|
10286
10298
|
H(this, He, tt).call(this);
|
|
10287
10299
|
}
|
|
10288
10300
|
};
|
|
10289
10301
|
bt = /* @__PURE__ */ new WeakSet();
|
|
10290
10302
|
gi = function(a = !0) {
|
|
10291
|
-
if (S(this,
|
|
10303
|
+
if (S(this, F).fastStart !== "fragmented")
|
|
10292
10304
|
throw new Error("Can't finalize a fragment unless 'fastStart' is set to 'fragmented'.");
|
|
10293
10305
|
let e = [S(this, se), S(this, ee)].filter((o) => o && o.currentChunk);
|
|
10294
10306
|
if (e.length === 0)
|
|
@@ -10296,34 +10308,34 @@ gi = function(a = !0) {
|
|
|
10296
10308
|
let s = wn(this, ui)._++;
|
|
10297
10309
|
if (s === 1) {
|
|
10298
10310
|
let o = ot(e, S(this, ze), !0);
|
|
10299
|
-
S(this,
|
|
10311
|
+
S(this, D).writeBox(o);
|
|
10300
10312
|
}
|
|
10301
|
-
let r = S(this,
|
|
10302
|
-
S(this,
|
|
10313
|
+
let r = S(this, D).pos, h = Ti(s, e);
|
|
10314
|
+
S(this, D).writeBox(h);
|
|
10303
10315
|
{
|
|
10304
|
-
let o =
|
|
10305
|
-
for (let
|
|
10306
|
-
for (let
|
|
10307
|
-
p +=
|
|
10308
|
-
let m = S(this,
|
|
10309
|
-
m >= 2 ** 32 && (o.largeSize = !0, m = S(this,
|
|
10316
|
+
let o = Lt(!1), p = 0;
|
|
10317
|
+
for (let y of e)
|
|
10318
|
+
for (let v of y.currentChunk.samples)
|
|
10319
|
+
p += v.size;
|
|
10320
|
+
let m = S(this, D).measureBox(o) + p;
|
|
10321
|
+
m >= 2 ** 32 && (o.largeSize = !0, m = S(this, D).measureBox(o) + p), o.size = m, S(this, D).writeBox(o);
|
|
10310
10322
|
}
|
|
10311
10323
|
for (let o of e) {
|
|
10312
|
-
o.currentChunk.offset = S(this,
|
|
10324
|
+
o.currentChunk.offset = S(this, D).pos, o.currentChunk.moofOffset = r;
|
|
10313
10325
|
for (let p of o.currentChunk.samples)
|
|
10314
|
-
S(this,
|
|
10326
|
+
S(this, D).write(p.data), p.data = null;
|
|
10315
10327
|
}
|
|
10316
|
-
let l = S(this,
|
|
10317
|
-
S(this,
|
|
10328
|
+
let l = S(this, D).pos;
|
|
10329
|
+
S(this, D).seek(S(this, D).offsets.get(h));
|
|
10318
10330
|
let u = Ti(s, e);
|
|
10319
|
-
S(this,
|
|
10331
|
+
S(this, D).writeBox(u), S(this, D).seek(l);
|
|
10320
10332
|
for (let o of e)
|
|
10321
10333
|
o.finalizedChunks.push(o.currentChunk), S(this, Ne).push(o.currentChunk), o.currentChunk = null;
|
|
10322
10334
|
a && H(this, He, tt).call(this);
|
|
10323
10335
|
};
|
|
10324
10336
|
He = /* @__PURE__ */ new WeakSet();
|
|
10325
10337
|
tt = function() {
|
|
10326
|
-
S(this,
|
|
10338
|
+
S(this, D) instanceof di && S(this, D).flush();
|
|
10327
10339
|
};
|
|
10328
10340
|
lt = /* @__PURE__ */ new WeakSet();
|
|
10329
10341
|
jt = function() {
|
|
@@ -10336,6 +10348,7 @@ class To {
|
|
|
10336
10348
|
firstAudioChunk = !0;
|
|
10337
10349
|
videoChunkMeta = null;
|
|
10338
10350
|
audioChunkMeta = null;
|
|
10351
|
+
lastAudioDurationUs = null;
|
|
10339
10352
|
constructor(e, s = { kind: "blob" }) {
|
|
10340
10353
|
this.videoChunkMeta = e.videoChunkMeta, this.audioChunkMeta = e.audioChunkMeta;
|
|
10341
10354
|
const h = {
|
|
@@ -10367,10 +10380,21 @@ class To {
|
|
|
10367
10380
|
}
|
|
10368
10381
|
audioChunkCount = 0;
|
|
10369
10382
|
writeAudioChunk(e, s) {
|
|
10370
|
-
if (e.byteLength <= 16)
|
|
10383
|
+
if (e.byteLength <= 16 && (!e.duration || e.duration <= 0))
|
|
10371
10384
|
return;
|
|
10372
10385
|
let r;
|
|
10373
|
-
this.firstAudioChunk && (s && s.decoderConfig && (this.audioChunkMeta = s.decoderConfig), this.audioChunkMeta && (r = { decoderConfig: this.audioChunkMeta }), this.firstAudioChunk = !1),
|
|
10386
|
+
if (this.firstAudioChunk && (s && s.decoderConfig && (this.audioChunkMeta = s.decoderConfig), this.audioChunkMeta && (r = { decoderConfig: this.audioChunkMeta }), this.firstAudioChunk = !1), !!e.duration && e.duration > 0)
|
|
10387
|
+
this.lastAudioDurationUs = e.duration;
|
|
10388
|
+
else {
|
|
10389
|
+
const l = s?.decoderConfig?.sampleRate ?? this.audioChunkMeta?.sampleRate ?? 48e3, u = this.lastAudioDurationUs ?? Math.max(1, Math.round(1024 / l * 1e6)), o = new ArrayBuffer(e.byteLength);
|
|
10390
|
+
e.copyTo(o), e = new EncodedAudioChunk({
|
|
10391
|
+
type: e.type,
|
|
10392
|
+
timestamp: e.timestamp,
|
|
10393
|
+
duration: u,
|
|
10394
|
+
data: o
|
|
10395
|
+
}), this.lastAudioDurationUs = u;
|
|
10396
|
+
}
|
|
10397
|
+
this.audioChunkCount++, this.muxer.addAudioChunk(e, r);
|
|
10374
10398
|
}
|
|
10375
10399
|
finalize() {
|
|
10376
10400
|
if (this.muxer.finalize(), this.muxer.target instanceof zt) {
|
|
@@ -10454,9 +10478,9 @@ function Ei() {
|
|
|
10454
10478
|
async function Ii(a, e, s = {}) {
|
|
10455
10479
|
const { timeoutMs: r = 2e3, pollIntervalMs: h = 10 } = s, l = performance.now(), u = [];
|
|
10456
10480
|
return new Promise((o, p) => {
|
|
10457
|
-
let m = !1,
|
|
10481
|
+
let m = !1, y = null, v = null;
|
|
10458
10482
|
const k = () => {
|
|
10459
|
-
|
|
10483
|
+
y !== null && (clearInterval(y), y = null), v !== null && (clearTimeout(v), v = null);
|
|
10460
10484
|
}, x = (T, t) => {
|
|
10461
10485
|
if (m) return;
|
|
10462
10486
|
m = !0, k();
|
|
@@ -10466,7 +10490,7 @@ async function Ii(a, e, s = {}) {
|
|
|
10466
10490
|
durationMs: performance.now() - l
|
|
10467
10491
|
};
|
|
10468
10492
|
T && u.length > 0 ? o({ frames: u, stats: n }) : p(new Error(t || "Decode failed"));
|
|
10469
|
-
},
|
|
10493
|
+
}, b = new VideoDecoder({
|
|
10470
10494
|
output: (T) => {
|
|
10471
10495
|
u.push(T);
|
|
10472
10496
|
},
|
|
@@ -10474,7 +10498,7 @@ async function Ii(a, e, s = {}) {
|
|
|
10474
10498
|
x(!1, T.message);
|
|
10475
10499
|
}
|
|
10476
10500
|
});
|
|
10477
|
-
|
|
10501
|
+
b.configure({
|
|
10478
10502
|
codec: e.codec,
|
|
10479
10503
|
codedWidth: e.width,
|
|
10480
10504
|
codedHeight: e.height,
|
|
@@ -10483,12 +10507,12 @@ async function Ii(a, e, s = {}) {
|
|
|
10483
10507
|
...e.description && { description: e.description }
|
|
10484
10508
|
});
|
|
10485
10509
|
for (const T of a)
|
|
10486
|
-
|
|
10487
|
-
|
|
10488
|
-
}),
|
|
10489
|
-
|
|
10490
|
-
}, h),
|
|
10491
|
-
|
|
10510
|
+
b.decode(T);
|
|
10511
|
+
b.flush().catch(() => {
|
|
10512
|
+
}), y = setInterval(() => {
|
|
10513
|
+
b.decodeQueueSize === 0 && u.length > 0 && (b.close(), x(!0));
|
|
10514
|
+
}, h), v = setTimeout(() => {
|
|
10515
|
+
b.close(), x(u.length > 0, `Decode timeout after ${r}ms`);
|
|
10492
10516
|
}, r);
|
|
10493
10517
|
});
|
|
10494
10518
|
}
|
|
@@ -10509,13 +10533,13 @@ class Te {
|
|
|
10509
10533
|
width: o.width,
|
|
10510
10534
|
height: o.height,
|
|
10511
10535
|
description: o.description
|
|
10512
|
-
}),
|
|
10513
|
-
for (const
|
|
10514
|
-
const k = h.startUs +
|
|
10536
|
+
}), y = Math.round(1e6 / u);
|
|
10537
|
+
for (const v of m.frames) {
|
|
10538
|
+
const k = h.startUs + v.timestamp;
|
|
10515
10539
|
l.addFrame(
|
|
10516
|
-
|
|
10540
|
+
v,
|
|
10517
10541
|
h.id,
|
|
10518
|
-
|
|
10542
|
+
y,
|
|
10519
10543
|
h.trackId ?? "main",
|
|
10520
10544
|
k
|
|
10521
10545
|
);
|
|
@@ -10625,21 +10649,21 @@ class Te {
|
|
|
10625
10649
|
calculateGOPRangesForWindow(e, s, r) {
|
|
10626
10650
|
if (!e.tracks.video)
|
|
10627
10651
|
return { gops: [], byteStart: 0, byteEnd: 0 };
|
|
10628
|
-
const { gopIndex: h, samples: l } = e.tracks.video, o = this.mp4IndexCache.getNearestKeyframe(this.resourceId, s)?.timestamp ?? s, p = Oe(h, o, r, (
|
|
10652
|
+
const { gopIndex: h, samples: l } = e.tracks.video, o = this.mp4IndexCache.getNearestKeyframe(this.resourceId, s)?.timestamp ?? s, p = Oe(h, o, r, (v, k) => {
|
|
10629
10653
|
const x = h[k + 1];
|
|
10630
10654
|
return {
|
|
10631
|
-
start:
|
|
10655
|
+
start: v.startTimeUs,
|
|
10632
10656
|
end: x ? x.startTimeUs : 1 / 0
|
|
10633
10657
|
};
|
|
10634
10658
|
});
|
|
10635
10659
|
if (p.length === 0)
|
|
10636
10660
|
return { gops: [], byteStart: 0, byteEnd: 0 };
|
|
10637
|
-
let m = 1 / 0,
|
|
10638
|
-
for (const
|
|
10639
|
-
const k = l[
|
|
10640
|
-
k &&
|
|
10661
|
+
let m = 1 / 0, y = 0;
|
|
10662
|
+
for (const v of p) {
|
|
10663
|
+
const k = l[v.keyframeSampleIndex], x = v.keyframeSampleIndex + v.sampleCount - 1, b = l[x];
|
|
10664
|
+
k && b && (m = Math.min(m, k.byteOffset), y = Math.max(y, b.byteOffset + b.byteLength));
|
|
10641
10665
|
}
|
|
10642
|
-
return { gops: p, byteStart: m, byteEnd:
|
|
10666
|
+
return { gops: p, byteStart: m, byteEnd: y };
|
|
10643
10667
|
}
|
|
10644
10668
|
/**
|
|
10645
10669
|
* Extract video chunks from GOP data
|
|
@@ -10654,22 +10678,22 @@ class Te {
|
|
|
10654
10678
|
throw new Error("No video track in index");
|
|
10655
10679
|
const { samples: l } = h, u = [], o = new Uint8Array(e), p = r.byteStart;
|
|
10656
10680
|
for (const m of r.gops) {
|
|
10657
|
-
const
|
|
10658
|
-
for (let k =
|
|
10681
|
+
const y = m.keyframeSampleIndex, v = y + m.sampleCount;
|
|
10682
|
+
for (let k = y; k < v; k++) {
|
|
10659
10683
|
const x = l[k];
|
|
10660
10684
|
if (!x) continue;
|
|
10661
|
-
const
|
|
10662
|
-
if (
|
|
10685
|
+
const b = x.byteOffset - p;
|
|
10686
|
+
if (b < 0 || b + x.byteLength > e.byteLength) {
|
|
10663
10687
|
console.warn("[OnDemandVideoSession] Sample outside buffer:", {
|
|
10664
10688
|
sampleOffset: x.byteOffset,
|
|
10665
10689
|
sampleLength: x.byteLength,
|
|
10666
10690
|
baseOffset: p,
|
|
10667
|
-
relativeOffset:
|
|
10691
|
+
relativeOffset: b,
|
|
10668
10692
|
bufferLength: e.byteLength
|
|
10669
10693
|
});
|
|
10670
10694
|
continue;
|
|
10671
10695
|
}
|
|
10672
|
-
const T = o.slice(
|
|
10696
|
+
const T = o.slice(b, b + x.byteLength), t = new EncodedVideoChunk({
|
|
10673
10697
|
type: x.isKeyframe ? "key" : "delta",
|
|
10674
10698
|
timestamp: x.timestamp,
|
|
10675
10699
|
duration: x.duration,
|
|
@@ -10774,27 +10798,27 @@ class Te {
|
|
|
10774
10798
|
p,
|
|
10775
10799
|
Math.min(p + o, l.gops.length)
|
|
10776
10800
|
);
|
|
10777
|
-
let
|
|
10778
|
-
for (const
|
|
10779
|
-
const T = h.samples[
|
|
10780
|
-
T && n && (
|
|
10801
|
+
let y = 1 / 0, v = 0;
|
|
10802
|
+
for (const b of m) {
|
|
10803
|
+
const T = h.samples[b.keyframeSampleIndex], t = b.keyframeSampleIndex + b.sampleCount - 1, n = h.samples[t];
|
|
10804
|
+
T && n && (y = Math.min(y, T.byteOffset), v = Math.max(v, n.byteOffset + n.byteLength));
|
|
10781
10805
|
}
|
|
10782
|
-
const k = await this.readResourceRangeWithRecovery(
|
|
10806
|
+
const k = await this.readResourceRangeWithRecovery(y, v);
|
|
10783
10807
|
if (this.aborted) {
|
|
10784
10808
|
u.close();
|
|
10785
10809
|
return;
|
|
10786
10810
|
}
|
|
10787
10811
|
const x = await this.demuxGOPData(k, r, {
|
|
10788
10812
|
gops: m,
|
|
10789
|
-
byteStart:
|
|
10790
|
-
byteEnd:
|
|
10813
|
+
byteStart: y,
|
|
10814
|
+
byteEnd: v
|
|
10791
10815
|
});
|
|
10792
10816
|
if (await this.decodeChunks(x, r), this.aborted) {
|
|
10793
10817
|
this.releaseDecodedFrames(), u.close();
|
|
10794
10818
|
return;
|
|
10795
10819
|
}
|
|
10796
|
-
for (const
|
|
10797
|
-
u.enqueue(
|
|
10820
|
+
for (const b of this.decodedFrames)
|
|
10821
|
+
u.enqueue(b);
|
|
10798
10822
|
this.decodedFrames = [];
|
|
10799
10823
|
}
|
|
10800
10824
|
u.close();
|
|
@@ -10811,7 +10835,7 @@ class Te {
|
|
|
10811
10835
|
try {
|
|
10812
10836
|
return await this.cacheManager.readResourceRange(this.resourceId, e, s);
|
|
10813
10837
|
} catch (r) {
|
|
10814
|
-
if (!(r instanceof
|
|
10838
|
+
if (!(r instanceof Le)) throw r;
|
|
10815
10839
|
return await this.cacheManager.resourceCache.deleteResource(this.resourceId), this.cacheManager.mp4IndexCache.delete(this.resourceId), await this.resourceLoader.load(this.resourceId, { isPreload: !1, clipId: this.clipId }), await this.cacheManager.readResourceRange(this.resourceId, e, s);
|
|
10816
10840
|
}
|
|
10817
10841
|
}
|
|
@@ -11103,8 +11127,8 @@ class Po {
|
|
|
11103
11127
|
const { muxManager: r, audioSession: h, eventBus: l, resourceLoader: u } = this.deps, o = s.signal, p = s.controller, m = s.exportMode ?? "blob";
|
|
11104
11128
|
if (m === "stream" && typeof s.onMuxData != "function")
|
|
11105
11129
|
throw new Error("onMuxData callback is required when exportMode is stream");
|
|
11106
|
-
let
|
|
11107
|
-
const
|
|
11130
|
+
let y = 0;
|
|
11131
|
+
const v = async () => {
|
|
11108
11132
|
if (o?.aborted)
|
|
11109
11133
|
throw new DOMException("Export aborted", "AbortError");
|
|
11110
11134
|
if (p?.isPaused())
|
|
@@ -11112,23 +11136,23 @@ class Po {
|
|
|
11112
11136
|
if (o?.aborted) throw new DOMException("Export aborted", "AbortError");
|
|
11113
11137
|
await new Promise((T) => setTimeout(T, 100));
|
|
11114
11138
|
}
|
|
11115
|
-
}, k = s.width || e.renderConfig?.width || 720, x = s.height || e.renderConfig?.height || 1280,
|
|
11116
|
-
l.emit(
|
|
11139
|
+
}, k = s.width || e.renderConfig?.width || 720, x = s.height || e.renderConfig?.height || 1280, b = s.fps || e.fps || 30;
|
|
11140
|
+
l.emit(O.ExportStart, {
|
|
11117
11141
|
format: s.format || "mp4",
|
|
11118
11142
|
width: k,
|
|
11119
11143
|
height: x,
|
|
11120
|
-
fps:
|
|
11144
|
+
fps: b,
|
|
11121
11145
|
durationUs: e.durationUs
|
|
11122
11146
|
}), this.deps.cacheManager.beginExport();
|
|
11123
11147
|
try {
|
|
11124
|
-
await this.preloadResources(e, u, l,
|
|
11148
|
+
await this.preloadResources(e, u, l, v), r.start({
|
|
11125
11149
|
width: k,
|
|
11126
11150
|
height: x,
|
|
11127
|
-
fps:
|
|
11151
|
+
fps: b,
|
|
11128
11152
|
output: m === "stream" ? {
|
|
11129
11153
|
kind: "stream",
|
|
11130
11154
|
onData: (n, c) => {
|
|
11131
|
-
|
|
11155
|
+
y = Math.max(y, c + n.byteLength), s.onMuxData?.(n, c);
|
|
11132
11156
|
},
|
|
11133
11157
|
chunkSize: s.muxChunkSizeBytes,
|
|
11134
11158
|
chunked: s.muxChunked
|
|
@@ -11136,23 +11160,23 @@ class Po {
|
|
|
11136
11160
|
});
|
|
11137
11161
|
const T = e.tracks.find((n) => n.id === e.mainTrackId);
|
|
11138
11162
|
if (T && T.clips.length > 0) {
|
|
11139
|
-
const c = this.deps.cacheManager.audioSampleCache.getTotalBytes() > 0 ? this.processAudioInWindows(e.durationUs, h, r,
|
|
11140
|
-
await this.processVideoClipsSequentially(T.clips, r, e,
|
|
11163
|
+
const c = this.deps.cacheManager.audioSampleCache.getTotalBytes() > 0 ? this.processAudioInWindows(e.durationUs, h, r, v) : Promise.resolve();
|
|
11164
|
+
await this.processVideoClipsSequentially(T.clips, r, e, v), await c;
|
|
11141
11165
|
} else
|
|
11142
11166
|
console.warn("[ExportScheduler] No video clips found");
|
|
11143
11167
|
if (await h.finalizeExportAudio(), o?.aborted)
|
|
11144
11168
|
throw new DOMException("Export aborted", "AbortError");
|
|
11145
11169
|
const t = await r.finalize();
|
|
11146
|
-
return l.emit(
|
|
11147
|
-
size: t?.size ??
|
|
11170
|
+
return l.emit(O.ExportComplete, {
|
|
11171
|
+
size: t?.size ?? y,
|
|
11148
11172
|
durationMs: e.durationUs / 1e3,
|
|
11149
11173
|
format: s.format || "mp4"
|
|
11150
|
-
}), l.emit(
|
|
11174
|
+
}), l.emit(O.ExportProgress, {
|
|
11151
11175
|
progress: 1,
|
|
11152
11176
|
stage: "muxing"
|
|
11153
11177
|
}), t;
|
|
11154
11178
|
} catch (T) {
|
|
11155
|
-
throw l.emit(
|
|
11179
|
+
throw l.emit(O.ExportError, {
|
|
11156
11180
|
error: T instanceof Error ? T : new Error(String(T)),
|
|
11157
11181
|
stage: "export"
|
|
11158
11182
|
}), T;
|
|
@@ -11164,29 +11188,29 @@ class Po {
|
|
|
11164
11188
|
* Preload all resources (0-40% progress)
|
|
11165
11189
|
*/
|
|
11166
11190
|
async preloadResources(e, s, r, h) {
|
|
11167
|
-
r.emit(
|
|
11191
|
+
r.emit(O.ExportProgress, {
|
|
11168
11192
|
progress: 0,
|
|
11169
11193
|
stage: "preparing",
|
|
11170
11194
|
message: "Loading and parsing resources..."
|
|
11171
11195
|
});
|
|
11172
|
-
const l = e.tracks.filter((
|
|
11196
|
+
const l = e.tracks.filter((v) => ["video", "audio"].includes(v.kind));
|
|
11173
11197
|
if (l.length === 0) return;
|
|
11174
|
-
const u = Math.max(...l.map((
|
|
11175
|
-
for (let
|
|
11198
|
+
const u = Math.max(...l.map((v) => v.clips.length)), o = [], p = /* @__PURE__ */ new Set();
|
|
11199
|
+
for (let v = 0; v < u; v++)
|
|
11176
11200
|
for (const k of l) {
|
|
11177
|
-
const x = k.clips[
|
|
11201
|
+
const x = k.clips[v];
|
|
11178
11202
|
x && re(x) && (p.has(x.resourceId) || (p.add(x.resourceId), o.push(x.resourceId)));
|
|
11179
11203
|
}
|
|
11180
11204
|
const m = o.length;
|
|
11181
|
-
let
|
|
11205
|
+
let y = 0;
|
|
11182
11206
|
await Promise.all(
|
|
11183
|
-
o.map(async (
|
|
11184
|
-
await h(), await s.load(
|
|
11185
|
-
const k = m > 0 ?
|
|
11186
|
-
r.emit(
|
|
11207
|
+
o.map(async (v) => {
|
|
11208
|
+
await h(), await s.load(v, { isPreload: !1 }), y++;
|
|
11209
|
+
const k = m > 0 ? y / m * 0.4 : 0.4;
|
|
11210
|
+
r.emit(O.ExportProgress, {
|
|
11187
11211
|
progress: k,
|
|
11188
11212
|
stage: "preparing",
|
|
11189
|
-
message: `Loading resources... (${
|
|
11213
|
+
message: `Loading resources... (${y}/${m})`
|
|
11190
11214
|
});
|
|
11191
11215
|
})
|
|
11192
11216
|
);
|
|
@@ -11213,13 +11237,13 @@ class Po {
|
|
|
11213
11237
|
for (let o = 0; o < e.length; o++) {
|
|
11214
11238
|
const p = e[o], m = l;
|
|
11215
11239
|
await h();
|
|
11216
|
-
const
|
|
11217
|
-
let
|
|
11240
|
+
const y = `${p.id}-export`;
|
|
11241
|
+
let v, k;
|
|
11218
11242
|
const x = new Promise((T, t) => {
|
|
11219
|
-
|
|
11220
|
-
}),
|
|
11243
|
+
v = T, k = t;
|
|
11244
|
+
}), b = await yi.create({
|
|
11221
11245
|
clipId: p.id,
|
|
11222
|
-
sessionId:
|
|
11246
|
+
sessionId: y,
|
|
11223
11247
|
planner: this.deps.planner,
|
|
11224
11248
|
workerPool: this.deps.workerPool,
|
|
11225
11249
|
cacheManager: this.deps.cacheManager,
|
|
@@ -11236,24 +11260,24 @@ class Po {
|
|
|
11236
11260
|
const { done: c, value: d } = await n.read();
|
|
11237
11261
|
if (c) break;
|
|
11238
11262
|
if (d) {
|
|
11239
|
-
const f = d.chunk, g = d.metadata,
|
|
11263
|
+
const f = d.chunk, g = d.metadata, _ = f.duration ?? 33333, w = f.timestamp + m, C = new ArrayBuffer(f.byteLength);
|
|
11240
11264
|
f.copyTo(C);
|
|
11241
11265
|
const U = new EncodedVideoChunk({
|
|
11242
11266
|
type: f.type,
|
|
11243
|
-
timestamp:
|
|
11244
|
-
duration:
|
|
11267
|
+
timestamp: w,
|
|
11268
|
+
duration: _,
|
|
11245
11269
|
data: C
|
|
11246
11270
|
});
|
|
11247
|
-
s.writeVideoChunk(U, g), u =
|
|
11248
|
-
const I = 0.4 +
|
|
11249
|
-
this.deps.eventBus.emit(
|
|
11271
|
+
s.writeVideoChunk(U, g), u = w + _;
|
|
11272
|
+
const I = 0.4 + w / r.durationUs * 0.6;
|
|
11273
|
+
this.deps.eventBus.emit(O.ExportProgress, {
|
|
11250
11274
|
progress: Math.min(1, I),
|
|
11251
11275
|
stage: "encoding",
|
|
11252
|
-
timeUs:
|
|
11276
|
+
timeUs: w
|
|
11253
11277
|
});
|
|
11254
11278
|
}
|
|
11255
11279
|
}
|
|
11256
|
-
|
|
11280
|
+
v();
|
|
11257
11281
|
} catch (c) {
|
|
11258
11282
|
c instanceof DOMException && c.name === "AbortError" || console.error(`[ExportScheduler] Stream error for clip ${p.id}:`, c), k(c);
|
|
11259
11283
|
} finally {
|
|
@@ -11265,7 +11289,7 @@ class Po {
|
|
|
11265
11289
|
// before sending video stream, ensuring watermarks appear from the first frame
|
|
11266
11290
|
}
|
|
11267
11291
|
});
|
|
11268
|
-
await
|
|
11292
|
+
await b.activate(), await x, await b.dispose(), l = u;
|
|
11269
11293
|
}
|
|
11270
11294
|
}
|
|
11271
11295
|
}
|
|
@@ -11286,7 +11310,7 @@ class Mo {
|
|
|
11286
11310
|
modelToken = 0;
|
|
11287
11311
|
events;
|
|
11288
11312
|
constructor(e) {
|
|
11289
|
-
this.eventBus = e.eventBus || new
|
|
11313
|
+
this.eventBus = e.eventBus || new Di(), this.events = this.eventBus.asReadonly(), this.config = me.getInstance().getConfig();
|
|
11290
11314
|
const s = this.buildWorkerConfigs();
|
|
11291
11315
|
this.workers = new qs({
|
|
11292
11316
|
eventBus: this.eventBus,
|
|
@@ -11339,7 +11363,7 @@ class Mo {
|
|
|
11339
11363
|
}), this.setupResourceFirstFrameHandler();
|
|
11340
11364
|
}
|
|
11341
11365
|
setupResourceFirstFrameHandler() {
|
|
11342
|
-
this.eventBus.on(
|
|
11366
|
+
this.eventBus.on(O.ResourceFirstFrameReady, async (e) => {
|
|
11343
11367
|
const { resourceId: s, clipId: r, index: h, chunks: l } = e;
|
|
11344
11368
|
if (!this.compositionModel) return;
|
|
11345
11369
|
const u = this.compositionModel.findClip(r);
|
|
@@ -11410,7 +11434,7 @@ class Mo {
|
|
|
11410
11434
|
async setCompositionModel(e) {
|
|
11411
11435
|
this.cacheManager.clear(), this.cancelActiveDecoding(), this.audio.preview.stopPlayback(), this.audio.preview.invalidatePreviewMixCache(), this.modelToken++, this.compositionModel = e, this.planner.setModel(e);
|
|
11412
11436
|
const s = this.resourceLoader.setModel(e);
|
|
11413
|
-
this.audio.prepare.setModel(e), await s, this.eventBus.emit(
|
|
11437
|
+
this.audio.prepare.setModel(e), await s, this.eventBus.emit(O.ModelSet, e), this.eventBus.emit(O.CompositionUpdated, {
|
|
11414
11438
|
trackCount: e.tracks.length,
|
|
11415
11439
|
clipCount: e.tracks.reduce((r, h) => r + h.clips.length, 0),
|
|
11416
11440
|
durationUs: e.durationUs
|
|
@@ -11420,7 +11444,7 @@ class Mo {
|
|
|
11420
11444
|
if (!this.compositionModel)
|
|
11421
11445
|
throw new Error("No composition model set");
|
|
11422
11446
|
const s = Ks(this.compositionModel, e);
|
|
11423
|
-
this.planner.applyPatch(e, s), this.eventBus.emit(
|
|
11447
|
+
this.planner.applyPatch(e, s), this.eventBus.emit(O.PatchApplied, {
|
|
11424
11448
|
operations: e.operations.length,
|
|
11425
11449
|
affectedClips: Array.from(s)
|
|
11426
11450
|
});
|
|
@@ -11445,9 +11469,9 @@ class Mo {
|
|
|
11445
11469
|
const o = u.trimStartUs ?? 0;
|
|
11446
11470
|
let p = s?.relativeTimeUs ? s.relativeTimeUs + o : e - u.startUs + o;
|
|
11447
11471
|
if (p = Math.min(p, o + u.durationUs - 1), !h) {
|
|
11448
|
-
const
|
|
11449
|
-
if (
|
|
11450
|
-
return
|
|
11472
|
+
const y = this.cacheManager.getFrame(p, u.id);
|
|
11473
|
+
if (y)
|
|
11474
|
+
return y;
|
|
11451
11475
|
}
|
|
11452
11476
|
return r?.aborted ? null : await this.decodeFromResource(u, p, e, {
|
|
11453
11477
|
...s,
|
|
@@ -11464,14 +11488,14 @@ class Mo {
|
|
|
11464
11488
|
*/
|
|
11465
11489
|
async decodeFromResource(e, s, r, h) {
|
|
11466
11490
|
if (!re(e)) return null;
|
|
11467
|
-
const l = e.resourceId, u = e.trimStartUs ?? 0, o = this.modelToken, p = this.compositionModel,
|
|
11491
|
+
const l = e.resourceId, u = e.trimStartUs ?? 0, o = this.modelToken, p = this.compositionModel, y = this.compositionModel?.getResource(l)?.state === "ready", v = {
|
|
11468
11492
|
isPreload: !1,
|
|
11469
11493
|
clipId: e.id,
|
|
11470
11494
|
trackId: e.trackId
|
|
11471
11495
|
}, k = h?.mode ?? "blocking";
|
|
11472
|
-
if (k === "probe" && !
|
|
11473
|
-
return this.resourceLoader.load(l,
|
|
11474
|
-
if (await this.resourceLoader.load(l,
|
|
11496
|
+
if (k === "probe" && !y)
|
|
11497
|
+
return this.resourceLoader.load(l, v), null;
|
|
11498
|
+
if (await this.resourceLoader.load(l, v), this.modelToken !== o || this.compositionModel !== p)
|
|
11475
11499
|
return console.warn("[Orchestrator] Model switched during decodeFromResource:", {
|
|
11476
11500
|
startModelToken: o,
|
|
11477
11501
|
currentModelToken: this.modelToken,
|
|
@@ -11500,8 +11524,8 @@ class Mo {
|
|
|
11500
11524
|
s + 3e6
|
|
11501
11525
|
);
|
|
11502
11526
|
return await x.decodeWindow(T, t), this.cacheManager.getFrame(s, e.id);
|
|
11503
|
-
} catch (
|
|
11504
|
-
return x.isDisposed || console.error("[Orchestrator] Error composing from resource:",
|
|
11527
|
+
} catch (b) {
|
|
11528
|
+
return x.isDisposed || console.error("[Orchestrator] Error composing from resource:", b), null;
|
|
11505
11529
|
} finally {
|
|
11506
11530
|
this.activeOnDemandSession === x && (this.activeOnDemandSession = null), await x.dispose();
|
|
11507
11531
|
}
|
|
@@ -11594,7 +11618,7 @@ class Mo {
|
|
|
11594
11618
|
clipId: l.id,
|
|
11595
11619
|
trackId: l.trackId
|
|
11596
11620
|
});
|
|
11597
|
-
const
|
|
11621
|
+
const y = await Te.create({
|
|
11598
11622
|
clipId: l.id,
|
|
11599
11623
|
resourceId: u,
|
|
11600
11624
|
targetTimeUs: p,
|
|
@@ -11606,11 +11630,11 @@ class Mo {
|
|
|
11606
11630
|
fps: this.compositionModel.fps ?? 30
|
|
11607
11631
|
});
|
|
11608
11632
|
try {
|
|
11609
|
-
await
|
|
11610
|
-
} catch (
|
|
11611
|
-
console.warn(`[Orchestrator] Preheat clip ${e} window failed:`,
|
|
11633
|
+
await y.decodeWindow(p, m);
|
|
11634
|
+
} catch (v) {
|
|
11635
|
+
console.warn(`[Orchestrator] Preheat clip ${e} window failed:`, v);
|
|
11612
11636
|
} finally {
|
|
11613
|
-
await
|
|
11637
|
+
await y.dispose();
|
|
11614
11638
|
}
|
|
11615
11639
|
}
|
|
11616
11640
|
/**
|
|
@@ -11630,15 +11654,15 @@ class Mo {
|
|
|
11630
11654
|
const o = e - u.startUs, p = u.trimStartUs ?? 0;
|
|
11631
11655
|
let m = o + p;
|
|
11632
11656
|
u.durationUs > 0 && (m = Math.min(m, p + u.durationUs - 1));
|
|
11633
|
-
const
|
|
11634
|
-
if (!
|
|
11657
|
+
const y = this.planner.getInstructions(u.id);
|
|
11658
|
+
if (!y)
|
|
11635
11659
|
return null;
|
|
11636
|
-
const
|
|
11637
|
-
(
|
|
11660
|
+
const v = [], k = y.layers.filter((x) => x.payload.attachmentId ? x.status !== "ready" ? !1 : x.activeRanges.some(
|
|
11661
|
+
(b) => o >= b.startUs && o < b.endUs
|
|
11638
11662
|
) : !0);
|
|
11639
11663
|
for (const x of k) {
|
|
11640
11664
|
if (x.type === "video" && !x.payload.attachmentId) {
|
|
11641
|
-
|
|
11665
|
+
v.push({
|
|
11642
11666
|
id: x.layerId,
|
|
11643
11667
|
type: "video",
|
|
11644
11668
|
zIndex: x.zIndex ?? 0,
|
|
@@ -11648,10 +11672,10 @@ class Mo {
|
|
|
11648
11672
|
});
|
|
11649
11673
|
continue;
|
|
11650
11674
|
}
|
|
11651
|
-
const
|
|
11652
|
-
|
|
11675
|
+
const b = await this.materializeLayer(x, u, m, e);
|
|
11676
|
+
b && v.push(b);
|
|
11653
11677
|
}
|
|
11654
|
-
return { layers:
|
|
11678
|
+
return { layers: v };
|
|
11655
11679
|
}
|
|
11656
11680
|
/**
|
|
11657
11681
|
* Materialize a serialized layer plan into concrete Layer
|
|
@@ -11694,18 +11718,18 @@ class Mo {
|
|
|
11694
11718
|
type: "image",
|
|
11695
11719
|
source: p,
|
|
11696
11720
|
attachmentId: u.attachmentId
|
|
11697
|
-
},
|
|
11721
|
+
}, y = ut(
|
|
11698
11722
|
u.renderConfig,
|
|
11699
11723
|
`image layer ${u.attachmentId || e.layerId}`
|
|
11700
11724
|
);
|
|
11701
|
-
if (
|
|
11702
|
-
const { position:
|
|
11703
|
-
if (
|
|
11725
|
+
if (y && (m.renderConfig = y), u.animation) {
|
|
11726
|
+
const { position: v, keyframes: k, overlayClipStartUs: x } = u.animation, b = h - x;
|
|
11727
|
+
if (b < 0 || b > k[k.length - 1].time)
|
|
11704
11728
|
return null;
|
|
11705
11729
|
const T = 0;
|
|
11706
11730
|
m.transform = {
|
|
11707
|
-
x:
|
|
11708
|
-
y:
|
|
11731
|
+
x: v.x,
|
|
11732
|
+
y: v.y,
|
|
11709
11733
|
scaleX: 1,
|
|
11710
11734
|
scaleY: 1,
|
|
11711
11735
|
rotation: T,
|
|
@@ -11718,7 +11742,7 @@ class Mo {
|
|
|
11718
11742
|
return l;
|
|
11719
11743
|
}
|
|
11720
11744
|
}
|
|
11721
|
-
var
|
|
11745
|
+
var z = /* @__PURE__ */ ((a) => (a.Idle = "idle", a.Buffering = "buffering", a.Playing = "playing", a.Paused = "paused", a.Seeking = "seeking", a.Ended = "ended", a))(z || {});
|
|
11722
11746
|
const $ = {
|
|
11723
11747
|
Play: "play",
|
|
11724
11748
|
Pause: "pause",
|
|
@@ -11730,7 +11754,7 @@ const $ = {
|
|
|
11730
11754
|
BufferingResolved: "bufferingResolved",
|
|
11731
11755
|
SeekResolved: "seekResolved",
|
|
11732
11756
|
StartFailed: "startFailed"
|
|
11733
|
-
},
|
|
11757
|
+
}, A = {
|
|
11734
11758
|
Seq: "seq",
|
|
11735
11759
|
Par: "par",
|
|
11736
11760
|
Try: "try",
|
|
@@ -11780,12 +11804,12 @@ function Ai(a, e, s, r, h) {
|
|
|
11780
11804
|
return l.reduce((o, p) => o + Math.abs(p - u), 0);
|
|
11781
11805
|
}
|
|
11782
11806
|
function Es(a, e, s, r, h, l, u, o, p, m) {
|
|
11783
|
-
let
|
|
11807
|
+
let y = [], v = 1 / 0;
|
|
11784
11808
|
if (r === 1) {
|
|
11785
11809
|
const x = e.slice(s).trim();
|
|
11786
11810
|
if (ie(a, x, u, o, p) <= l) {
|
|
11787
11811
|
const T = [...h, x], t = Ai(T, a, u, o, p);
|
|
11788
|
-
t <
|
|
11812
|
+
t < v && (v = t, y = T);
|
|
11789
11813
|
} else {
|
|
11790
11814
|
const T = x.split(/\s+/);
|
|
11791
11815
|
let t = "", n = [...h];
|
|
@@ -11795,21 +11819,21 @@ function Es(a, e, s, r, h, l, u, o, p, m) {
|
|
|
11795
11819
|
}
|
|
11796
11820
|
t && n.push(t);
|
|
11797
11821
|
const c = Ai(n, a, u, o, p);
|
|
11798
|
-
c <
|
|
11822
|
+
c < v && (v = c, y = n);
|
|
11799
11823
|
}
|
|
11800
|
-
return { bestLines:
|
|
11824
|
+
return { bestLines: y, bestBalance: v };
|
|
11801
11825
|
}
|
|
11802
11826
|
let k = !1;
|
|
11803
11827
|
for (let x = 0; x < m.length; x++) {
|
|
11804
|
-
const
|
|
11805
|
-
if (
|
|
11806
|
-
const T = e.slice(s,
|
|
11828
|
+
const b = m[x];
|
|
11829
|
+
if (b <= s || b >= e.length) continue;
|
|
11830
|
+
const T = e.slice(s, b).trim();
|
|
11807
11831
|
if (ie(a, T, u, o, p) <= l) {
|
|
11808
11832
|
k = !0;
|
|
11809
11833
|
const n = Es(
|
|
11810
11834
|
a,
|
|
11811
11835
|
e,
|
|
11812
|
-
|
|
11836
|
+
b,
|
|
11813
11837
|
r - 1,
|
|
11814
11838
|
[...h, T],
|
|
11815
11839
|
l,
|
|
@@ -11818,19 +11842,19 @@ function Es(a, e, s, r, h, l, u, o, p, m) {
|
|
|
11818
11842
|
p,
|
|
11819
11843
|
m
|
|
11820
11844
|
);
|
|
11821
|
-
n.bestBalance <
|
|
11845
|
+
n.bestBalance < v && (v = n.bestBalance, y = n.bestLines);
|
|
11822
11846
|
}
|
|
11823
11847
|
}
|
|
11824
11848
|
if (!k) {
|
|
11825
|
-
const
|
|
11849
|
+
const b = e.slice(s).split(/\s+/);
|
|
11826
11850
|
let T = "", t = [...h];
|
|
11827
|
-
for (const n of
|
|
11851
|
+
for (const n of b) {
|
|
11828
11852
|
const c = T ? `${T} ${n}` : n;
|
|
11829
11853
|
ie(a, c, u, o, p) <= l ? T = c : T ? (t.push(T), T = n) : t.push(n);
|
|
11830
11854
|
}
|
|
11831
|
-
T && t.push(T),
|
|
11855
|
+
T && t.push(T), y = t;
|
|
11832
11856
|
}
|
|
11833
|
-
return { bestLines:
|
|
11857
|
+
return { bestLines: y, bestBalance: v };
|
|
11834
11858
|
}
|
|
11835
11859
|
function Is(a, e, s, r, h, l = 400) {
|
|
11836
11860
|
const u = ie(a, e, r, h, l);
|
|
@@ -11854,17 +11878,17 @@ function Pt(a, e, s, r, h, l, u = 400) {
|
|
|
11854
11878
|
const o = [];
|
|
11855
11879
|
let p = 0;
|
|
11856
11880
|
const m = ie(a, " ", r, l, u);
|
|
11857
|
-
let
|
|
11858
|
-
for (const
|
|
11859
|
-
let k = ie(a,
|
|
11860
|
-
h && (k += m), k + p <= s ? (
|
|
11881
|
+
let y = "";
|
|
11882
|
+
for (const v of e) {
|
|
11883
|
+
let k = ie(a, v, r, l, u);
|
|
11884
|
+
h && (k += m), k + p <= s ? (y += v + (h ? " " : ""), p += k) : (y && o.push(y), y = v + (h ? " " : ""), p = k);
|
|
11861
11885
|
}
|
|
11862
|
-
return
|
|
11886
|
+
return y !== "" && o.push(y), o;
|
|
11863
11887
|
}
|
|
11864
11888
|
function _i(a, e, s, r, h, l, u = 400) {
|
|
11865
11889
|
let o = s / 2;
|
|
11866
|
-
for (const
|
|
11867
|
-
const k = ie(a,
|
|
11890
|
+
for (const v of e) {
|
|
11891
|
+
const k = ie(a, v, r, l, u);
|
|
11868
11892
|
k > o && (o = k);
|
|
11869
11893
|
}
|
|
11870
11894
|
const p = Pt(
|
|
@@ -11876,12 +11900,12 @@ function _i(a, e, s, r, h, l, u = 400) {
|
|
|
11876
11900
|
l,
|
|
11877
11901
|
u
|
|
11878
11902
|
).length;
|
|
11879
|
-
let m = s,
|
|
11880
|
-
for (let
|
|
11903
|
+
let m = s, y = o;
|
|
11904
|
+
for (let v = s; v >= o; v -= 1) {
|
|
11881
11905
|
const k = Pt(
|
|
11882
11906
|
a,
|
|
11883
11907
|
e,
|
|
11884
|
-
|
|
11908
|
+
v,
|
|
11885
11909
|
r,
|
|
11886
11910
|
h,
|
|
11887
11911
|
l,
|
|
@@ -11889,15 +11913,15 @@ function _i(a, e, s, r, h, l, u = 400) {
|
|
|
11889
11913
|
);
|
|
11890
11914
|
if (k.length > p)
|
|
11891
11915
|
break;
|
|
11892
|
-
let x = 1 / 0,
|
|
11916
|
+
let x = 1 / 0, b = 0;
|
|
11893
11917
|
for (const t of k) {
|
|
11894
11918
|
const n = ie(a, t, r, l, u);
|
|
11895
|
-
n < x && (x = n), n >
|
|
11919
|
+
n < x && (x = n), n > b && (b = n);
|
|
11896
11920
|
}
|
|
11897
|
-
const T =
|
|
11898
|
-
T < m && (m = T,
|
|
11921
|
+
const T = b - x;
|
|
11922
|
+
T < m && (m = T, y = v);
|
|
11899
11923
|
}
|
|
11900
|
-
return Pt(a, e,
|
|
11924
|
+
return Pt(a, e, y, r, h, l, u);
|
|
11901
11925
|
}
|
|
11902
11926
|
function As(a, e) {
|
|
11903
11927
|
const { damping: s, mass: r, stiffness: h, overshootClamping: l = !1 } = e;
|
|
@@ -11905,13 +11929,13 @@ function As(a, e) {
|
|
|
11905
11929
|
const u = s / (2 * Math.sqrt(r * h)), o = Math.sqrt(h / r), p = a / 60;
|
|
11906
11930
|
let m;
|
|
11907
11931
|
if (u < 1) {
|
|
11908
|
-
const
|
|
11909
|
-
m = 1 - Math.exp(-u * o * p) * (
|
|
11932
|
+
const y = o * Math.sqrt(1 - u * u), v = 1, k = u * o / y;
|
|
11933
|
+
m = 1 - Math.exp(-u * o * p) * (v * Math.cos(y * p) + k * Math.sin(y * p));
|
|
11910
11934
|
} else if (u === 1)
|
|
11911
11935
|
m = 1 - Math.exp(-o * p) * (1 + o * p);
|
|
11912
11936
|
else {
|
|
11913
|
-
const
|
|
11914
|
-
m = 1 - k * Math.exp(
|
|
11937
|
+
const y = -o * (u - Math.sqrt(u * u - 1)), v = -o * (u + Math.sqrt(u * u - 1)), k = v / (v - y), x = 1 - k;
|
|
11938
|
+
m = 1 - k * Math.exp(y * p) - x * Math.exp(v * p);
|
|
11915
11939
|
}
|
|
11916
11940
|
return l && m > 1 ? 1 : Math.max(0, m);
|
|
11917
11941
|
}
|
|
@@ -11921,11 +11945,11 @@ function we(a, e, s, r) {
|
|
|
11921
11945
|
return p;
|
|
11922
11946
|
if (a > o && l === "clamp")
|
|
11923
11947
|
return m;
|
|
11924
|
-
const
|
|
11925
|
-
if (
|
|
11948
|
+
const y = o - u;
|
|
11949
|
+
if (y === 0)
|
|
11926
11950
|
return p;
|
|
11927
|
-
const
|
|
11928
|
-
return p +
|
|
11951
|
+
const v = (a - u) / y, k = m - p;
|
|
11952
|
+
return p + v * k;
|
|
11929
11953
|
}
|
|
11930
11954
|
function Bi(a) {
|
|
11931
11955
|
const e = a.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
|
|
@@ -11950,7 +11974,7 @@ function Et(a, e) {
|
|
|
11950
11974
|
}
|
|
11951
11975
|
return !["zh-CN", "ja-JP", "ko-KR"].includes(a);
|
|
11952
11976
|
}
|
|
11953
|
-
function
|
|
11977
|
+
function Do(a, e, s) {
|
|
11954
11978
|
if (!s)
|
|
11955
11979
|
return a / 2 - e / 2;
|
|
11956
11980
|
if (s.top) {
|
|
@@ -11966,10 +11990,10 @@ function Lo(a, e, s) {
|
|
|
11966
11990
|
function Yt(a, e, s, r, h) {
|
|
11967
11991
|
const l = e.fontConfig?.textStyle;
|
|
11968
11992
|
if (!l) return;
|
|
11969
|
-
const u = l.fontSize, o = l.fontFamily, p = l.fontWeight, m = l.fill,
|
|
11993
|
+
const u = l.fontSize, o = l.fontFamily, p = l.fontWeight, m = l.fill, y = l.stroke, v = l.strokeWidth || 0, k = l.lineHeight || 1.2, x = s * 0.64, b = Tt(e.text, e.letterCase);
|
|
11970
11994
|
let T;
|
|
11971
11995
|
if (e.wordTimings && e.wordTimings.length > 0) {
|
|
11972
|
-
const c = Et(e.localeCode || "en-US",
|
|
11996
|
+
const c = Et(e.localeCode || "en-US", b), d = b.split(c ? /\s+/ : "");
|
|
11973
11997
|
T = _i(
|
|
11974
11998
|
a,
|
|
11975
11999
|
d,
|
|
@@ -11980,16 +12004,16 @@ function Yt(a, e, s, r, h) {
|
|
|
11980
12004
|
p
|
|
11981
12005
|
);
|
|
11982
12006
|
} else
|
|
11983
|
-
T = Is(a,
|
|
12007
|
+
T = Is(a, b, x, u, o, p);
|
|
11984
12008
|
a.save(), a.font = `${p} ${u}px ${o}`, a.textAlign = "center", a.textBaseline = "middle", a.lineJoin = "round", a.lineCap = "round";
|
|
11985
|
-
const t = T.length * u * k, n =
|
|
12009
|
+
const t = T.length * u * k, n = Do(r, t, e.fontConfig?.globalPosition);
|
|
11986
12010
|
for (let c = 0; c < T.length; c++) {
|
|
11987
12011
|
const d = T[c], f = n + c * u * k + u / 2;
|
|
11988
|
-
|
|
12012
|
+
y && v > 0 && (a.strokeStyle = y, a.lineWidth = v, a.strokeText(d, s / 2, f)), a.fillStyle = m, a.fillText(d, s / 2, f);
|
|
11989
12013
|
}
|
|
11990
12014
|
a.restore();
|
|
11991
12015
|
}
|
|
11992
|
-
function
|
|
12016
|
+
function Lo(a, e, s, r, h) {
|
|
11993
12017
|
if (!e.fontConfig?.textStyle) return;
|
|
11994
12018
|
const u = As(h, {
|
|
11995
12019
|
damping: 200,
|
|
@@ -12017,7 +12041,7 @@ function zo(a, e, s) {
|
|
|
12017
12041
|
function Oo(a, e, s, r, h, l = 30) {
|
|
12018
12042
|
const u = e.fontConfig?.textStyle;
|
|
12019
12043
|
if (!u) return;
|
|
12020
|
-
const o = u.fontSize, p = u.fontFamily, m = u.fontWeight,
|
|
12044
|
+
const o = u.fontSize, p = u.fontFamily, m = u.fontWeight, y = u.fill, v = u.stroke, k = u.strokeWidth || 0, x = u.lineHeight || 1.2, b = e.animation?.highlightTextStyle?.fill || "rgb(255, 215, 0)", T = e.animation?.highlightTextStyle?.stroke || v, t = s * 0.64, n = Tt(e.text, e.letterCase), c = Et(e.localeCode || "en-US", n), d = n.split(c ? /\s+/ : ""), f = _i(
|
|
12021
12045
|
a,
|
|
12022
12046
|
d,
|
|
12023
12047
|
t,
|
|
@@ -12026,33 +12050,33 @@ function Oo(a, e, s, r, h, l = 30) {
|
|
|
12026
12050
|
p,
|
|
12027
12051
|
m
|
|
12028
12052
|
), g = [];
|
|
12029
|
-
let
|
|
12030
|
-
const
|
|
12053
|
+
let _ = 0;
|
|
12054
|
+
const w = f.length * o * x, C = zo(r, w, e.fontConfig?.globalPosition);
|
|
12031
12055
|
for (let U = 0; U < f.length; U++) {
|
|
12032
|
-
const E = f[U], I = E.split(c ? /\s+/ : ""), P = C + U * o * x + o / 2,
|
|
12033
|
-
let
|
|
12034
|
-
for (const
|
|
12035
|
-
const
|
|
12056
|
+
const E = f[U], I = E.split(c ? /\s+/ : ""), P = C + U * o * x + o / 2, B = ie(a, E, o, p, m);
|
|
12057
|
+
let R = s / 2 - B / 2;
|
|
12058
|
+
for (const L of I) {
|
|
12059
|
+
const j = ie(a, L, o, p, m), K = e.wordTimings?.[_], X = K ? {
|
|
12036
12060
|
startFrame: Pi(K.startUs, l),
|
|
12037
12061
|
endFrame: Pi(K.endUs, l)
|
|
12038
12062
|
} : void 0;
|
|
12039
12063
|
g.push({
|
|
12040
|
-
text:
|
|
12041
|
-
x:
|
|
12064
|
+
text: L,
|
|
12065
|
+
x: R + j / 2,
|
|
12042
12066
|
y: P,
|
|
12043
12067
|
lineIndex: U,
|
|
12044
|
-
wordIndex:
|
|
12068
|
+
wordIndex: _,
|
|
12045
12069
|
timing: X
|
|
12046
|
-
}),
|
|
12070
|
+
}), R += j + (c ? ie(a, " ", o, p, m) : 0), _++;
|
|
12047
12071
|
}
|
|
12048
12072
|
}
|
|
12049
12073
|
a.save(), a.font = `${m} ${o}px ${p}`, a.textAlign = "center", a.textBaseline = "middle", a.lineJoin = "round", a.lineCap = "round";
|
|
12050
12074
|
for (const U of g) {
|
|
12051
|
-
let E =
|
|
12075
|
+
let E = y, I = v;
|
|
12052
12076
|
if (U.timing) {
|
|
12053
|
-
const { startFrame: P, endFrame:
|
|
12054
|
-
if (h >= P && h <=
|
|
12055
|
-
const
|
|
12077
|
+
const { startFrame: P, endFrame: B } = U.timing;
|
|
12078
|
+
if (h >= P && h <= B) {
|
|
12079
|
+
const R = we(
|
|
12056
12080
|
h,
|
|
12057
12081
|
[P, P + 3],
|
|
12058
12082
|
[0, 1],
|
|
@@ -12061,13 +12085,13 @@ function Oo(a, e, s, r, h, l = 30) {
|
|
|
12061
12085
|
extrapolateRight: "clamp"
|
|
12062
12086
|
}
|
|
12063
12087
|
);
|
|
12064
|
-
E = nt(
|
|
12065
|
-
} else if (h >
|
|
12066
|
-
const
|
|
12088
|
+
E = nt(y, b, R), v && T && (I = nt(v, T, R));
|
|
12089
|
+
} else if (h > B) {
|
|
12090
|
+
const R = we(h, [B, B + 3], [1, 0], {
|
|
12067
12091
|
extrapolateLeft: "clamp",
|
|
12068
12092
|
extrapolateRight: "clamp"
|
|
12069
12093
|
});
|
|
12070
|
-
E = nt(
|
|
12094
|
+
E = nt(y, b, R), v && T && (I = nt(v, T, R));
|
|
12071
12095
|
}
|
|
12072
12096
|
}
|
|
12073
12097
|
I && k > 0 && (a.strokeStyle = I, a.lineWidth = k, a.strokeText(U.text, U.x, U.y)), a.fillStyle = E, a.fillText(U.text, U.x, U.y);
|
|
@@ -12093,15 +12117,15 @@ function No(a, e, s) {
|
|
|
12093
12117
|
function Wo(a, e, s, r, h, l = 30) {
|
|
12094
12118
|
const u = e.fontConfig?.textStyle;
|
|
12095
12119
|
if (!u) return;
|
|
12096
|
-
const o = u.fontSize, p = u.fontFamily, m = u.fontWeight,
|
|
12120
|
+
const o = u.fontSize, p = u.fontFamily, m = u.fontWeight, y = u.fill, v = u.stroke, k = u.strokeWidth || 0, x = u.lineHeight || 1.2, b = e.animation?.highlightTextStyle?.fill || "rgb(255, 215, 0)", T = e.animation?.glowColor || "#ffffff", t = e.animation?.glowIntensity || 3, n = e.animation?.transitionFrames || 10, c = s * 0.9, d = Tt(e.text, e.letterCase), f = Et(e.localeCode || "en-US", d), g = [];
|
|
12097
12121
|
if (e.wordTimings && e.wordTimings.length > 0) {
|
|
12098
12122
|
let I = 0;
|
|
12099
12123
|
for (let P = 0; P < e.wordTimings.length; P++) {
|
|
12100
|
-
const
|
|
12101
|
-
for (let X = 0; X <
|
|
12102
|
-
const J = Math.floor(
|
|
12124
|
+
const B = e.wordTimings[P], R = B.text.split(""), L = Mi(B.startUs, l), j = Mi(B.endUs, l), K = R.length > 0 ? (j - L) / R.length : 0;
|
|
12125
|
+
for (let X = 0; X < R.length; X++) {
|
|
12126
|
+
const J = Math.floor(L + X * K);
|
|
12103
12127
|
g.push({
|
|
12104
|
-
char:
|
|
12128
|
+
char: R[X],
|
|
12105
12129
|
index: I,
|
|
12106
12130
|
startFrame: J
|
|
12107
12131
|
}), I++;
|
|
@@ -12119,28 +12143,28 @@ function Wo(a, e, s, r, h, l = 30) {
|
|
|
12119
12143
|
}
|
|
12120
12144
|
}
|
|
12121
12145
|
} else {
|
|
12122
|
-
const P = d.split(""),
|
|
12123
|
-
for (let
|
|
12146
|
+
const P = d.split(""), B = P.length > 0 ? 100 / P.length : 0;
|
|
12147
|
+
for (let R = 0; R < P.length; R++)
|
|
12124
12148
|
g.push({
|
|
12125
|
-
char: P[
|
|
12126
|
-
index:
|
|
12127
|
-
startFrame: Math.floor(
|
|
12149
|
+
char: P[R],
|
|
12150
|
+
index: R,
|
|
12151
|
+
startFrame: Math.floor(R * B)
|
|
12128
12152
|
});
|
|
12129
12153
|
}
|
|
12130
|
-
const
|
|
12154
|
+
const _ = g.map((I) => I.char).join(""), w = Is(a, _, c, o, p, m);
|
|
12131
12155
|
a.save(), a.font = `${m} ${o}px ${p}`, a.textAlign = "left", a.textBaseline = "middle", a.lineJoin = "round", a.lineCap = "round";
|
|
12132
|
-
const C =
|
|
12156
|
+
const C = w.length * o * x, U = No(r, C, e.fontConfig?.globalPosition);
|
|
12133
12157
|
let E = 0;
|
|
12134
|
-
for (let I = 0; I <
|
|
12135
|
-
const P =
|
|
12136
|
-
let
|
|
12137
|
-
for (let
|
|
12138
|
-
const K = P[
|
|
12158
|
+
for (let I = 0; I < w.length; I++) {
|
|
12159
|
+
const P = w[I], B = U + I * o * x + o / 2, R = ie(a, P, o, p, m);
|
|
12160
|
+
let L = s / 2 - R / 2;
|
|
12161
|
+
for (let j = 0; j < P.length; j++) {
|
|
12162
|
+
const K = P[j], X = g[E];
|
|
12139
12163
|
if (X) {
|
|
12140
12164
|
const J = h >= X.startFrame, he = J && h < X.startFrame + n;
|
|
12141
|
-
a.fillStyle = J ?
|
|
12165
|
+
a.fillStyle = J ? b : y, he ? (a.shadowColor = T, a.shadowBlur = t * 10) : a.shadowBlur = 0, v && k > 0 && (a.strokeStyle = v, a.lineWidth = k, a.strokeText(K, L, B)), a.fillText(K, L, B), a.shadowBlur = 0;
|
|
12142
12166
|
}
|
|
12143
|
-
|
|
12167
|
+
L += ie(a, K, o, p, m), E++;
|
|
12144
12168
|
}
|
|
12145
12169
|
}
|
|
12146
12170
|
a.restore();
|
|
@@ -12164,7 +12188,7 @@ function Ho(a, e, s) {
|
|
|
12164
12188
|
function Vo(a, e, s, r, h, l = 30) {
|
|
12165
12189
|
const u = e.fontConfig?.textStyle;
|
|
12166
12190
|
if (!u) return;
|
|
12167
|
-
const o = u.fontSize, p = u.fontFamily, m = u.fontWeight,
|
|
12191
|
+
const o = u.fontSize, p = u.fontFamily, m = u.fontWeight, y = u.fill, v = u.stroke, k = u.strokeWidth || 0, x = u.lineHeight || 1.2, b = e.animation?.highlightColor || "rgb(255, 215, 0)", T = s * 0.64, t = Tt(e.text, e.letterCase), n = Et(e.localeCode || "en-US", t), c = t.split(n ? /\s+/ : ""), d = _i(
|
|
12168
12192
|
a,
|
|
12169
12193
|
c,
|
|
12170
12194
|
T,
|
|
@@ -12174,33 +12198,33 @@ function Vo(a, e, s, r, h, l = 30) {
|
|
|
12174
12198
|
m
|
|
12175
12199
|
), f = [];
|
|
12176
12200
|
let g = 0;
|
|
12177
|
-
const
|
|
12201
|
+
const _ = d.length * o * x, w = Ho(r, _, e.fontConfig?.globalPosition);
|
|
12178
12202
|
for (let C = 0; C < d.length; C++) {
|
|
12179
|
-
const U = d[C], E = U.split(n ? /\s+/ : ""), I =
|
|
12180
|
-
let
|
|
12181
|
-
for (const
|
|
12182
|
-
const
|
|
12183
|
-
startFrame: Ri(
|
|
12184
|
-
endFrame: Ri(
|
|
12203
|
+
const U = d[C], E = U.split(n ? /\s+/ : ""), I = w + C * o * x + o / 2, P = ie(a, U, o, p, m);
|
|
12204
|
+
let B = s / 2 - P / 2;
|
|
12205
|
+
for (const R of E) {
|
|
12206
|
+
const L = ie(a, R, o, p, m), j = e.wordTimings?.[g], K = j ? {
|
|
12207
|
+
startFrame: Ri(j.startUs, l),
|
|
12208
|
+
endFrame: Ri(j.endUs, l)
|
|
12185
12209
|
} : void 0;
|
|
12186
12210
|
f.push({
|
|
12187
|
-
text:
|
|
12188
|
-
x:
|
|
12211
|
+
text: R,
|
|
12212
|
+
x: B + L / 2,
|
|
12189
12213
|
y: I,
|
|
12190
|
-
width:
|
|
12214
|
+
width: L,
|
|
12191
12215
|
lineIndex: C,
|
|
12192
12216
|
wordIndex: g,
|
|
12193
12217
|
timing: K
|
|
12194
|
-
}),
|
|
12218
|
+
}), B += L + (n ? ie(a, " ", o, p, m) : 0), g++;
|
|
12195
12219
|
}
|
|
12196
12220
|
}
|
|
12197
12221
|
a.save(), a.font = `${m} ${o}px ${p}`, a.textAlign = "center", a.textBaseline = "middle", a.lineJoin = "round", a.lineCap = "round";
|
|
12198
12222
|
for (const C of f) {
|
|
12199
12223
|
let U = 0, E = 0.8;
|
|
12200
12224
|
if (C.timing) {
|
|
12201
|
-
const { startFrame: I, endFrame: P } = C.timing,
|
|
12225
|
+
const { startFrame: I, endFrame: P } = C.timing, B = 3;
|
|
12202
12226
|
if (h >= I && h <= P) {
|
|
12203
|
-
const
|
|
12227
|
+
const L = As(h - (I - B), {
|
|
12204
12228
|
damping: 6,
|
|
12205
12229
|
mass: 0.35,
|
|
12206
12230
|
stiffness: 200,
|
|
@@ -12209,14 +12233,14 @@ function Vo(a, e, s, r, h, l = 30) {
|
|
|
12209
12233
|
U = 0.9 * we(h, [I, I + 1], [0, 1], {
|
|
12210
12234
|
extrapolateLeft: "clamp",
|
|
12211
12235
|
extrapolateRight: "clamp"
|
|
12212
|
-
}), E = 0.8 +
|
|
12236
|
+
}), E = 0.8 + L * 0.45;
|
|
12213
12237
|
} else h > P && (U = 0, E = 0.8);
|
|
12214
12238
|
if (U > 0) {
|
|
12215
|
-
const
|
|
12216
|
-
a.save(), a.globalAlpha = U, a.fillStyle =
|
|
12239
|
+
const j = (C.width + 16) * E, K = (o + 8) * E;
|
|
12240
|
+
a.save(), a.globalAlpha = U, a.fillStyle = b, a.beginPath(), a.roundRect(C.x - j / 2, C.y - K / 2, j, K, 8), a.fill(), a.restore();
|
|
12217
12241
|
}
|
|
12218
12242
|
}
|
|
12219
|
-
|
|
12243
|
+
v && k > 0 && (a.strokeStyle = v, a.lineWidth = k, a.strokeText(C.text, C.x, C.y)), a.fillStyle = y, a.fillText(C.text, C.x, C.y);
|
|
12220
12244
|
}
|
|
12221
12245
|
a.restore();
|
|
12222
12246
|
}
|
|
@@ -12315,12 +12339,12 @@ class Go {
|
|
|
12315
12339
|
const h = e * r, l = s * r, u = h / this.width > this.FILL_THRESHOLD && l / this.height > this.FILL_THRESHOLD;
|
|
12316
12340
|
let o, p;
|
|
12317
12341
|
if (u) {
|
|
12318
|
-
const
|
|
12319
|
-
o = Math.round(e *
|
|
12342
|
+
const v = Math.max(this.width / e, this.height / s);
|
|
12343
|
+
o = Math.round(e * v), p = Math.round(s * v);
|
|
12320
12344
|
} else
|
|
12321
12345
|
o = Math.round(h), p = Math.round(l);
|
|
12322
|
-
const m = Math.round((this.width - o) / 2),
|
|
12323
|
-
return { width: o, height: p, x: m, y
|
|
12346
|
+
const m = Math.round((this.width - o) / 2), y = Math.round((this.height - p) / 2);
|
|
12347
|
+
return { width: o, height: p, x: m, y };
|
|
12324
12348
|
}
|
|
12325
12349
|
applyTransform(e, s) {
|
|
12326
12350
|
const r = e.anchorX ?? 0.5, h = e.anchorY ?? 0.5, l = s.width * r, u = s.height * h;
|
|
@@ -12328,13 +12352,13 @@ class Go {
|
|
|
12328
12352
|
}
|
|
12329
12353
|
renderVideoLayer(e) {
|
|
12330
12354
|
const { videoFrame: s, crop: r, renderConfig: h } = e, l = s.displayWidth || s.codedWidth, u = s.displayHeight || s.codedHeight;
|
|
12331
|
-
let o, p, m,
|
|
12355
|
+
let o, p, m, y;
|
|
12332
12356
|
if (h?.width !== void 0 || h?.height !== void 0) {
|
|
12333
12357
|
const k = this.calculateDimensionsFromConfig(l, u, h);
|
|
12334
|
-
m = k.width,
|
|
12358
|
+
m = k.width, y = k.height, o = Math.round((this.width - m) / 2), p = Math.round((this.height - y) / 2);
|
|
12335
12359
|
} else {
|
|
12336
12360
|
const k = this.height / u, x = this.calculateRenderDimensions(l, u, k);
|
|
12337
|
-
o = x.x, p = x.y, m = x.width,
|
|
12361
|
+
o = x.x, p = x.y, m = x.width, y = x.height;
|
|
12338
12362
|
}
|
|
12339
12363
|
r ? this.ctx.drawImage(
|
|
12340
12364
|
s,
|
|
@@ -12345,8 +12369,8 @@ class Go {
|
|
|
12345
12369
|
o,
|
|
12346
12370
|
p,
|
|
12347
12371
|
m,
|
|
12348
|
-
|
|
12349
|
-
) : this.ctx.drawImage(s, o, p, m,
|
|
12372
|
+
y
|
|
12373
|
+
) : this.ctx.drawImage(s, o, p, m, y);
|
|
12350
12374
|
}
|
|
12351
12375
|
renderImageLayer(e) {
|
|
12352
12376
|
const { source: s, crop: r, renderConfig: h, attachmentId: l } = e;
|
|
@@ -12360,15 +12384,15 @@ class Go {
|
|
|
12360
12384
|
}
|
|
12361
12385
|
if (!s) return;
|
|
12362
12386
|
const u = s.width, o = s.height;
|
|
12363
|
-
let p, m,
|
|
12387
|
+
let p, m, y, v;
|
|
12364
12388
|
if (h?.width !== void 0 || h?.height !== void 0) {
|
|
12365
12389
|
const x = this.calculateDimensionsFromConfig(u, o, h);
|
|
12366
|
-
|
|
12390
|
+
y = x.width, v = x.height, p = 0, m = 0;
|
|
12367
12391
|
} else if (l)
|
|
12368
|
-
|
|
12392
|
+
y = u, v = o, p = 0, m = 0;
|
|
12369
12393
|
else {
|
|
12370
|
-
const x = this.width / u,
|
|
12371
|
-
|
|
12394
|
+
const x = this.width / u, b = this.calculateRenderDimensions(u, o, x);
|
|
12395
|
+
y = b.width, v = b.height, p = Math.round((this.width - y) / 2), m = Math.round((this.height - v) / 2);
|
|
12372
12396
|
}
|
|
12373
12397
|
r ? this.ctx.drawImage(
|
|
12374
12398
|
s,
|
|
@@ -12378,9 +12402,9 @@ class Go {
|
|
|
12378
12402
|
r.height,
|
|
12379
12403
|
p,
|
|
12380
12404
|
m,
|
|
12381
|
-
|
|
12382
|
-
|
|
12383
|
-
) : this.ctx.drawImage(s, p, m,
|
|
12405
|
+
y,
|
|
12406
|
+
v
|
|
12407
|
+
) : this.ctx.drawImage(s, p, m, y, v);
|
|
12384
12408
|
}
|
|
12385
12409
|
renderTextLayer(e) {
|
|
12386
12410
|
const s = e.animation?.type, r = e.wordTimings && e.wordTimings.length > 0;
|
|
@@ -12408,7 +12432,7 @@ class Go {
|
|
|
12408
12432
|
);
|
|
12409
12433
|
break;
|
|
12410
12434
|
case "fade":
|
|
12411
|
-
|
|
12435
|
+
Lo(this.ctx, e, this.width, this.height, this.currentFrame);
|
|
12412
12436
|
break;
|
|
12413
12437
|
default:
|
|
12414
12438
|
Yt(this.ctx, e, this.width, this.height, this.currentFrame);
|
|
@@ -12533,18 +12557,18 @@ class $o {
|
|
|
12533
12557
|
for (let o = 0; o < this.height; o++)
|
|
12534
12558
|
for (let p = 0; p < this.width; p++) {
|
|
12535
12559
|
const m = (o * this.width + p) * 4;
|
|
12536
|
-
let
|
|
12560
|
+
let y = 255;
|
|
12537
12561
|
switch (e.type) {
|
|
12538
12562
|
case "wipe":
|
|
12539
|
-
|
|
12563
|
+
y = this.calculateWipeAlpha(p, o, u, e.direction);
|
|
12540
12564
|
break;
|
|
12541
12565
|
case "dissolve":
|
|
12542
|
-
|
|
12566
|
+
y = Math.random() < u ? 255 : 0;
|
|
12543
12567
|
break;
|
|
12544
12568
|
default:
|
|
12545
|
-
|
|
12569
|
+
y = Math.floor(255 * u);
|
|
12546
12570
|
}
|
|
12547
|
-
l[m] = 255, l[m + 1] = 255, l[m + 2] = 255, l[m + 3] =
|
|
12571
|
+
l[m] = 255, l[m + 1] = 255, l[m + 2] = 255, l[m + 3] = y;
|
|
12548
12572
|
}
|
|
12549
12573
|
return h;
|
|
12550
12574
|
}
|
|
@@ -12656,8 +12680,8 @@ class jo {
|
|
|
12656
12680
|
throw new Error("Color matrix must have 20 values (4x5 matrix)");
|
|
12657
12681
|
const r = e.data, h = r.length;
|
|
12658
12682
|
for (let l = 0; l < h; l += 4) {
|
|
12659
|
-
const u = r[l], o = r[l + 1], p = r[l + 2], m = r[l + 3],
|
|
12660
|
-
r[l] = this.clamp(u *
|
|
12683
|
+
const u = r[l], o = r[l + 1], p = r[l + 2], m = r[l + 3], y = s;
|
|
12684
|
+
r[l] = this.clamp(u * y[0] + o * y[1] + p * y[2] + m * y[3] + y[4] * 255), r[l + 1] = this.clamp(u * y[5] + o * y[6] + p * y[7] + m * y[8] + y[9] * 255), r[l + 2] = this.clamp(u * y[10] + o * y[11] + p * y[12] + m * y[13] + y[14] * 255), r[l + 3] = this.clamp(u * y[15] + o * y[16] + p * y[17] + m * y[18] + y[19] * 255);
|
|
12661
12685
|
}
|
|
12662
12686
|
return e;
|
|
12663
12687
|
}
|
|
@@ -12731,23 +12755,23 @@ class jo {
|
|
|
12731
12755
|
), h = e.width, l = e.height, u = e.data, o = r.data;
|
|
12732
12756
|
for (let p = 0; p < l; p++)
|
|
12733
12757
|
for (let m = 0; m < h; m++) {
|
|
12734
|
-
let
|
|
12758
|
+
let y = 0, v = 0, k = 0, x = 0, b = 0;
|
|
12735
12759
|
for (let t = -s; t <= s; t++) {
|
|
12736
12760
|
const n = Math.min(Math.max(m + t, 0), h - 1), c = (p * h + n) * 4;
|
|
12737
|
-
|
|
12761
|
+
y += u[c], v += u[c + 1], k += u[c + 2], x += u[c + 3], b++;
|
|
12738
12762
|
}
|
|
12739
12763
|
const T = (p * h + m) * 4;
|
|
12740
|
-
o[T] =
|
|
12764
|
+
o[T] = y / b, o[T + 1] = v / b, o[T + 2] = k / b, o[T + 3] = x / b;
|
|
12741
12765
|
}
|
|
12742
12766
|
for (let p = 0; p < h; p++)
|
|
12743
12767
|
for (let m = 0; m < l; m++) {
|
|
12744
|
-
let
|
|
12768
|
+
let y = 0, v = 0, k = 0, x = 0, b = 0;
|
|
12745
12769
|
for (let t = -s; t <= s; t++) {
|
|
12746
12770
|
const c = (Math.min(Math.max(m + t, 0), l - 1) * h + p) * 4;
|
|
12747
|
-
|
|
12771
|
+
y += o[c], v += o[c + 1], k += o[c + 2], x += o[c + 3], b++;
|
|
12748
12772
|
}
|
|
12749
12773
|
const T = (m * h + p) * 4;
|
|
12750
|
-
u[T] =
|
|
12774
|
+
u[T] = y / b, u[T + 1] = v / b, u[T + 2] = k / b, u[T + 3] = x / b;
|
|
12751
12775
|
}
|
|
12752
12776
|
return e;
|
|
12753
12777
|
}
|
|
@@ -12918,7 +12942,7 @@ class Yo {
|
|
|
12918
12942
|
}
|
|
12919
12943
|
}
|
|
12920
12944
|
class qo {
|
|
12921
|
-
state =
|
|
12945
|
+
state = z.Idle;
|
|
12922
12946
|
wantsPlay = !1;
|
|
12923
12947
|
frozenTimeUs = null;
|
|
12924
12948
|
token = 0;
|
|
@@ -12931,186 +12955,186 @@ class qo {
|
|
|
12931
12955
|
};
|
|
12932
12956
|
}
|
|
12933
12957
|
dispatch(e, s) {
|
|
12934
|
-
const r = [], h = () => (this.token++, this.token), l = (
|
|
12935
|
-
this.state =
|
|
12936
|
-
}, u = (
|
|
12937
|
-
this.wantsPlay =
|
|
12938
|
-
}, o = (
|
|
12939
|
-
this.frozenTimeUs =
|
|
12940
|
-
}, p = (
|
|
12941
|
-
r.push({ type:
|
|
12942
|
-
}, m = (
|
|
12943
|
-
const k =
|
|
12944
|
-
return Math.max(0, Math.min(
|
|
12958
|
+
const r = [], h = () => (this.token++, this.token), l = (y) => {
|
|
12959
|
+
this.state = y, r.push({ type: A.SetState, state: y });
|
|
12960
|
+
}, u = (y) => {
|
|
12961
|
+
this.wantsPlay = y, r.push({ type: A.SetWantsPlay, wantsPlay: y });
|
|
12962
|
+
}, o = (y) => {
|
|
12963
|
+
this.frozenTimeUs = y, r.push({ type: A.SetFrozenTime, timeUs: y });
|
|
12964
|
+
}, p = (y) => {
|
|
12965
|
+
r.push({ type: A.SetTime, timeUs: y });
|
|
12966
|
+
}, m = (y, v) => {
|
|
12967
|
+
const k = v > 0 ? v - 1 : 0;
|
|
12968
|
+
return Math.max(0, Math.min(y, k));
|
|
12945
12969
|
};
|
|
12946
12970
|
switch (e.type) {
|
|
12947
12971
|
case $.ModelSet:
|
|
12948
|
-
return h(), r.push({ type:
|
|
12972
|
+
return h(), r.push({ type: A.CancelRaf }), r.push({ type: A.StopAudio }), r.push({ type: A.SetLastAudioScheduleTime, timeUs: 0 }), o(null), (this.state === z.Playing || this.state === z.Buffering || this.state === z.Seeking) && l(z.Paused), { token: this.token, commands: r };
|
|
12949
12973
|
case $.Play: {
|
|
12950
|
-
const
|
|
12951
|
-
if (u(!0), this.state ===
|
|
12952
|
-
return { token:
|
|
12953
|
-
l(
|
|
12954
|
-
const k =
|
|
12974
|
+
const y = h(), v = this.state;
|
|
12975
|
+
if (u(!0), this.state === z.Ended && p(0), this.state === z.Playing)
|
|
12976
|
+
return { token: y, commands: r };
|
|
12977
|
+
l(z.Playing), o(null), r.push({ type: A.SetLastAudioScheduleTime, timeUs: 0 }), r.push({ type: A.CancelRaf });
|
|
12978
|
+
const k = v === z.Idle || v === z.Ended ? z.Idle : z.Paused;
|
|
12955
12979
|
return r.push({
|
|
12956
|
-
type:
|
|
12980
|
+
type: A.Try,
|
|
12957
12981
|
logPrefix: "[PlaybackController] Failed to start playback:",
|
|
12958
12982
|
emitPlaybackError: !0,
|
|
12959
12983
|
ignoreWaiterReplacedError: !0,
|
|
12960
12984
|
onError: { type: $.StartFailed, fallbackState: k },
|
|
12961
12985
|
command: {
|
|
12962
|
-
type:
|
|
12986
|
+
type: A.Seq,
|
|
12963
12987
|
commands: [
|
|
12964
|
-
{ type:
|
|
12988
|
+
{ type: A.ProbeStartReady, timeUs: s.currentTimeUs },
|
|
12965
12989
|
{
|
|
12966
|
-
type:
|
|
12990
|
+
type: A.RenderFrame,
|
|
12967
12991
|
timeUs: s.currentTimeUs,
|
|
12968
12992
|
mode: "blocking"
|
|
12969
12993
|
},
|
|
12970
|
-
{ type:
|
|
12971
|
-
{ type:
|
|
12972
|
-
{ type:
|
|
12973
|
-
{ type:
|
|
12974
|
-
{ type:
|
|
12994
|
+
{ type: A.InitWindow, timeUs: s.currentTimeUs },
|
|
12995
|
+
{ type: A.StartAudioPlayback, timeUs: s.currentTimeUs },
|
|
12996
|
+
{ type: A.SyncTimeBaseToAudioClock, timeUs: s.currentTimeUs },
|
|
12997
|
+
{ type: A.StartRafLoop },
|
|
12998
|
+
{ type: A.Emit, event: O.PlaybackPlay }
|
|
12975
12999
|
]
|
|
12976
13000
|
}
|
|
12977
|
-
}), { token:
|
|
13001
|
+
}), { token: y, commands: r };
|
|
12978
13002
|
}
|
|
12979
13003
|
case $.Pause: {
|
|
12980
13004
|
h();
|
|
12981
|
-
const
|
|
12982
|
-
return u(!1), o(null), r.push({ type:
|
|
13005
|
+
const y = this.state;
|
|
13006
|
+
return u(!1), o(null), r.push({ type: A.CancelRaf }), r.push({ type: A.StopAudio }), y !== z.Idle && y !== z.Ended && l(z.Paused), (y === z.Playing || y === z.Buffering || y === z.Seeking) && r.push({ type: A.Emit, event: O.PlaybackPause }), { token: this.token, commands: r };
|
|
12983
13007
|
}
|
|
12984
13008
|
case $.Stop:
|
|
12985
|
-
return h(), u(!1), o(null), l(
|
|
13009
|
+
return h(), u(!1), o(null), l(z.Idle), p(0), r.push({ type: A.CancelRaf }), r.push({ type: A.StopAudio }), r.push({ type: A.ClearCanvas }), r.push({ type: A.ResetAudioSession }), r.push({ type: A.ResetAudioPlaybackStates }), r.push({ type: A.SetLastAudioScheduleTime, timeUs: 0 }), r.push({ type: A.Emit, event: O.PlaybackStop }), { token: this.token, commands: r };
|
|
12986
13010
|
case $.Seek: {
|
|
12987
|
-
const
|
|
12988
|
-
return p(k), o(k), l(
|
|
12989
|
-
type:
|
|
13011
|
+
const y = h(), v = this.state, k = m(e.timeUs, e.durationUs);
|
|
13012
|
+
return p(k), o(k), l(z.Seeking), r.push({ type: A.CancelRaf }), r.push({ type: A.StopAudio }), r.push({ type: A.SetLastAudioScheduleTime, timeUs: 0 }), r.push({
|
|
13013
|
+
type: A.Try,
|
|
12990
13014
|
logPrefix: "[PlaybackController] Seek error:",
|
|
12991
13015
|
emitPlaybackError: !0,
|
|
12992
13016
|
ignoreWaiterReplacedError: !0,
|
|
12993
13017
|
onError: { type: $.Pause },
|
|
12994
13018
|
command: {
|
|
12995
|
-
type:
|
|
13019
|
+
type: A.Seq,
|
|
12996
13020
|
commands: [
|
|
12997
|
-
{ type:
|
|
13021
|
+
{ type: A.MaybeRenderKeyframePreview, timeUs: k },
|
|
12998
13022
|
{
|
|
12999
|
-
type:
|
|
13023
|
+
type: A.Par,
|
|
13000
13024
|
commands: [
|
|
13001
|
-
{ type:
|
|
13025
|
+
{ type: A.EnsureAudio, timeUs: k, mode: "blocking" },
|
|
13002
13026
|
{
|
|
13003
|
-
type:
|
|
13027
|
+
type: A.GetFrame,
|
|
13004
13028
|
timeUs: k,
|
|
13005
13029
|
mode: "blocking",
|
|
13006
13030
|
preheat: !0
|
|
13007
13031
|
}
|
|
13008
13032
|
]
|
|
13009
13033
|
},
|
|
13010
|
-
{ type:
|
|
13011
|
-
{ type:
|
|
13034
|
+
{ type: A.InitWindow, timeUs: k },
|
|
13035
|
+
{ type: A.RenderFrame, timeUs: k, mode: "blocking" },
|
|
13012
13036
|
{
|
|
13013
|
-
type:
|
|
13014
|
-
action: { type: $.SeekResolved, previousState:
|
|
13037
|
+
type: A.Dispatch,
|
|
13038
|
+
action: { type: $.SeekResolved, previousState: v }
|
|
13015
13039
|
}
|
|
13016
13040
|
]
|
|
13017
13041
|
}
|
|
13018
|
-
}), { token:
|
|
13042
|
+
}), { token: y, commands: r };
|
|
13019
13043
|
}
|
|
13020
13044
|
case $.EnterBuffering:
|
|
13021
|
-
return (e.bumpToken ?? !1) && h(), this.state !==
|
|
13022
|
-
type:
|
|
13045
|
+
return (e.bumpToken ?? !1) && h(), this.state !== z.Playing ? { token: this.token, commands: r } : (o(e.timeUs), l(z.Buffering), r.push({ type: A.Emit, event: O.PlaybackBuffering }), r.push({ type: A.CancelRaf }), r.push({ type: A.StopAudio }), r.push({
|
|
13046
|
+
type: A.Try,
|
|
13023
13047
|
logPrefix: "[PlaybackController] Buffering error:",
|
|
13024
13048
|
emitPlaybackError: !0,
|
|
13025
13049
|
ignoreWaiterReplacedError: !0,
|
|
13026
13050
|
onError: { type: $.Pause },
|
|
13027
13051
|
command: {
|
|
13028
|
-
type:
|
|
13052
|
+
type: A.Seq,
|
|
13029
13053
|
commands: [
|
|
13030
|
-
{ type:
|
|
13054
|
+
{ type: A.SetCacheWindow, timeUs: e.timeUs },
|
|
13031
13055
|
{
|
|
13032
|
-
type:
|
|
13056
|
+
type: A.Par,
|
|
13033
13057
|
commands: [
|
|
13034
|
-
{ type:
|
|
13058
|
+
{ type: A.GetFrame, timeUs: e.timeUs, mode: "blocking" },
|
|
13035
13059
|
{
|
|
13036
|
-
type:
|
|
13060
|
+
type: A.EnsureAudio,
|
|
13037
13061
|
timeUs: e.timeUs,
|
|
13038
13062
|
mode: "blocking"
|
|
13039
13063
|
}
|
|
13040
13064
|
]
|
|
13041
13065
|
},
|
|
13042
13066
|
{
|
|
13043
|
-
type:
|
|
13067
|
+
type: A.Dispatch,
|
|
13044
13068
|
action: { type: $.BufferingResolved, timeUs: e.timeUs }
|
|
13045
13069
|
}
|
|
13046
13070
|
]
|
|
13047
13071
|
}
|
|
13048
13072
|
}), { token: this.token, commands: r });
|
|
13049
13073
|
case $.BufferingResolved:
|
|
13050
|
-
return this.state !==
|
|
13051
|
-
type:
|
|
13074
|
+
return this.state !== z.Buffering ? { token: this.token, commands: r } : (o(null), this.wantsPlay ? (l(z.Playing), r.push({
|
|
13075
|
+
type: A.Try,
|
|
13052
13076
|
logPrefix: "[PlaybackController] Failed to start playback:",
|
|
13053
13077
|
emitPlaybackError: !0,
|
|
13054
|
-
onError: { type: $.StartFailed, fallbackState:
|
|
13078
|
+
onError: { type: $.StartFailed, fallbackState: z.Paused },
|
|
13055
13079
|
command: {
|
|
13056
|
-
type:
|
|
13080
|
+
type: A.Seq,
|
|
13057
13081
|
commands: [
|
|
13058
|
-
{ type:
|
|
13059
|
-
{ type:
|
|
13060
|
-
{ type:
|
|
13061
|
-
{ type:
|
|
13062
|
-
{ type:
|
|
13063
|
-
{ type:
|
|
13082
|
+
{ type: A.RenderFrame, timeUs: e.timeUs, mode: "blocking" },
|
|
13083
|
+
{ type: A.InitWindow, timeUs: e.timeUs },
|
|
13084
|
+
{ type: A.StartAudioPlayback, timeUs: e.timeUs },
|
|
13085
|
+
{ type: A.SyncTimeBaseToAudioClock, timeUs: e.timeUs },
|
|
13086
|
+
{ type: A.StartRafLoop },
|
|
13087
|
+
{ type: A.Emit, event: O.PlaybackPlay }
|
|
13064
13088
|
]
|
|
13065
13089
|
}
|
|
13066
|
-
})) : l(
|
|
13090
|
+
})) : l(z.Paused), { token: this.token, commands: r });
|
|
13067
13091
|
case $.SeekResolved:
|
|
13068
|
-
return this.state !==
|
|
13069
|
-
type:
|
|
13070
|
-
event:
|
|
13092
|
+
return this.state !== z.Seeking ? { token: this.token, commands: r } : (o(null), r.push({
|
|
13093
|
+
type: A.Emit,
|
|
13094
|
+
event: O.PlaybackSeek,
|
|
13071
13095
|
payload: { timeUs: s.currentTimeUs }
|
|
13072
|
-
}), this.wantsPlay ? (l(
|
|
13073
|
-
type:
|
|
13096
|
+
}), this.wantsPlay ? (l(z.Playing), r.push({
|
|
13097
|
+
type: A.Try,
|
|
13074
13098
|
logPrefix: "[PlaybackController] Failed to start playback:",
|
|
13075
13099
|
emitPlaybackError: !0,
|
|
13076
|
-
onError: { type: $.StartFailed, fallbackState:
|
|
13100
|
+
onError: { type: $.StartFailed, fallbackState: z.Paused },
|
|
13077
13101
|
command: {
|
|
13078
|
-
type:
|
|
13102
|
+
type: A.Seq,
|
|
13079
13103
|
commands: [
|
|
13080
13104
|
{
|
|
13081
|
-
type:
|
|
13105
|
+
type: A.RenderFrame,
|
|
13082
13106
|
timeUs: s.currentTimeUs,
|
|
13083
13107
|
mode: "blocking"
|
|
13084
13108
|
},
|
|
13085
|
-
{ type:
|
|
13086
|
-
{ type:
|
|
13087
|
-
{ type:
|
|
13088
|
-
{ type:
|
|
13089
|
-
{ type:
|
|
13109
|
+
{ type: A.InitWindow, timeUs: s.currentTimeUs },
|
|
13110
|
+
{ type: A.StartAudioPlayback, timeUs: s.currentTimeUs },
|
|
13111
|
+
{ type: A.SyncTimeBaseToAudioClock, timeUs: s.currentTimeUs },
|
|
13112
|
+
{ type: A.StartRafLoop },
|
|
13113
|
+
{ type: A.Emit, event: O.PlaybackPlay }
|
|
13090
13114
|
]
|
|
13091
13115
|
}
|
|
13092
13116
|
})) : l(
|
|
13093
|
-
e.previousState ===
|
|
13117
|
+
e.previousState === z.Idle ? z.Idle : z.Paused
|
|
13094
13118
|
), { token: this.token, commands: r });
|
|
13095
13119
|
case $.StartFailed:
|
|
13096
|
-
return u(!1), o(null), l(e.fallbackState), r.push({ type:
|
|
13120
|
+
return u(!1), o(null), l(e.fallbackState), r.push({ type: A.CancelRaf }), r.push({ type: A.StopAudio }), r.push({ type: A.SetLastAudioScheduleTime, timeUs: 0 }), { token: this.token, commands: r };
|
|
13097
13121
|
case $.ClockTick: {
|
|
13098
|
-
if (this.state !==
|
|
13122
|
+
if (this.state !== z.Playing)
|
|
13099
13123
|
return { token: this.token, commands: r };
|
|
13100
13124
|
if (this.frozenTimeUs !== null)
|
|
13101
13125
|
return { token: this.token, commands: r };
|
|
13102
|
-
const
|
|
13103
|
-
return
|
|
13104
|
-
type:
|
|
13126
|
+
const y = e.candidateTimeUs;
|
|
13127
|
+
return y >= e.durationUs ? (e.loop ? (p(0), r.push({
|
|
13128
|
+
type: A.SetStartTimeBase,
|
|
13105
13129
|
startTimeUs: e.audioNowUs
|
|
13106
|
-
}), r.push({ type:
|
|
13107
|
-
type:
|
|
13108
|
-
event:
|
|
13130
|
+
}), r.push({ type: A.ResetAudioPlaybackStates }), r.push({ type: A.SetLastAudioScheduleTime, timeUs: 0 }), r.push({ type: A.InitWindow, timeUs: 0 })) : (u(!1), l(z.Ended), r.push({ type: A.CancelRaf }), r.push({ type: A.StopAudio }), p(0), r.push({
|
|
13131
|
+
type: A.Emit,
|
|
13132
|
+
event: O.PlaybackEnded,
|
|
13109
13133
|
payload: { timeUs: e.durationUs }
|
|
13110
|
-
})), { token: this.token, commands: r }) : (p(
|
|
13111
|
-
type:
|
|
13112
|
-
event:
|
|
13113
|
-
payload: { timeUs:
|
|
13134
|
+
})), { token: this.token, commands: r }) : (p(y), r.push({
|
|
13135
|
+
type: A.Emit,
|
|
13136
|
+
event: O.PlaybackTimeUpdate,
|
|
13137
|
+
payload: { timeUs: y }
|
|
13114
13138
|
}), { token: this.token, commands: r });
|
|
13115
13139
|
}
|
|
13116
13140
|
}
|
|
@@ -13183,17 +13207,17 @@ class Ko {
|
|
|
13183
13207
|
}
|
|
13184
13208
|
setRate(e) {
|
|
13185
13209
|
const s = this.currentTimeUs;
|
|
13186
|
-
this.playbackRate = e, this.startTimeUs = this.audioContext.currentTime * 1e6 - s / e, this.audioSession.setPlaybackRate(this.playbackRate), this.eventBus.emit(
|
|
13210
|
+
this.playbackRate = e, this.startTimeUs = this.audioContext.currentTime * 1e6 - s / e, this.audioSession.setPlaybackRate(this.playbackRate), this.eventBus.emit(O.PlaybackRateChange, { rate: e });
|
|
13187
13211
|
}
|
|
13188
13212
|
setVolume(e) {
|
|
13189
|
-
this.volume = Math.max(0, Math.min(1, e)), this.audioSession.setVolume(this.volume), this.eventBus.emit(
|
|
13213
|
+
this.volume = Math.max(0, Math.min(1, e)), this.audioSession.setVolume(this.volume), this.eventBus.emit(O.PlaybackVolumeChange, { volume: this.volume });
|
|
13190
13214
|
}
|
|
13191
13215
|
setMute(e) {
|
|
13192
13216
|
if (e) {
|
|
13193
13217
|
this.audioSession.stopPlayback();
|
|
13194
13218
|
return;
|
|
13195
13219
|
}
|
|
13196
|
-
this.fsm.snapshot.state ===
|
|
13220
|
+
this.fsm.snapshot.state === z.Playing && this.audioSession.startPlayback(this.currentTimeUs, this.audioContext);
|
|
13197
13221
|
}
|
|
13198
13222
|
setLoop(e) {
|
|
13199
13223
|
this.loop = e;
|
|
@@ -13202,7 +13226,7 @@ class Ko {
|
|
|
13202
13226
|
return this.orchestrator.compositionModel?.durationUs ?? 0;
|
|
13203
13227
|
}
|
|
13204
13228
|
get isPlaying() {
|
|
13205
|
-
return this.fsm.snapshot.state ===
|
|
13229
|
+
return this.fsm.snapshot.state === z.Playing;
|
|
13206
13230
|
}
|
|
13207
13231
|
resume() {
|
|
13208
13232
|
this.play();
|
|
@@ -13242,18 +13266,18 @@ class Ko {
|
|
|
13242
13266
|
executeCommand(e, s) {
|
|
13243
13267
|
if (this.isCurrentToken(s))
|
|
13244
13268
|
switch (e.type) {
|
|
13245
|
-
case
|
|
13269
|
+
case A.Seq:
|
|
13246
13270
|
return this.executeSeq(e.commands, s, 0);
|
|
13247
|
-
case
|
|
13271
|
+
case A.Par:
|
|
13248
13272
|
return this.executePar(e.commands, s);
|
|
13249
|
-
case
|
|
13273
|
+
case A.Try: {
|
|
13250
13274
|
const r = (h) => {
|
|
13251
13275
|
if (!this.isCurrentToken(s) || e.ignoreWaiterReplacedError && h instanceof Ni) return;
|
|
13252
13276
|
e.logPrefix && console.error(e.logPrefix, h);
|
|
13253
13277
|
const l = e.onError ? this.dispatch(e.onError).done : void 0, u = (p) => p instanceof Error ? p : new Error(typeof p == "string" ? p : JSON.stringify(p)), o = () => {
|
|
13254
13278
|
if (e.emitPlaybackError) {
|
|
13255
13279
|
const p = u(h);
|
|
13256
|
-
this.eventBus.emit(
|
|
13280
|
+
this.eventBus.emit(O.PlaybackError, p), this.eventBus.emit(O.Error, {
|
|
13257
13281
|
source: "playback",
|
|
13258
13282
|
error: p,
|
|
13259
13283
|
context: {
|
|
@@ -13277,66 +13301,66 @@ class Ko {
|
|
|
13277
13301
|
return r(h) ?? Promise.resolve();
|
|
13278
13302
|
}
|
|
13279
13303
|
}
|
|
13280
|
-
case
|
|
13304
|
+
case A.Dispatch:
|
|
13281
13305
|
return this.dispatch(e.action).done;
|
|
13282
|
-
case
|
|
13306
|
+
case A.SetTime: {
|
|
13283
13307
|
this.currentTimeUs = e.timeUs;
|
|
13284
13308
|
return;
|
|
13285
13309
|
}
|
|
13286
|
-
case
|
|
13287
|
-
case
|
|
13288
|
-
case
|
|
13310
|
+
case A.SetFrozenTime:
|
|
13311
|
+
case A.SetWantsPlay:
|
|
13312
|
+
case A.SetState:
|
|
13289
13313
|
return;
|
|
13290
|
-
case
|
|
13314
|
+
case A.CancelRaf: {
|
|
13291
13315
|
this.cancelRaf();
|
|
13292
13316
|
return;
|
|
13293
13317
|
}
|
|
13294
|
-
case
|
|
13318
|
+
case A.StopAudio: {
|
|
13295
13319
|
this.audioSession.stopPlayback();
|
|
13296
13320
|
return;
|
|
13297
13321
|
}
|
|
13298
|
-
case
|
|
13322
|
+
case A.ResetAudioPlaybackStates: {
|
|
13299
13323
|
this.audioSession.resetPlaybackStates();
|
|
13300
13324
|
return;
|
|
13301
13325
|
}
|
|
13302
|
-
case
|
|
13326
|
+
case A.ResetAudioSession: {
|
|
13303
13327
|
this.audioSession.reset();
|
|
13304
13328
|
return;
|
|
13305
13329
|
}
|
|
13306
|
-
case
|
|
13330
|
+
case A.ClearCanvas: {
|
|
13307
13331
|
this.clearCanvas();
|
|
13308
13332
|
return;
|
|
13309
13333
|
}
|
|
13310
|
-
case
|
|
13334
|
+
case A.SetLastAudioScheduleTime: {
|
|
13311
13335
|
this.lastAudioScheduleTime = e.timeUs;
|
|
13312
13336
|
return;
|
|
13313
13337
|
}
|
|
13314
|
-
case
|
|
13338
|
+
case A.SetStartTimeBase: {
|
|
13315
13339
|
this.startTimeUs = e.startTimeUs;
|
|
13316
13340
|
return;
|
|
13317
13341
|
}
|
|
13318
|
-
case
|
|
13342
|
+
case A.SyncTimeBaseToAudioClock: {
|
|
13319
13343
|
this.startTimeUs = this.audioContext.currentTime * 1e6 - e.timeUs / this.playbackRate;
|
|
13320
13344
|
return;
|
|
13321
13345
|
}
|
|
13322
|
-
case
|
|
13346
|
+
case A.InitWindow: {
|
|
13323
13347
|
this.initWindow(e.timeUs);
|
|
13324
13348
|
return;
|
|
13325
13349
|
}
|
|
13326
|
-
case
|
|
13350
|
+
case A.SetCacheWindow: {
|
|
13327
13351
|
this.orchestrator.cacheManager.setWindow(e.timeUs);
|
|
13328
13352
|
return;
|
|
13329
13353
|
}
|
|
13330
|
-
case
|
|
13354
|
+
case A.Emit: {
|
|
13331
13355
|
e.payload === void 0 ? this.eventBus.emit(e.event) : this.eventBus.emit(e.event, e.payload);
|
|
13332
13356
|
return;
|
|
13333
13357
|
}
|
|
13334
|
-
case
|
|
13358
|
+
case A.RenderFrame:
|
|
13335
13359
|
return this.renderCurrentFrame(e.timeUs, {
|
|
13336
13360
|
mode: e.mode,
|
|
13337
13361
|
relativeTimeUs: e.relativeTimeUs
|
|
13338
13362
|
});
|
|
13339
|
-
case
|
|
13363
|
+
case A.MaybeRenderKeyframePreview:
|
|
13340
13364
|
return this.orchestrator.tryRenderKeyframe(e.timeUs).then((r) => {
|
|
13341
13365
|
if (this.isCurrentToken(s) && r !== null)
|
|
13342
13366
|
return this.orchestrator.getRenderState(e.timeUs, {
|
|
@@ -13347,18 +13371,18 @@ class Ko {
|
|
|
13347
13371
|
return this.compose(e.timeUs, h);
|
|
13348
13372
|
});
|
|
13349
13373
|
});
|
|
13350
|
-
case
|
|
13374
|
+
case A.EnsureAudio:
|
|
13351
13375
|
return this.audioSession.ensureAudioForTime(e.timeUs, {
|
|
13352
13376
|
mode: e.mode
|
|
13353
13377
|
});
|
|
13354
|
-
case
|
|
13378
|
+
case A.GetFrame:
|
|
13355
13379
|
return this.orchestrator.getFrame(e.timeUs, {
|
|
13356
13380
|
mode: e.mode,
|
|
13357
13381
|
preheat: e.preheat
|
|
13358
13382
|
});
|
|
13359
|
-
case
|
|
13383
|
+
case A.StartAudioPlayback:
|
|
13360
13384
|
return this.audioSession.startPlayback(e.timeUs, this.audioContext);
|
|
13361
|
-
case
|
|
13385
|
+
case A.ProbeStartReady: {
|
|
13362
13386
|
const r = this.audioSession.isPreviewMixBlockCached(e.timeUs), h = this.isVideoResourceReadyAtTime(e.timeUs);
|
|
13363
13387
|
if (r && h) return;
|
|
13364
13388
|
r || this.audioSession.ensureAudioForTime(e.timeUs, { mode: "probe" }), h || this.orchestrator.getFrame(e.timeUs, { mode: "probe" }), this.dispatch({
|
|
@@ -13369,7 +13393,7 @@ class Ko {
|
|
|
13369
13393
|
});
|
|
13370
13394
|
return;
|
|
13371
13395
|
}
|
|
13372
|
-
case
|
|
13396
|
+
case A.StartRafLoop: {
|
|
13373
13397
|
this.startPlaybackLoop(s);
|
|
13374
13398
|
return;
|
|
13375
13399
|
}
|
|
@@ -13387,7 +13411,7 @@ class Ko {
|
|
|
13387
13411
|
});
|
|
13388
13412
|
}
|
|
13389
13413
|
async onRafTick(e) {
|
|
13390
|
-
if (!this.isCurrentToken(e) || this.fsm.snapshot.state !==
|
|
13414
|
+
if (!this.isCurrentToken(e) || this.fsm.snapshot.state !== z.Playing)
|
|
13391
13415
|
return;
|
|
13392
13416
|
const s = (this.audioContext.currentTime * 1e6 - this.startTimeUs) * this.playbackRate;
|
|
13393
13417
|
if (this.dispatch({
|
|
@@ -13396,7 +13420,7 @@ class Ko {
|
|
|
13396
13420
|
durationUs: this.duration,
|
|
13397
13421
|
loop: this.loop,
|
|
13398
13422
|
audioNowUs: this.audioContext.currentTime * 1e6
|
|
13399
|
-
}), !this.isCurrentToken(e) || this.fsm.snapshot.state !==
|
|
13423
|
+
}), !this.isCurrentToken(e) || this.fsm.snapshot.state !== z.Playing)
|
|
13400
13424
|
return;
|
|
13401
13425
|
if (this.currentTimeUs - this.lastAudioScheduleTime >= this.AUDIO_SCHEDULE_INTERVAL && (this.audioSession.scheduleAudio(this.currentTimeUs, this.audioContext), this.lastAudioScheduleTime = this.currentTimeUs), this.audioSession.shouldEnterBufferingForUpcomingPreviewAudio(this.currentTimeUs)) {
|
|
13402
13426
|
this.audioSession.ensureAudioForTime(this.currentTimeUs, { mode: "probe" }), this.dispatch({
|
|
@@ -13409,12 +13433,12 @@ class Ko {
|
|
|
13409
13433
|
const r = await this.orchestrator.getRenderState(this.currentTimeUs, {
|
|
13410
13434
|
mode: "probe"
|
|
13411
13435
|
});
|
|
13412
|
-
if (!(!this.isCurrentToken(e) || this.fsm.snapshot.state !==
|
|
13436
|
+
if (!(!this.isCurrentToken(e) || this.fsm.snapshot.state !== z.Playing)) {
|
|
13413
13437
|
if (!r) {
|
|
13414
13438
|
this.dispatch({ type: $.EnterBuffering, timeUs: this.currentTimeUs });
|
|
13415
13439
|
return;
|
|
13416
13440
|
}
|
|
13417
|
-
await this.compose(this.currentTimeUs, r), !(!this.isCurrentToken(e) || this.fsm.snapshot.state !==
|
|
13441
|
+
await this.compose(this.currentTimeUs, r), !(!this.isCurrentToken(e) || this.fsm.snapshot.state !== z.Playing) && (this.updateFps(), this.frameCount++, this.orchestrator.cacheManager.setWindow(this.currentTimeUs), this.checkAndPreheatWindow(), !(!this.isCurrentToken(e) || this.fsm.snapshot.state !== z.Playing) && this.startPlaybackLoop(e));
|
|
13418
13442
|
}
|
|
13419
13443
|
}
|
|
13420
13444
|
updateFps() {
|
|
@@ -13429,7 +13453,7 @@ class Ko {
|
|
|
13429
13453
|
this.windowEnd = e + this.WINDOW_DURATION, this.preheatInProgress = !1, this.orchestrator.cacheManager.setWindow(e);
|
|
13430
13454
|
}
|
|
13431
13455
|
checkAndPreheatWindow() {
|
|
13432
|
-
if (this.orchestrator.cacheManager.isExporting || this.preheatInProgress || this.fsm.snapshot.state !==
|
|
13456
|
+
if (this.orchestrator.cacheManager.isExporting || this.preheatInProgress || this.fsm.snapshot.state !== z.Playing)
|
|
13433
13457
|
return;
|
|
13434
13458
|
const e = this.windowEnd - this.currentTimeUs;
|
|
13435
13459
|
if (e < 0) {
|
|
@@ -13482,10 +13506,10 @@ class Ko {
|
|
|
13482
13506
|
}
|
|
13483
13507
|
// ========= Cleanup / event handlers =========
|
|
13484
13508
|
dispose() {
|
|
13485
|
-
this.stop(), this.eventBus.off(
|
|
13509
|
+
this.stop(), this.eventBus.off(O.CacheCover, this.onCacheCover), this.eventBus.off(O.ModelSet, this.onModelSet), this.videoComposer && (this.videoComposer.dispose(), this.videoComposer = null);
|
|
13486
13510
|
}
|
|
13487
13511
|
onCacheCover = () => {
|
|
13488
|
-
this.fsm.snapshot.state ===
|
|
13512
|
+
this.fsm.snapshot.state === z.Idle && this.currentTimeUs === 0 && this.renderCurrentFrame(0, { mode: "blocking" });
|
|
13489
13513
|
};
|
|
13490
13514
|
onModelSet = () => {
|
|
13491
13515
|
if (!this.videoComposer || !this.orchestrator.compositionModel) return;
|
|
@@ -13499,7 +13523,7 @@ class Ko {
|
|
|
13499
13523
|
}), this.orchestrator.cacheManager.isExporting || this.audioSession.ensureAudioForTime(this.currentTimeUs, { mode: "probe" }), this.renderCurrentFrame(this.currentTimeUs, { mode: "blocking" });
|
|
13500
13524
|
};
|
|
13501
13525
|
setupEventListeners() {
|
|
13502
|
-
this.eventBus.on(
|
|
13526
|
+
this.eventBus.on(O.CacheCover, this.onCacheCover), this.eventBus.on(O.ModelSet, this.onModelSet);
|
|
13503
13527
|
}
|
|
13504
13528
|
isVideoResourceReadyAtTime(e) {
|
|
13505
13529
|
const s = this.orchestrator.compositionModel;
|
|
@@ -13622,7 +13646,7 @@ class wi {
|
|
|
13622
13646
|
return Ei();
|
|
13623
13647
|
}
|
|
13624
13648
|
constructor(e) {
|
|
13625
|
-
this.config = e, this.eventBus = new
|
|
13649
|
+
this.config = e, this.eventBus = new Di(), this.events = this.eventBus.asReadonly(), this.pluginManager = new Xo(this), this.orchestrator = new Mo({
|
|
13626
13650
|
projectId: e.global.projectId,
|
|
13627
13651
|
maxWorkers: e.maxWorkers,
|
|
13628
13652
|
cacheConfig: e.cache,
|
|
@@ -13638,7 +13662,7 @@ class wi {
|
|
|
13638
13662
|
const s = Ei();
|
|
13639
13663
|
if (!s.webCodecsAvailable || !s.opfsAvailable)
|
|
13640
13664
|
throw new _r(s);
|
|
13641
|
-
const r = await
|
|
13665
|
+
const r = await Ds({ override: e }), h = new wi(r);
|
|
13642
13666
|
return await h.initialize(), h;
|
|
13643
13667
|
}
|
|
13644
13668
|
/**
|
|
@@ -13663,7 +13687,7 @@ class wi {
|
|
|
13663
13687
|
async setCompositionModel(e) {
|
|
13664
13688
|
this.ensureNotDestroyed(), this.playbackController?.pause();
|
|
13665
13689
|
const s = e instanceof vi ? e : new vi(e);
|
|
13666
|
-
await this.orchestrator.setCompositionModel(s), this.model = s, this.setState("ready"), this.eventBus.emit(
|
|
13690
|
+
await this.orchestrator.setCompositionModel(s), this.model = s, this.setState("ready"), this.eventBus.emit(O.Ready, {
|
|
13667
13691
|
trackCount: e.tracks.length,
|
|
13668
13692
|
clipCount: e.tracks.reduce(
|
|
13669
13693
|
(r, h) => r + h.clips?.length || 0,
|
|
@@ -13798,9 +13822,9 @@ async function Zo() {
|
|
|
13798
13822
|
if (typeof globalThis.VideoEncoder != "function")
|
|
13799
13823
|
throw new Error("WebCodecs VideoEncoder is not available in this browser context");
|
|
13800
13824
|
console.log("[meframe-runner] creating meframe...");
|
|
13801
|
-
const l = (
|
|
13802
|
-
if (
|
|
13803
|
-
return
|
|
13825
|
+
const l = (w) => {
|
|
13826
|
+
if (w)
|
|
13827
|
+
return w.replace(/\/+$/, "");
|
|
13804
13828
|
}, u = await wi.create({
|
|
13805
13829
|
global: {
|
|
13806
13830
|
workerPath: l(h)
|
|
@@ -13810,103 +13834,111 @@ async function Zo() {
|
|
|
13810
13834
|
let o = 0;
|
|
13811
13835
|
const p = new AbortController();
|
|
13812
13836
|
window.__serverAbort = () => p.abort();
|
|
13813
|
-
const m = (
|
|
13814
|
-
setTimeout(
|
|
13815
|
-
}),
|
|
13816
|
-
let
|
|
13817
|
-
return
|
|
13818
|
-
},
|
|
13819
|
-
if (
|
|
13820
|
-
|
|
13821
|
-
let
|
|
13822
|
-
for (let
|
|
13823
|
-
const
|
|
13824
|
-
if (
|
|
13825
|
-
|
|
13837
|
+
const m = (w) => new Promise((C) => {
|
|
13838
|
+
setTimeout(C, w);
|
|
13839
|
+
}), y = (w) => w === 429 || w >= 500 && w <= 599, v = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Map(), x = (w) => {
|
|
13840
|
+
let C = v.get(w);
|
|
13841
|
+
return C || (C = { buf: new Uint8Array(r), ranges: [], uploaded: !1 }, v.set(w, C)), C;
|
|
13842
|
+
}, b = (w, C, U) => {
|
|
13843
|
+
if (U <= C) return;
|
|
13844
|
+
w.push({ start: C, end: U }), w.sort((I, P) => I.start - P.start);
|
|
13845
|
+
let E = 0;
|
|
13846
|
+
for (let I = 0; I < w.length; I++) {
|
|
13847
|
+
const P = w[I];
|
|
13848
|
+
if (E === 0) {
|
|
13849
|
+
w[E++] = P;
|
|
13826
13850
|
continue;
|
|
13827
13851
|
}
|
|
13828
|
-
const
|
|
13829
|
-
|
|
13830
|
-
}
|
|
13831
|
-
|
|
13832
|
-
},
|
|
13833
|
-
if (
|
|
13834
|
-
if (
|
|
13835
|
-
let
|
|
13836
|
-
if (
|
|
13837
|
-
for (let
|
|
13838
|
-
const
|
|
13839
|
-
if (
|
|
13852
|
+
const B = w[E - 1];
|
|
13853
|
+
P.start <= B.end ? B.end = Math.max(B.end, P.end) : w[E++] = P;
|
|
13854
|
+
}
|
|
13855
|
+
w.length = E;
|
|
13856
|
+
}, T = (w, C) => {
|
|
13857
|
+
if (C <= 0) return !0;
|
|
13858
|
+
if (w.length === 0) return !1;
|
|
13859
|
+
let U = w[0].start === 0 ? w[0].end : 0;
|
|
13860
|
+
if (U === 0) return !1;
|
|
13861
|
+
for (let E = 1; E < w.length && U < C; E++) {
|
|
13862
|
+
const I = w[E];
|
|
13863
|
+
if (I.start > U)
|
|
13840
13864
|
return !1;
|
|
13841
|
-
|
|
13865
|
+
U = Math.max(U, I.end);
|
|
13842
13866
|
}
|
|
13843
|
-
return
|
|
13844
|
-
},
|
|
13845
|
-
for (let
|
|
13867
|
+
return U >= C;
|
|
13868
|
+
}, t = async (w, C) => {
|
|
13869
|
+
for (let E = 1; E <= 4; E++) {
|
|
13846
13870
|
if (p.signal.aborted)
|
|
13847
13871
|
throw new DOMException("Export aborted", "AbortError");
|
|
13848
|
-
const { url:
|
|
13872
|
+
const { url: I, headers: P } = await window.runnerRequestPartUrl(C), B = new Blob(w, { type: "application/octet-stream" });
|
|
13849
13873
|
try {
|
|
13850
|
-
const
|
|
13874
|
+
const R = await fetch(I, {
|
|
13851
13875
|
method: "PUT",
|
|
13852
|
-
body:
|
|
13853
|
-
headers:
|
|
13876
|
+
body: B,
|
|
13877
|
+
headers: P ?? {},
|
|
13854
13878
|
signal: p.signal
|
|
13855
13879
|
});
|
|
13856
|
-
if (!
|
|
13857
|
-
if (
|
|
13858
|
-
const
|
|
13859
|
-
await m(
|
|
13880
|
+
if (!R.ok) {
|
|
13881
|
+
if (E < 4 && y(R.status)) {
|
|
13882
|
+
const j = Math.min(8e3, 250 * 2 ** (E - 1));
|
|
13883
|
+
await m(j);
|
|
13860
13884
|
continue;
|
|
13861
13885
|
}
|
|
13862
|
-
throw new Error(`UploadPart failed: HTTP ${
|
|
13886
|
+
throw new Error(`UploadPart failed: HTTP ${R.status}`);
|
|
13863
13887
|
}
|
|
13864
|
-
const
|
|
13865
|
-
if (!
|
|
13888
|
+
const L = R.headers.get("etag") || R.headers.get("ETag");
|
|
13889
|
+
if (!L)
|
|
13866
13890
|
throw new Error("UploadPart missing ETag header");
|
|
13867
|
-
await window.runnerReportPartDone(
|
|
13891
|
+
await window.runnerReportPartDone(C, L);
|
|
13868
13892
|
return;
|
|
13869
|
-
} catch (
|
|
13870
|
-
if (
|
|
13871
|
-
throw
|
|
13872
|
-
if (
|
|
13873
|
-
const
|
|
13874
|
-
await m(
|
|
13893
|
+
} catch (R) {
|
|
13894
|
+
if (R instanceof DOMException && R.name === "AbortError")
|
|
13895
|
+
throw R;
|
|
13896
|
+
if (E < 4) {
|
|
13897
|
+
const L = Math.min(8e3, 250 * 2 ** (E - 1));
|
|
13898
|
+
await m(L);
|
|
13875
13899
|
continue;
|
|
13876
13900
|
}
|
|
13877
|
-
throw
|
|
13901
|
+
throw R;
|
|
13878
13902
|
}
|
|
13879
13903
|
}
|
|
13880
13904
|
};
|
|
13881
|
-
let
|
|
13882
|
-
const
|
|
13883
|
-
|
|
13884
|
-
|
|
13885
|
-
|
|
13886
|
-
|
|
13887
|
-
|
|
13905
|
+
let n = Promise.resolve(), c = !1;
|
|
13906
|
+
const d = (w, C) => {
|
|
13907
|
+
if (w === 1 && !c) return;
|
|
13908
|
+
const U = k.get(w);
|
|
13909
|
+
if (U !== void 0) {
|
|
13910
|
+
k.set(w, Math.max(U, C));
|
|
13911
|
+
return;
|
|
13912
|
+
}
|
|
13913
|
+
k.set(w, C), n = n.then(async () => {
|
|
13914
|
+
const E = k.get(w);
|
|
13915
|
+
if (k.delete(w), E === void 0) return;
|
|
13916
|
+
const I = v.get(w);
|
|
13917
|
+
if (!I || I.uploaded || !T(I.ranges, E)) return;
|
|
13918
|
+
const P = I.buf.subarray(0, E);
|
|
13919
|
+
await t([P], w), I.uploaded = !0, v.delete(w);
|
|
13888
13920
|
});
|
|
13889
|
-
},
|
|
13890
|
-
o = Math.max(o,
|
|
13891
|
-
let
|
|
13892
|
-
for (;
|
|
13893
|
-
const
|
|
13894
|
-
|
|
13921
|
+
}, f = (w, C) => {
|
|
13922
|
+
o = Math.max(o, C + w.byteLength);
|
|
13923
|
+
let U = w, E = C;
|
|
13924
|
+
for (; U.byteLength > 0; ) {
|
|
13925
|
+
const I = Math.floor(E / r) + 1, P = E % r, B = Math.min(r - P, U.byteLength), R = x(I);
|
|
13926
|
+
R.buf.set(U.subarray(0, B), P), b(R.ranges, P, P + B), d(I, r), U = U.subarray(B), E += B;
|
|
13895
13927
|
}
|
|
13896
13928
|
};
|
|
13897
|
-
let
|
|
13898
|
-
if (u.events.on(
|
|
13899
|
-
window.runnerReportProgress(
|
|
13900
|
-
const
|
|
13901
|
-
|
|
13902
|
-
}), u.events.on(
|
|
13903
|
-
console.log("[meframe-runner] export:start",
|
|
13904
|
-
}), u.events.on(
|
|
13905
|
-
console.log("[meframe-runner] export:complete",
|
|
13929
|
+
let g = 0;
|
|
13930
|
+
if (u.events.on(O.ExportProgress, (w) => {
|
|
13931
|
+
window.runnerReportProgress(w);
|
|
13932
|
+
const C = Date.now();
|
|
13933
|
+
C - g >= 1e3 && (g = C, console.log("[meframe-runner] progress", w));
|
|
13934
|
+
}), u.events.on(O.ExportStart, (w) => {
|
|
13935
|
+
console.log("[meframe-runner] export:start", w);
|
|
13936
|
+
}), u.events.on(O.ExportComplete, (w) => {
|
|
13937
|
+
console.log("[meframe-runner] export:complete", w);
|
|
13906
13938
|
}), console.log("[meframe-runner] export()..."), await u.export({
|
|
13907
13939
|
...s,
|
|
13908
13940
|
exportMode: "stream",
|
|
13909
|
-
onMuxData:
|
|
13941
|
+
onMuxData: f,
|
|
13910
13942
|
// IMPORTANT:
|
|
13911
13943
|
// mp4-muxer@5.2.2 StreamTarget "chunked" mode buffers into fixed-size chunks and only emits
|
|
13912
13944
|
// when a whole chunk is filled (or on finalize). With our current muxing pattern (seek+patch),
|
|
@@ -13919,14 +13951,15 @@ async function Zo() {
|
|
|
13919
13951
|
"[meframe-runner] stream mux produced 0 bytes. This indicates mp4-muxer StreamTarget did not emit any data."
|
|
13920
13952
|
);
|
|
13921
13953
|
console.log("[meframe-runner] finalize: flushing parts...");
|
|
13922
|
-
const
|
|
13923
|
-
|
|
13924
|
-
for (let
|
|
13925
|
-
const
|
|
13926
|
-
|
|
13954
|
+
const _ = Math.ceil(o / r);
|
|
13955
|
+
c = !0;
|
|
13956
|
+
for (let w = 1; w <= _; w++) {
|
|
13957
|
+
const C = w === _ ? o - (_ - 1) * r : r;
|
|
13958
|
+
d(w, C);
|
|
13927
13959
|
}
|
|
13928
|
-
await
|
|
13960
|
+
await n, console.log("[meframe-runner] done", { totalBytes: o }), await window.runnerReportComplete(o);
|
|
13929
13961
|
}
|
|
13930
13962
|
Zo().catch(async (a) => {
|
|
13931
|
-
await window.runnerReportError(a?.message ?? String(a))
|
|
13963
|
+
await window.runnerReportError(a?.message ?? String(a)).catch(() => {
|
|
13964
|
+
});
|
|
13932
13965
|
});
|