Skip to content

Ignore unusable Cues references in MatroskaExtractor - #3605

Open
Jercik wants to merge 1 commit into
androidx:mainfrom
Jercik:fix/mkv-cues-reference-check
Open

Jercik wants to merge 1 commit into
androidx:mainfrom
Jercik:fix/mkv-cues-reference-check

Conversation

@Jercik

@Jercik Jercik commented Nov 30, 2026

Copy link
Copy Markdown

Matroska files whose SeekHead points Cues to another element or past the end of the file hang or fail to prepare in ExoPlayer. MatroskaExtractor now validates that the Cues position is within a known input length and actually starts with ID_CUES before reading it.

Previously, MatroskaExtractor sought to the Cues offset unconditionally at the first Cluster. If that offset held a Cluster (or preceded one), the extractor kept requesting the same seek forever with no SeekMap or samples output. If it was at or past EOF (for example in a truncated file), the data source rejected the seek and playback failed. Now the extractor outputs an unseekable SeekMap and resumes playback from where it left off.

Known limits

  • A Cues offset past EOF on an input of unknown length is still rejected by the data source before the extractor can read again.
  • A broken Cues reference from which reading forward happened to reach the real Cues used to be seekable and is now unseekable.

Device testing

Tested in the demo app on an NVIDIA Shield TV Pro 2019 (Android 11):

Sample Before After
Cues pointing to a Cluster Never starts Plays, unseekable
Cues past EOF / file truncated before Cues Load error Plays, unseekable
Normal file with direct Cues Plays, seekable Plays, seekable

Found via @FongMi's review of #3588.

MatroskaExtractor seeks to the Cues position named by a SeekHead when
it reaches the first Cluster, and trusted that position. If it held
another element, the extractor read on from there. From a position at
or before a Cluster it requested the same seek again without end, with
no SeekMap or samples output. From other positions it output nothing or
failed to parse. If the position was at or beyond the end of the input,
as in a file cut off before its Cues, the data source rejected the seek
and the file did not prepare.

The extractor now checks that the named position holds the Cues before
reading them. If it holds anything else, or is at or beyond a known
input length, the extractor outputs an unseekable SeekMap, as for a
file without Cues, and plays the file from where it left off.

A position beyond the end of an input of unknown length is still
rejected by the data source before the extractor can read again. A
reference to a position from which reading on happened to reach the
Cues used to be seekable and is now unseekable.
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.

1 participant