Chapter tracks (v0.4.2) #6

Merged
mnovak merged 1 commits from feature/chapter-track into main 2026-11-17 21:53:49 +01:00
Owner

Day 4 follow-up (v0.4.2): QuickTime chapter tracks.

LibriVox M4B (and iTunes, most M4B tools) keep chapters in a chapter track (a text track that the audio track names in tref/chap), not a Nero chpl. On the real LibriVox Metamorphosis the parser found the 2.5 h duration but no chapters.

  • The box walk records each track (id, handler, timescale, the byte ranges of stts/stsz/stsc/stco/co64); trak boxes are bounded (64).
  • chapter_track decodes only the referenced text track: start times from stts, sample offsets from stsc + chunk offsets + stsz, every count capped at 10,000 chapters and checked against its box.
  • When the titles are inside the bytes given, they are read at once; otherwise Info.chapter_samples tells the caller where they are and titles_from_samples reads them (each at most 1 KiB) — the app reads them from the file without loading the media data.

Test (tests/hostile.rs): a generated M4B with a chapter track (three titles, starts), the metadata-only path, a lying sample count refused. Workspace 110 tests green; clippy 0; deps --check clean.

Day 4 follow-up (v0.4.2): QuickTime chapter tracks. LibriVox M4B (and iTunes, most M4B tools) keep chapters in a *chapter track* (a text track that the audio track names in `tref/chap`), not a Nero `chpl`. On the real LibriVox Metamorphosis the parser found the 2.5 h duration but no chapters. - The box walk records each track (id, handler, timescale, the byte ranges of `stts`/`stsz`/`stsc`/`stco`/`co64`); `trak` boxes are bounded (64). - `chapter_track` decodes only the referenced text track: start times from `stts`, sample offsets from `stsc` + chunk offsets + `stsz`, every count capped at 10,000 chapters and checked against its box. - When the titles are inside the bytes given, they are read at once; otherwise `Info.chapter_samples` tells the caller where they are and `titles_from_samples` reads them (each at most 1 KiB) — the app reads them from the file without loading the media data. Test (`tests/hostile.rs`): a generated M4B with a chapter track (three titles, starts), the metadata-only path, a lying sample count refused. Workspace 110 tests green; clippy 0; deps --check clean.
mnovak added 1 commit 2026-11-17 21:53:46 +01:00
mnovak merged commit 7aa13d6c0a into main 2026-11-17 21:53:49 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mnovak/Liber-public#6