diff --git a/dev/convert.html b/dev/convert.html
index 7dd4124..094ed90 100644
--- a/dev/convert.html
+++ b/dev/convert.html
@@ -24,9 +24,7 @@
chunked: true,
chunkSize: 2**20
});
- const outputFormat = new Mediabunny.AdtsOutputFormat({
- onFrame: console.log
- });
+ const outputFormat = new Mediabunny.Mp4OutputFormat({});
const button = document.createElement('button');
button.textContent = 'Cancel';
diff --git a/dev/demux.html b/dev/demux.html
index eb8fce3..8391087 100644
--- a/dev/demux.html
+++ b/dev/demux.html
@@ -21,6 +21,8 @@
for await (const packet of sink.packets()) {
console.log(packet);
+
+ if (packet.timestamp > 135) break;
}
/*
diff --git a/package-lock.json b/package-lock.json
index dd43508..ed9eeb2 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "mediabunny",
- "version": "1.9.1",
+ "version": "1.9.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "mediabunny",
- "version": "1.9.1",
+ "version": "1.9.2",
"license": "MPL-2.0",
"workspaces": [
"packages/*"
@@ -5900,9 +5900,9 @@
}
},
"node_modules/mediabunny": {
- "version": "1.9.0",
- "resolved": "https://registry.npmjs.org/mediabunny/-/mediabunny-1.9.0.tgz",
- "integrity": "sha512-pNviaYemNRjrIbx1K1+Q1xcCbD1PRVp6i1+0GXJf5NPVeHUVJfJY2xkhtBjbd4LpbqCTqRoSPYxcrOmIRt14bw==",
+ "version": "1.9.1",
+ "resolved": "https://registry.npmjs.org/mediabunny/-/mediabunny-1.9.1.tgz",
+ "integrity": "sha512-DghqcYW2s8LsZ9kErFeZdm6308BEABYs8SkY1z3Y7v3LWgPNvBmkXk7Yt+EKcpEGEFjGgDGoTapOjrrrNh7dQA==",
"license": "MPL-2.0",
"peer": true,
"workspaces": [
@@ -9017,7 +9017,7 @@
},
"packages/mp3-encoder": {
"name": "@mediabunny/mp3-encoder",
- "version": "1.9.1",
+ "version": "1.9.2",
"license": "MPL-2.0",
"devDependencies": {
"@types/emscripten": "^1.40.1"
diff --git a/package.json b/package.json
index f958375..b49df22 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "mediabunny",
"author": "Vanilagy",
- "version": "1.9.1",
+ "version": "1.9.2",
"description": "Pure TypeScript media toolkit for reading, writing, and converting media files, directly in the browser.",
"type": "module",
"workspaces": [
diff --git a/packages/mp3-encoder/package.json b/packages/mp3-encoder/package.json
index 24c8fc3..f2de19e 100644
--- a/packages/mp3-encoder/package.json
+++ b/packages/mp3-encoder/package.json
@@ -1,7 +1,7 @@
{
"name": "@mediabunny/mp3-encoder",
"author": "Vanilagy",
- "version": "1.9.1",
+ "version": "1.9.2",
"description": "MP3 encoder extension for Mediabunny, based on LAME.",
"main": "./dist/bundles/mediabunny-mp3-encoder.mjs",
"module": "./dist/bundles/mediabunny-mp3-encoder.mjs",
diff --git a/src/adts/adts-muxer.ts b/src/adts/adts-muxer.ts
index 1c60fc7..395a998 100644
--- a/src/adts/adts-muxer.ts
+++ b/src/adts/adts-muxer.ts
@@ -50,6 +50,8 @@ export class AdtsMuxer extends Muxer {
const release = await this.mutex.acquire();
try {
+ this.validateAndNormalizeTimestamp(track, packet.timestamp, packet.type === 'key');
+
if (!this.audioSpecificConfig) {
validateAudioChunkMetadata(meta);
diff --git a/src/isobmff/isobmff-demuxer.ts b/src/isobmff/isobmff-demuxer.ts
index e5fb63c..0f6c7cb 100644
--- a/src/isobmff/isobmff-demuxer.ts
+++ b/src/isobmff/isobmff-demuxer.ts
@@ -291,14 +291,20 @@ export class IsobmffDemuxer extends Demuxer {
const lastWord = this.metadataReader.readU32();
const potentialMfraPos = sourceSize - lastWord;
- if (potentialMfraPos >= 0 && potentialMfraPos < sourceSize) {
- await this.metadataReader.reader.loadRange(potentialMfraPos, sourceSize);
+ if (potentialMfraPos >= 0 && potentialMfraPos <= sourceSize - MAX_BOX_HEADER_SIZE) {
+ // Load the header and a bit more, likely covering the entire box
+ await this.metadataReader.reader.loadRange(potentialMfraPos, potentialMfraPos + 2 ** 16);
this.metadataReader.pos = potentialMfraPos;
const boxInfo = this.metadataReader.readBoxHeader();
if (boxInfo.name === 'mfra') {
- // We found the mfra box, allowing for much better random access. Let's parse it:
+ // We found the mfra box, allowing for much better random access. Let's parse it.
+
+ await this.metadataReader.reader.loadRange(
+ potentialMfraPos,
+ potentialMfraPos + boxInfo.totalSize,
+ );
this.readContiguousBoxes(boxInfo.contentSize);
}
}