Fix conversion progress non-monotonicity

This commit is contained in:
Vanilagy
2025-09-07 22:36:53 +02:00
parent f3613b7260
commit cb9f4e0fdf
4 changed files with 18 additions and 10 deletions
+10 -2
View File
@@ -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);