Skip to content

Fix M4B chapters on noncontiguous tracks and packed samples - #36

Merged
M1sterMo merged 1 commit into
M1sterMo:mainfrom
lecrackzor:fix-m4b-packed-chapter-tracks
Nov 15, 2026
Merged

M1sterMo merged 1 commit into
M1sterMo:mainfrom
lecrackzor:fix-m4b-packed-chapter-tracks

Conversation

@lecrackzor

@lecrackzor lecrackzor commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Read QuickTime chapter titles from the track id named by the chap atom. Some M4Bs, including ones written by cm4b, use track id 3 while only tracks 1 and 3 exist, so the old trackId - 1 lookup returned no chapters.
  • Treat each text sample as a chapter. Those files store every title in one chunk, with an encd trailer after the length-prefixed name, so one title per stco entry collapsed the book to a single chapter.
  • Keep preferring a valid Nero chpl atom. Also accept co64 offsets and skip boxes larger than 2 GiB, and clear cached chapter timestamps so an existing library re-reads marks on the next scan.

Test plan

  • ./gradlew :core:scanner:testDebugUnitTest :core:data:impl:testDebugUnitTest — covers a chapter text track that is not the next track id, several titles packed into one chunk, co64 offsets past 4 GiB, an mdat larger than 2 GiB, and the schema migration that clears cached chapter timestamps. These cases are synthetic fixtures, so they do not depend on anyone's library.
  • On a device, rescanning a library that previously showed no chapters for this kind of M4B now shows the embedded chapter list. Ordinary books and one-file-per-chapter books are unchanged. (Checked by the author; a reviewer does not need those files.)

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.

2 participants