Skip to content

fix: seek no longer throws on a track without samples - #572

Merged
DenizUgur merged 1 commit into
gpac:mainfrom
zzoraemon043:fix/seek-empty-track
Oct 23, 2026
Merged

DenizUgur merged 1 commit into
gpac:mainfrom
zzoraemon043:fix/seek-empty-track

Conversation

@zzoraemon043

Copy link
Copy Markdown
Contributor

Fixes #515

getTrackDuration only checked for a missing samples array, so a track whose samples is empty read .cts of undefined and seek() threw. It now returns 0 for an empty track, so seek() treats it as already ended and skips it. Returning Infinity as in the patch in the issue would send the empty track into seekTrack, which answers offset 0 and pulls the whole seek back to the start of the file.

Added a test in tests/segmentation.test.ts that empties one track of 01_simple.mp4 and seeks to 3s; it throws before the change. Credited @big-nacho as co-author for tracking it down. Includes a patch changeset.

Fixes gpac#515

Co-authored-by: big-nacho <67847653+big-nacho@users.noreply.github.com>
@changeset-bot

changeset-bot Bot commented Oct 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c9dffea

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
mp4box Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@DenizUgur
DenizUgur added this pull request to the merge queue Oct 23, 2026
Merged via the queue into gpac:main with commit 213ac8d Oct 23, 2026
1 check passed
@github-actions github-actions Bot mentioned this pull request Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants