Repository navigation
Conversation
Some files have a first SeekHead that only links to another SeekHead (e.g. at the end of the file), and only that one references the Cues element. This layout is produced when the header can't be rewritten in place, for example after editing with mkvpropedit. Previously only the first SeekHead was parsed, so the Cues were never found and the file was reported as unseekable. Follow SeekHead entries that point to other SeekHead elements (up to a fixed limit, skipping already visited positions) before deciding that the Cues element is missing. Track formats are deferred while linked SeekHeads are pending, so they're output once with the Cues-derived metadata, or on the fallback path if no Cues are found. Issue: androidx#1143 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Collaborator
|
Hey @brendongl. We need more information to resolve this issue but there hasn't been an update in 14 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
Collaborator
|
See #3588 (comment) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1143.
Problem
Some MKV files have a first
SeekHeadwhose only entry points to anotherSeekHead, and only a laterSeekHeadreferencesCues. As noted in #1143, mkvtoolnix writes this layout when it can't rewrite the header in place (e.g. aftermkvpropedit).MatroskaExtractoronly recordsSeekentries forCuesandTracks, so it never finds theCues, reports the stream as unseekable, and every seek fails or restarts from the start.This is common in the wild. In one media library, 216 of 299 files from the WEB-DL group TURG use this layout. A typical file has: front
SeekHead→SeekHeadat end of file →SeekHeadbefore the attachments →Cues. We reproduced the failure on Android TV with two different Media3-based players.Change
Seekentries that point to aSeekHeadare queued as linked SeekHeads. Already-visited positions and positions outside the segment are skipped, and at most 8 are followed.Clusteris reached and noCuesposition is known, the extractor seeks to the next linkedSeekHead. The decision is made when thatSeekHeadelement ends, because a linkedSeekHeadcan be the last element in the file. IfCuesis now known it is read; otherwise the next link is followed orSeekMap.Unseekableis output. In every case the extractor then seeks back to the original position, as the existing Cues/Tracks seeks do.seek(), so a restart from the beginning works.Files without linked SeekHeads behave exactly as before.
Testing
media/mkv/sample_with_linked_seek_heads.mkv. It issample.mkvwith the firstSeekHeadreplaced by a single link (padded with aVoidso all other offsets are unchanged) to aSeekHeadat the end of the file. That one links to anotherSeekHeadholding the original entries, matching the real-world layout above (verified withmkvinfo).MatroskaExtractorTest#mkvSample_withLinkedSeekHeadspasses in all simulation modes. Its dumps are identical tosample.mkv's, includingisSeekable = trueand the same seek points.MatroskaExtractorNonParameterizedTest#read_cuesOnlyReferencedByLinkedSeekHead_seekMapIsSeekablechecks that the seek map is seekable and matchessample.mkv's../gradlew :lib-extractor:testDebugUnitTest: 5765 tests, 0 failures.🤖 Generated with Claude Code