I'm new to the library, so I'm not sure if this might be me doing something wrong, but I noticed that with one specific video, when calling
I'd get
I managed to track it down to the moov box having a track with no samples, and patched it like this
MP4Box.ISOFile.prototype.getTrackDuration = function (trak) {
if (!trak.samples || !trak.samples.length) { // Added length check
return Infinity;
}
const sample = trak.samples[trak.samples.length - 1];
return (sample.cts + sample.duration) / sample.timescale;
}
Not sure if it's me patching my own poor usage of the library, but submitting in case it's a bug.