Skip to content

Support gapless MP3 playback #463

Description

@valadaptive

The MP3 format has an inherent delay due to the MDCT + polyphase filterbank, and encoders may add their own delay.

While determining the encoder delay isn't possible for every MP3 file, LAME includes an extension to the Xing info that explicitly lists the encoder delay.

I have a (work-in-progress) branch that parses this delay field and offsets the timestamp. However, Mediabunny really doesn't seem to like negative timestamps; despite the documentation explicitly saying that timestamps may be negative, there are a ton of code paths that assert that they aren't. This would also require API consumers to explicitly notice and trim the delay themselves based on the timestamp.

An alternative approach would be to automatically trim the leading and trailing samples in the decoding step. This has the downside that we'd have to do it for each combination of codec and container, but would avoid pesky negative samples. It would also better handle trimming of trailing samples in general; I'm not sure what actually happens if the advertised duration of an audio packet is shorter than its actual sample count.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions