Fall back to default timescale when not provided by the Matroska file

This commit is contained in:
Vanilagy
2025-07-27 13:03:43 +02:00
parent 232d1a6cd7
commit ac8baa4873
4 changed files with 12 additions and 3 deletions
+7
View File
@@ -368,6 +368,13 @@ export class MatroskaDemuxer extends Demuxer {
this.readContiguousElements(this.metadataReader, size);
}
if (this.currentSegment.timestampScale === -1) {
// TimestampScale element is missing. Technically an invalid file, but let's default to the typical value,
// which is 1e6.
this.currentSegment.timestampScale = 1e6;
this.currentSegment.timestampFactor = 1e9 / 1e6;
}
// Put default tracks first
this.currentSegment.tracks.sort((a, b) => Number(b.isDefault) - Number(a.isDefault));