webcodecs-utils 0.2.4 → 0.2.6
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 +142 -0
- package/dist/audio/extract-channels.d.ts +45 -0
- package/dist/audio/extract-channels.d.ts.map +1 -0
- package/dist/audio/extract-channels.js +25 -0
- package/dist/audio/get-sample-rate.d.ts +19 -0
- package/dist/audio/get-sample-rate.d.ts.map +1 -0
- package/dist/audio/get-sample-rate.js +14 -0
- package/dist/audio/mp3.d.ts +162 -0
- package/dist/audio/mp3.d.ts.map +1 -0
- package/dist/audio/mp3.js +173 -0
- package/dist/demux/example-muxer.d.ts +74 -0
- package/dist/demux/example-muxer.d.ts.map +1 -0
- package/dist/demux/example-muxer.js +40 -0
- package/dist/demux/get-chunks.d.ts +81 -0
- package/dist/demux/get-chunks.d.ts.map +1 -0
- package/dist/demux/get-chunks.js +88 -0
- package/dist/demux/mp4-demuxer.d.ts +84 -0
- package/dist/demux/mp4-demuxer.d.ts.map +1 -0
- package/dist/demux/mp4-demuxer.js +215 -0
- package/dist/demux/simple-demuxer.d.ts +49 -0
- package/dist/demux/simple-demuxer.d.ts.map +1 -0
- package/dist/demux/simple-demuxer.js +87 -0
- package/dist/in-memory-storage.d.ts +30 -0
- package/dist/in-memory-storage.d.ts.map +1 -0
- package/dist/in-memory-storage.js +54 -0
- package/dist/index.cjs +5 -298
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -13873
- package/dist/mux/simple-muxer.d.ts +47 -0
- package/dist/mux/simple-muxer.d.ts.map +1 -0
- package/dist/mux/simple-muxer.js +83 -0
- package/dist/polyfills/media-stream-track-processor.d.ts +5 -0
- package/dist/polyfills/media-stream-track-processor.d.ts.map +1 -0
- package/dist/polyfills/media-stream-track-processor.js +109 -0
- package/dist/streams/video-decode-stream.d.ts +11 -0
- package/dist/streams/video-decode-stream.d.ts.map +1 -0
- package/dist/streams/video-decode-stream.js +39 -0
- package/dist/streams/video-encode-stream.d.ts +15 -0
- package/dist/streams/video-encode-stream.d.ts.map +1 -0
- package/dist/streams/video-encode-stream.js +40 -0
- package/dist/streams/video-process-stream.d.ts +22 -0
- package/dist/streams/video-process-stream.d.ts.map +1 -0
- package/dist/streams/video-process-stream.js +21 -0
- package/dist/video/get-bitrate.d.ts +35 -0
- package/dist/video/get-bitrate.d.ts.map +1 -0
- package/dist/video/get-bitrate.js +12 -0
- package/dist/video/get-codec-string.d.ts +46 -0
- package/dist/video/get-codec-string.d.ts.map +1 -0
- package/dist/video/get-codec-string.js +195 -0
- package/dist/video/gpu-renderer.d.ts +108 -0
- package/dist/video/gpu-renderer.d.ts.map +1 -0
- package/dist/video/gpu-renderer.js +266 -0
- package/package.json +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
class _ {
|
|
2
|
+
/**
|
|
3
|
+
* Create a new InMemoryStorage instance
|
|
4
|
+
* @param chunkSize Size of each chunk in bytes (default: 10MB)
|
|
5
|
+
*/
|
|
6
|
+
constructor(s = 10 * 1024 * 1024) {
|
|
7
|
+
this.chunks = /* @__PURE__ */ new Map(), this._size = 0, this._chunkSize = s;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Write data to storage, handling overlaps efficiently
|
|
11
|
+
* @param data Data to write
|
|
12
|
+
* @param position Position to write at
|
|
13
|
+
*/
|
|
14
|
+
write(s, e) {
|
|
15
|
+
this._size = Math.max(this._size, e + s.byteLength);
|
|
16
|
+
const h = Math.floor(e / this._chunkSize), u = Math.floor((e + s.byteLength - 1) / this._chunkSize);
|
|
17
|
+
for (let t = h; t <= u; t++) {
|
|
18
|
+
const n = t * this._chunkSize, i = n + this._chunkSize, c = Math.max(e, n), k = Math.min(e + s.byteLength, i) - c;
|
|
19
|
+
if (k <= 0) continue;
|
|
20
|
+
let o;
|
|
21
|
+
this.chunks.has(t) ? o = this.chunks.get(t) : (o = new Uint8Array(this._chunkSize), this.chunks.set(t, o));
|
|
22
|
+
const l = c - n, a = c - e;
|
|
23
|
+
for (let r = 0; r < k; r++)
|
|
24
|
+
o[l + r] = s[a + r];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get the total size of data written
|
|
29
|
+
*/
|
|
30
|
+
get size() {
|
|
31
|
+
return this._size;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Convert all stored chunks to a single Blob
|
|
35
|
+
* @param type MIME type for the Blob
|
|
36
|
+
*/
|
|
37
|
+
toBlob(s = "application/octet-stream") {
|
|
38
|
+
if (this.chunks.size === 0)
|
|
39
|
+
return new Blob([], { type: s });
|
|
40
|
+
const e = Array.from(this.chunks.keys()).sort((t, n) => t - n), h = [];
|
|
41
|
+
for (let t = 0; t < e.length; t++) {
|
|
42
|
+
const n = e[t], i = this.chunks.get(n);
|
|
43
|
+
if (t === e.length - 1) {
|
|
44
|
+
const c = this._size - n * this._chunkSize;
|
|
45
|
+
c < this._chunkSize ? h.push(i.slice(0, c)) : h.push(i);
|
|
46
|
+
} else
|
|
47
|
+
h.push(i);
|
|
48
|
+
}
|
|
49
|
+
return new Blob(h, { type: s });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
_ as InMemoryStorage
|
|
54
|
+
};
|