Skip to content

TypeError: Cannot read properties of undefined (reading 'cts') #515

Description

@big-nacho

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

file.seek(time, true);

I'd get

Image

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions