Skip to content

Enhancement: Support for MP4 Chapters #2803

Closed

Description

@sandreas

Use case description

I'm working on improving Voice, an audio book player app. A common use case is to store audio books as a single m4a file (an mp4 container without video) with all metadata. This metadata includes chapters to be able to navigate within the book. Quite often the .m4b extension is used to mark the file as book.

There are two different standards for storing chapters, from which one is mostly preferred - but often both are contained in the file, since they are not exclusive:

  • QuickTime chapters format (preferred)
  • Nero chapters format (simpler, but more prone to errors)

Here is a short and good overview of how these formats are structured and how they can be parsed. Unfortunately androidx/media does not provide support for any of these formats and there isn't even an alternative mp4 library which is well maintained and ready to use. This forces most App developers to write a custom format parser to extract the chapters themselves, which leads to slower / redundant file parsing and less robust solutions, sometimes even uncaught exceptions / App crashes.

There was already an attempt for a PR to solve this problem (#1851), but it did not receive a response.

Proposed solution

Since media3 already contains a solution for MP3 / ID3v2 chapters, the proposed solution would be to use the existing data structures to store a mapping of the mp4 chapters, similar to the other metadata and to the PR mentioned above.

See these commits:

If two chapter formats (QuickTime + Nero) exist in parallel, the QuickTime variant is to be preferred - even if they might contain different data. The reason for this is that damaged or incomplete files most of the time also contain a damaged set of Nero chapters, that can't be parsed - while the QuickTime set stays intact most of the time due to more robust data structure.

Alternatives considered

As an alternative it might be less effort to first integrate only the Nero format using #1851 as a base implementation and later extend this solution to also support QuickTime in a separate task.

Activity

  1. self-assigned this
    on Sep 24, 2025
  2. rohitjoins commented on Sep 26, 2025

    @rohitjoins
    Contributor

    Hi @sandreas,

    Sorry that PR #1851 was closed by the bot. I'll keep this issue open to track this enhancement.

  3. sandreas commented on Sep 26, 2025

    @sandreas
    Author

    Sorry that PR #1851 was closed by the bot. I'll keep this issue open to track this enhancement.

    Oh, there is no need to apologize :-) I just thought that A LOT of Apps would benefit from this and remind the maintainers.
    If you need a way to prevent bots to close an issue or PR, you could try to add an exclusive label to leave specific tasks open:

    with:
      exempt-issue-labels: 'work-in-progress'
    

    Then label the issue with work-in-progress. See https://github.com/actions/stale?tab=readme-ov-file#exempt-issue-labels

    Let me know if I can help you with something, e.g. testing changes.

    EDIT:
    @rohitjoins Just for clarification: Are you planning to work on this anytime soon or is this just something that might happen or not in the future?

  4. PylotLight commented on Oct 6, 2025

    @PylotLight

    I was working on something similar for audiobook support on wearos and have been running into similar chapter extraction issues.
    Any chance we can get some action on this one, as all the 3rd party libs I found haven't been updated in years which seems to suggest we need to parse this manually until this gets native support?

    Actually I might go with bundled ffprobe for now as simple but bloated option. That seems to handle the files relatively easily.

  5. rohitjoins commented on Mar 17, 2026

    @rohitjoins
    Contributor

    Hi @sandreas,

    Thank you for opening this issue and providing detailed overview of the chapters formats!

    We have added support for extracting both Nero and QuickTime chapters from MP4 files. To keep it format agnostic, we introduced a new Chapter interface.

    Additionally, just as you suggested, if an MP4 file contains both Nero and QuickTime chapters, the QuickTime chapters are preferred.

  6. sandreas commented on Mar 17, 2026

    @sandreas
    Author

    @rohitjoins
    Awesome thank you!

  7. locked and limited conversation to collaborators on May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions