mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-02 21:33:52 +02:00
Fix MP3 demuxer wrong data offset
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
While Mediabunny is proudly human-coded, we want to encourage any and all usage of Mediabunny, even when the vibes are high.
|
While Mediabunny is proudly human-coded, we want to encourage any and all usage of Mediabunny, even when the vibes are high.
|
||||||
|
|
||||||
Mediabunny is still new and is unlikely to be in the training data of modern LLMs, but we can still make the AI perform extremely well but just giving it a little more context.
|
Mediabunny is still new and is unlikely to be in the training data of modern LLMs, but we can still make the AI perform extremely well by just giving it a little more context.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import {
|
|||||||
ALL_FORMATS,
|
ALL_FORMATS,
|
||||||
AudioBufferSink,
|
AudioBufferSink,
|
||||||
BlobSource,
|
BlobSource,
|
||||||
|
BufferSource,
|
||||||
CanvasSink,
|
CanvasSink,
|
||||||
Input,
|
Input,
|
||||||
UrlSource,
|
UrlSource,
|
||||||
@@ -91,7 +92,7 @@ const initMediaPlayer = async (resource: File | string) => {
|
|||||||
|
|
||||||
// Create an Input from the resource
|
// Create an Input from the resource
|
||||||
const source = resource instanceof File
|
const source = resource instanceof File
|
||||||
? new BlobSource(resource)
|
? new BufferSource(await resource.arrayBuffer())// new BlobSource(resource)
|
||||||
: new UrlSource(resource);
|
: new UrlSource(resource);
|
||||||
const input = new Input({
|
const input = new Input({
|
||||||
source,
|
source,
|
||||||
@@ -191,6 +192,7 @@ const initMediaPlayer = async (resource: File | string) => {
|
|||||||
if (!videoSink) {
|
if (!videoSink) {
|
||||||
// If there's only an audio track, always show the controls
|
// If there's only an audio track, always show the controls
|
||||||
controlsElement.style.opacity = '1';
|
controlsElement.style.opacity = '1';
|
||||||
|
controlsElement.style.pointerEvents = '';
|
||||||
playerContainer.style.cursor = '';
|
playerContainer.style.cursor = '';
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Generated
+6
-6
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "mediabunny",
|
"name": "mediabunny",
|
||||||
"version": "1.13.1",
|
"version": "1.13.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "mediabunny",
|
"name": "mediabunny",
|
||||||
"version": "1.13.1",
|
"version": "1.13.2",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
@@ -7749,9 +7749,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mediabunny": {
|
"node_modules/mediabunny": {
|
||||||
"version": "1.13.0",
|
"version": "1.13.1",
|
||||||
"resolved": "https://registry.npmjs.org/mediabunny/-/mediabunny-1.13.0.tgz",
|
"resolved": "https://registry.npmjs.org/mediabunny/-/mediabunny-1.13.1.tgz",
|
||||||
"integrity": "sha512-eAtCVOzceN3VkExQmYrDB+3bM6d98PfB6AhgueojYG6T5SNzc4cRR2gWm0oZ1HjhNN0J4hjtvtEpJ+AAMXF/dQ==",
|
"integrity": "sha512-Fht/ujfoS0jt8s9W4zDEilnWVsafkBaiIQ5BX0x1tdvM4PClexgYIWDZSf6kC82/c9Bo3ehZPIIfS3aJ9younA==",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"peer": true,
|
"peer": true,
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
@@ -12242,7 +12242,7 @@
|
|||||||
},
|
},
|
||||||
"packages/mp3-encoder": {
|
"packages/mp3-encoder": {
|
||||||
"name": "@mediabunny/mp3-encoder",
|
"name": "@mediabunny/mp3-encoder",
|
||||||
"version": "1.13.1",
|
"version": "1.13.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.13.1",
|
"version": "1.13.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.13.1",
|
"version": "1.13.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",
|
||||||
|
|||||||
+10
-12
@@ -75,9 +75,7 @@ export class Mp3Demuxer extends Demuxer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const startPos = this.lastLoadedPos;
|
const result = await readNextFrameHeader(this.reader, this.lastLoadedPos, this.reader.fileSize);
|
||||||
|
|
||||||
const result = await readNextFrameHeader(this.reader, startPos, this.reader.fileSize);
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
this.lastSampleLoaded = true;
|
this.lastSampleLoaded = true;
|
||||||
return;
|
return;
|
||||||
@@ -89,16 +87,16 @@ export class Mp3Demuxer extends Demuxer {
|
|||||||
|
|
||||||
const xingOffset = getXingOffset(header.mpegVersionId, header.channel);
|
const xingOffset = getXingOffset(header.mpegVersionId, header.channel);
|
||||||
|
|
||||||
let slice = this.reader.requestSlice(startPos + xingOffset, 4);
|
let slice = this.reader.requestSlice(result.startPos + xingOffset, 4);
|
||||||
if (slice instanceof Promise) slice = await slice;
|
if (slice instanceof Promise) slice = await slice;
|
||||||
assert(slice);
|
if (slice) {
|
||||||
|
const word = readU32Be(slice);
|
||||||
|
const isXing = word === XING || word === INFO;
|
||||||
|
|
||||||
const word = readU32Be(slice);
|
if (isXing) {
|
||||||
const isXing = word === XING || word === INFO;
|
// There's no actual audio data in this frame, so let's skip it
|
||||||
|
return;
|
||||||
if (isXing) {
|
}
|
||||||
// There's no actual audio data in this frame, so let's skip it
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.firstFrameHeader) {
|
if (!this.firstFrameHeader) {
|
||||||
@@ -109,7 +107,7 @@ export class Mp3Demuxer extends Demuxer {
|
|||||||
const sample: Sample = {
|
const sample: Sample = {
|
||||||
timestamp: this.nextTimestampInSamples / header.sampleRate,
|
timestamp: this.nextTimestampInSamples / header.sampleRate,
|
||||||
duration: sampleDuration,
|
duration: sampleDuration,
|
||||||
dataStart: startPos,
|
dataStart: result.startPos,
|
||||||
dataSize: header.totalSize,
|
dataSize: header.totalSize,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user