Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch MP3 parser to ignore files that contain Lyrics3 data. #164

Merged
merged 4 commits into from
Nov 18, 2022

Conversation

psobot
Copy link
Member

@psobot psobot commented Nov 16, 2022

This PR resolves an issue discovered by @f90 in which certain MP3 files - notably those that contain Lyrics3v2 data - cannot be read completely by Pedalboard.

The full explanation of the bug:

  • Lyrics3v2 is a non-standard addition to the MP3 file format to encode lyrics into the file by appending a section to the end of the audio stream, but before the ID3 tag.
  • The inclusion of Lyrics3v2 data causes many parsers to choke on these files; FFMPEG has trouble parsing them, and other projects exist to remove the offending data.
  • Pedalboard uses JUCE's MP3 decoder to read MP3 files on Linux and Windows. (On macOS, CoreAudio is used by default.) JUCE's MP3 decoder doesn't know how to handle the Lyrics3v2 format, and returns an error once this data is encountered as part of the audio stream.
  • Pedalboard could be used to read these files, but upon reading the last couple of MP3 frames, would throw an opaque error saying just Failed to read from file. when it encountered the Lyrics3v2 tag.
  • Other parsers (including macOS's built-in CoreAudio parser) handle this data by silently skipping it, making Pedalboard's behaviour inconsistent between operating systems.

This PR makes a couple of changes to fix the issue:

  • JUCE's MP3 parser is now vendored in juce_overrides and has been patched to ignore Lyrics3v2 blocks if encountered during parsing.
  • The error message returned if audio can't be parsed has been improved to indicate which file (or stream) failed to parse, where in the file the parsing error was discovered, and what can be tried to avoid the error.
  • pedalboard.io.ReadableAudioFile now includes a new constructor parameter, cross_platform_formats_only, which allows reproduction of this bug on macOS by disabling any platform-specific audio format parsers (like CoreAudio, or Windows Media).

@psobot psobot added the bug Something isn't working label Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants