diff --git a/package-lock.json b/package-lock.json index 5c23700..ab1d590 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mediabunny", - "version": "1.14.1", + "version": "1.14.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "mediabunny", - "version": "1.14.1", + "version": "1.14.2", "license": "MPL-2.0", "workspaces": [ "packages/*" @@ -7749,9 +7749,9 @@ } }, "node_modules/mediabunny": { - "version": "1.14.0", - "resolved": "https://registry.npmjs.org/mediabunny/-/mediabunny-1.14.0.tgz", - "integrity": "sha512-GaULQgUWpz5m4S7N6iNjpyLxqhpudjcSNGLC4Ni9A0A2vA6l5frBpxQJZM2JmqrN1B2BkArnCgyuTZv7ePw2vQ==", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/mediabunny/-/mediabunny-1.14.1.tgz", + "integrity": "sha512-TjLg8GQGGsnGePcA6i0NItGe9a5G8WaleCGaXpb5V5okwuK5KpNKfcmTZXItnjfPLo7FvfEZI0NFp1lIR8Os7Q==", "license": "MPL-2.0", "peer": true, "workspaces": [ @@ -12242,7 +12242,7 @@ }, "packages/mp3-encoder": { "name": "@mediabunny/mp3-encoder", - "version": "1.14.1", + "version": "1.14.2", "license": "MPL-2.0", "devDependencies": { "@types/emscripten": "^1.40.1" diff --git a/package.json b/package.json index 78dbbe5..b3d43b7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mediabunny", "author": "Vanilagy", - "version": "1.14.1", + "version": "1.14.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 cf89587..530fce7 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.14.1", + "version": "1.14.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/conversion.ts b/src/conversion.ts index cc48e63..19ab3f9 100644 --- a/src/conversion.ts +++ b/src/conversion.ts @@ -534,9 +534,14 @@ export class Conversion { if (this.onProgress) { this._computeProgress = true; this._totalDuration = Math.min( - await this.input.computeDuration() - this._startTimestamp, + (await this.input.computeDuration()) - this._startTimestamp, this._endTimestamp - this._startTimestamp, ); + + for (const track of this.utilizedTracks) { + this._maxTimestamps.set(track.id, 0); + } + this.onProgress?.(0); } @@ -1160,7 +1165,10 @@ export class Conversion { } assert(this._totalDuration !== null); - this._maxTimestamps.set(trackId, Math.max(endTimestamp, this._maxTimestamps.get(trackId) ?? -Infinity)); + this._maxTimestamps.set( + trackId, + Math.max(endTimestamp, this._maxTimestamps.get(trackId)!), + ); const minTimestamp = Math.min(...this._maxTimestamps.values()); const newProgress = clamp(minTimestamp / this._totalDuration, 0, 1);