Migrate FLAC demuxer to new packet system, move computeDuration impl to Input

This commit is contained in:
Vanilagy
2025-12-22 23:16:05 +01:00
parent bc1511a201
commit 4f8c8836ec
4 changed files with 172 additions and 126 deletions
+7 -2
View File
@@ -118,8 +118,13 @@ export class Input<S extends Source = Source> implements Disposable {
* all tracks.
*/
async computeDuration() {
const demuxer = await this._getDemuxer();
return demuxer.computeDuration();
const tracks = await this.getTracks();
if (tracks.length === 0) {
return 0;
}
const trackDurations = await Promise.all(tracks.map(x => x.computeDuration()));
return Math.max(...trackDurations);
}
/** Returns the list of all tracks of this input file. */