Skip to content

Fix: Added ID_SEEK_HEAD parsing for MKV container. - #1604

Merged
fire-light42 merged 1 commit into
masterfrom
mkvseek
Mar 11, 2025
Merged

fire-light42 merged 1 commit into
masterfrom
mkvseek

Conversation

@fire-light42

@fire-light42 fire-light42 commented Mar 10, 2025 •

Copy link
Copy Markdown
Collaborator

Note due to media3 fuckery we have to copy paste the extractorfactory and mkv parser to edit anything. To make it less of a pain they are also auto translated into Kotlin.

This just added seekForSeekContent, seekHeadContentPosition and seekPositionAfterSeekingForHead. Notably this only supports a single recursive query, so no nested KaxSeekHead.

To detail what happens and why this is needed, the current impl only seeks to cues (timestamps) if the cue header is on the top of the file. What many real mkv editors do is to append the metadata (including cues) to the end of the file, presumably to not have to move like 1gb of media like 20kb forwards. This PR allows the header to include a SeekHead.

This means that when we parse an MKV file what really happens is:

  1. find KaxSeekHead
  2. seek to KaxSeekHead position
  3. find KaxCues
  4. seek to KaxCues position
  5. parse cues
  6. seek back from KaxCues
  7. seek back from KaxSeekHead
  8. parse rest normally

What happened before was:

  1. find KaxCues
  2. seek to KaxCues position
  3. parse cues
  4. seek back from KaxCues
  5. parse rest normally

This resolves #1584

Note due to media3 fuckery we have to copy paste the extractorfactory and mkv parser to edit anything. To make it less of a pain they are also auto translated into kotlin.
@fire-light42

Copy link
Copy Markdown
Collaborator Author

For anyone that wants to review, please try some MKV file that was not seekable in pre and try with this PR. Additionally this should not fuck up parsing, but might, so deny this PR if you find a MKV file that is playable in pre but not in this PR. Also have software encoding set to the same on both versions when testing.

@KingLucius

Copy link
Copy Markdown
Contributor

Please try to push it upstream after testing
For me, I have tried and it works

@fire-light42

Copy link
Copy Markdown
Collaborator Author

Please try to push it upstream after testing For me, I have tried and it works

Might do, however I wrote this in Kotlin not Java, due to some inherit issues with Java for this.

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.

MKV Seek / Better non seeking support

2 participants