@mediabunny/mp3-encoder 1.25.6 → 1.25.7
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/dist/bundles/mediabunny-mp3-encoder.js +5 -1
- package/dist/bundles/mediabunny-mp3-encoder.min.js +1 -1
- package/dist/bundles/mediabunny-mp3-encoder.min.mjs +1 -1
- package/dist/bundles/mediabunny-mp3-encoder.mjs +5 -1
- package/dist/modules/src/index.d.ts.map +1 -1
- package/dist/modules/src/index.js +6 -1
- package/package.json +1 -1
- package/src/index.ts +8 -1
|
@@ -323,7 +323,7 @@ var MediabunnyMp3Encoder = (() => {
|
|
|
323
323
|
this.pendingMessages = /* @__PURE__ */ new Map();
|
|
324
324
|
this.buffer = new Uint8Array(2 ** 16);
|
|
325
325
|
this.currentBufferOffset = 0;
|
|
326
|
-
this.currentTimestamp =
|
|
326
|
+
this.currentTimestamp = null;
|
|
327
327
|
this.chunkMetadata = {};
|
|
328
328
|
}
|
|
329
329
|
static supports(codec, config) {
|
|
@@ -367,6 +367,9 @@ var MediabunnyMp3Encoder = (() => {
|
|
|
367
367
|
};
|
|
368
368
|
}
|
|
369
369
|
async encode(audioSample) {
|
|
370
|
+
if (this.currentTimestamp === null) {
|
|
371
|
+
this.currentTimestamp = audioSample.timestamp;
|
|
372
|
+
}
|
|
370
373
|
const sizePerChannel = audioSample.allocationSize({
|
|
371
374
|
format: "s16-planar",
|
|
372
375
|
planeIndex: 0
|
|
@@ -404,6 +407,7 @@ var MediabunnyMp3Encoder = (() => {
|
|
|
404
407
|
* these chunks and extract the MP3 frames only when they're complete.
|
|
405
408
|
*/
|
|
406
409
|
digestOutput(bytes) {
|
|
410
|
+
assert(this.currentTimestamp !== null);
|
|
407
411
|
const requiredBufferSize = this.currentBufferOffset + bytes.length;
|
|
408
412
|
if (requiredBufferSize > this.buffer.length) {
|
|
409
413
|
const newSize = 1 << Math.ceil(Math.log2(requiredBufferSize));
|