Make computeDuration and getFirstTimestamp have the same implementations across the board

This commit is contained in:
Vanilagy
2026-01-27 16:49:25 +01:00
parent 2ffa692fdd
commit 6004912f3d
13 changed files with 13 additions and 171 deletions
-15
View File
@@ -391,12 +391,6 @@ export class OggDemuxer extends Demuxer {
return this.tracks;
}
async computeDuration() {
const tracks = await this.getTracks();
const trackDurations = await Promise.all(tracks.map(x => x.computeDuration()));
return Math.max(0, ...trackDurations);
}
async getMetadataTags() {
await this.readMetadata();
return this.metadataTags;
@@ -487,15 +481,6 @@ class OggAudioTrackBacking implements InputAudioTrackBacking {
};
}
async getFirstTimestamp() {
return 0;
}
async computeDuration() {
const lastPacket = await this.getPacket(Infinity, { metadataOnly: true });
return (lastPacket?.timestamp ?? 0) + (lastPacket?.duration ?? 0);
}
granulePositionToTimestampInSamples(granulePosition: number) {
if (this.bitstream.codecInfo.codec === 'opus') {
assert(this.bitstream.codecInfo.opusInfo);