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
@@ -129,6 +129,8 @@ const renderObject = (object: Record<string, unknown>) => {
listItem.removeChild(loadingSpan); listItem.removeChild(loadingSpan);
listItem.appendChild(renderValue(resolvedValue)); listItem.appendChild(renderValue(resolvedValue));
}).catch((error) => { }).catch((error) => {
console.error(error);
// Show the promise error // Show the promise error
listItem.removeChild(loadingSpan); listItem.removeChild(loadingSpan);
const errorSpan = document.createElement('span'); const errorSpan = document.createElement('span');
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "mediabunny", "name": "mediabunny",
"version": "1.4.0", "version": "1.4.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "mediabunny", "name": "mediabunny",
"version": "1.4.0", "version": "1.4.1",
"license": "MPL-2.0", "license": "MPL-2.0",
"dependencies": { "dependencies": {
"@types/dom-mediacapture-transform": "^0.1.11", "@types/dom-mediacapture-transform": "^0.1.11",
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "mediabunny", "name": "mediabunny",
"author": "Vanilagy", "author": "Vanilagy",
"version": "1.4.0", "version": "1.4.1",
"description": "Pure TypeScript media toolkit for reading, writing, and converting media files, directly in the browser.", "description": "Pure TypeScript media toolkit for reading, writing, and converting media files, directly in the browser.",
"type": "module", "type": "module",
"main": "./dist/bundles/mediabunny.cjs", "main": "./dist/bundles/mediabunny.cjs",
+7
View File
@@ -368,6 +368,13 @@ export class MatroskaDemuxer extends Demuxer {
this.readContiguousElements(this.metadataReader, size); 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 // Put default tracks first
this.currentSegment.tracks.sort((a, b) => Number(b.isDefault) - Number(a.isDefault)); this.currentSegment.tracks.sort((a, b) => Number(b.isDefault) - Number(a.isDefault));