mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-03 13:53:53 +02:00
Make mfra box lookup more resilient
This commit is contained in:
+1
-3
@@ -24,9 +24,7 @@
|
|||||||
chunked: true,
|
chunked: true,
|
||||||
chunkSize: 2**20
|
chunkSize: 2**20
|
||||||
});
|
});
|
||||||
const outputFormat = new Mediabunny.AdtsOutputFormat({
|
const outputFormat = new Mediabunny.Mp4OutputFormat({});
|
||||||
onFrame: console.log
|
|
||||||
});
|
|
||||||
|
|
||||||
const button = document.createElement('button');
|
const button = document.createElement('button');
|
||||||
button.textContent = 'Cancel';
|
button.textContent = 'Cancel';
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
for await (const packet of sink.packets()) {
|
for await (const packet of sink.packets()) {
|
||||||
console.log(packet);
|
console.log(packet);
|
||||||
|
|
||||||
|
if (packet.timestamp > 135) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Generated
+6
-6
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "mediabunny",
|
"name": "mediabunny",
|
||||||
"version": "1.9.1",
|
"version": "1.9.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "mediabunny",
|
"name": "mediabunny",
|
||||||
"version": "1.9.1",
|
"version": "1.9.2",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
@@ -5900,9 +5900,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mediabunny": {
|
"node_modules/mediabunny": {
|
||||||
"version": "1.9.0",
|
"version": "1.9.1",
|
||||||
"resolved": "https://registry.npmjs.org/mediabunny/-/mediabunny-1.9.0.tgz",
|
"resolved": "https://registry.npmjs.org/mediabunny/-/mediabunny-1.9.1.tgz",
|
||||||
"integrity": "sha512-pNviaYemNRjrIbx1K1+Q1xcCbD1PRVp6i1+0GXJf5NPVeHUVJfJY2xkhtBjbd4LpbqCTqRoSPYxcrOmIRt14bw==",
|
"integrity": "sha512-DghqcYW2s8LsZ9kErFeZdm6308BEABYs8SkY1z3Y7v3LWgPNvBmkXk7Yt+EKcpEGEFjGgDGoTapOjrrrNh7dQA==",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"peer": true,
|
"peer": true,
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
@@ -9017,7 +9017,7 @@
|
|||||||
},
|
},
|
||||||
"packages/mp3-encoder": {
|
"packages/mp3-encoder": {
|
||||||
"name": "@mediabunny/mp3-encoder",
|
"name": "@mediabunny/mp3-encoder",
|
||||||
"version": "1.9.1",
|
"version": "1.9.2",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/emscripten": "^1.40.1"
|
"@types/emscripten": "^1.40.1"
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "mediabunny",
|
"name": "mediabunny",
|
||||||
"author": "Vanilagy",
|
"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.",
|
"description": "Pure TypeScript media toolkit for reading, writing, and converting media files, directly in the browser.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@mediabunny/mp3-encoder",
|
"name": "@mediabunny/mp3-encoder",
|
||||||
"author": "Vanilagy",
|
"author": "Vanilagy",
|
||||||
"version": "1.9.1",
|
"version": "1.9.2",
|
||||||
"description": "MP3 encoder extension for Mediabunny, based on LAME.",
|
"description": "MP3 encoder extension for Mediabunny, based on LAME.",
|
||||||
"main": "./dist/bundles/mediabunny-mp3-encoder.mjs",
|
"main": "./dist/bundles/mediabunny-mp3-encoder.mjs",
|
||||||
"module": "./dist/bundles/mediabunny-mp3-encoder.mjs",
|
"module": "./dist/bundles/mediabunny-mp3-encoder.mjs",
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ export class AdtsMuxer extends Muxer {
|
|||||||
const release = await this.mutex.acquire();
|
const release = await this.mutex.acquire();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
this.validateAndNormalizeTimestamp(track, packet.timestamp, packet.type === 'key');
|
||||||
|
|
||||||
if (!this.audioSpecificConfig) {
|
if (!this.audioSpecificConfig) {
|
||||||
validateAudioChunkMetadata(meta);
|
validateAudioChunkMetadata(meta);
|
||||||
|
|
||||||
|
|||||||
@@ -291,14 +291,20 @@ export class IsobmffDemuxer extends Demuxer {
|
|||||||
const lastWord = this.metadataReader.readU32();
|
const lastWord = this.metadataReader.readU32();
|
||||||
const potentialMfraPos = sourceSize - lastWord;
|
const potentialMfraPos = sourceSize - lastWord;
|
||||||
|
|
||||||
if (potentialMfraPos >= 0 && potentialMfraPos < sourceSize) {
|
if (potentialMfraPos >= 0 && potentialMfraPos <= sourceSize - MAX_BOX_HEADER_SIZE) {
|
||||||
await this.metadataReader.reader.loadRange(potentialMfraPos, sourceSize);
|
// 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;
|
this.metadataReader.pos = potentialMfraPos;
|
||||||
const boxInfo = this.metadataReader.readBoxHeader();
|
const boxInfo = this.metadataReader.readBoxHeader();
|
||||||
|
|
||||||
if (boxInfo.name === 'mfra') {
|
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);
|
this.readContiguousBoxes(boxInfo.contentSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user