Skip to content

Bad chapter timestamps for Mp4 files #639

Open
@davidgfnet

Description

@davidgfnet

Hello there!
I found some issues while processing some M4A audio files, where chapter timestamps are wrong.
For reference, I compared with VLC and ffmpeg outputs (which agree) and figured the timestamps where multiplied by 1.666 in my audio files. I also noticed that there's a closed issue that seems to complain about the same (issue #451)
So that got me digging a bit on how this works, so I fired a hex viewer and found the chapters and their start points, which are encoded in 10s of microsends. The only thing that seemed off was the timestamp scaling by _timescale (here: https://github.com/quodlibet/mutagen/blob/main/mutagen/mp4/__init__.py#L1006), this is what produces the scaling factor (in my file, timescale is 600, so it is implicitely using a 1000/600 factor).
Looking at other implementations (VLC, mp4v2) I think this scaling factor is wrong and it should be removed, just divide by 1000 to scale it down to seconds).
Lemme know if you want me to send a PR. It would be good to create some example file to reproduce the issue, since the ones I've used are copyrighted and cannot be uploaded here :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions