-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add support for parsing Nero M4A chapters #7159
Add support for parsing Nero M4A chapters #7159
Conversation
This commit adds support for parsing Nero type chapters from a M4A file. See: https://github.com/Zeugma440/atldotnet/wiki/Focus-on-Chapter-metadata#mp4
This commit adds testcases that verify whether the application correctly parses Nero type M4A chapters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, this is great! Looks pretty good. I have added a few comments below :)
parser/media/src/main/java/de/danoeh/antennapod/parser/media/m4a/M4AChapterReader.java
Outdated
Show resolved
Hide resolved
parser/media/src/main/java/de/danoeh/antennapod/parser/media/m4a/M4AChapterReader.java
Outdated
Show resolved
Hide resolved
parser/media/src/main/java/de/danoeh/antennapod/parser/media/m4a/M4AChapterReader.java
Outdated
Show resolved
Hide resolved
parser/media/src/main/java/de/danoeh/antennapod/parser/media/m4a/M4AChapterReader.java
Outdated
Show resolved
Hide resolved
parser/media/src/test/java/de/danoeh/antennapod/parser/media/m4a/M4AChapterReaderTest.java
Outdated
Show resolved
Hide resolved
This commit introduces a mechanism to keep track of the remaining size of each part while searching for an atom in the M4A file. This is done to ensure that we do not exceed the size of the current part while searching for the next part in the atom name. If the remaining size is exhausted before finding the next part, the search for the atom is aborted and a message is logged. This change improves the robustness of the atom search process and helps prevent potential errors due to exceeding part sizes (e.g. reading the whole file even though the atom is not present).
This commit modifies the method of reading M4A atoms in the M4AChapterReader class. Previously, the method used a combination of InputStream.read and manual byte array handling. This commit replaces that with the use of IOUtils.readFully from Apache Commons IO. This method ensures that the entire atom is read into the buffer, even if it requires multiple read operations. This change simplifies the code and makes it more robust against situations where a single read operation might not read the entire atom. Additionally the method does not return -1 anymore when failing to find the atom but instead throws an IOException.
This commit introduces a functionality to validate if the provided file is an M4A file. This is achieved by checking the signature of the file. The signature of an M4A file is a specific sequence of bytes at the beginning of the file. If the signature does not match the expected M4A signature, an IOException is thrown indicating that the file is not an M4A file. This validation is crucial to ensure that the file can be correctly processed as an M4A file in subsequent steps.
Refactored the findAtom function in the M4AChapterReader class to improve performance. The function now uses a more efficient method to search for atoms in the M4A file, reducing the overall time complexity. This optimization should lead to faster parsing of M4A files, especially for larger files. The changes do not affect the functionality of the function, and all existing tests pass successfully.
Replaced the test file with a shorter copy-right free one. Fixed a bug where the find atom function returned the wrong size (8-bytes too large).
@ByteHamster I have made some changes to the pull request, trying to keep the commits atomic. I think you should get a good overview of the changes by stepping through each commit and reading the commit message. |
Thanks! Will be released in 3.5.x |
@IsAvaible Vielen Dank 🙂 |
Great, glad to contribute! |
Description
This pull request adds a simple M4A parser to detect and read Nero type chapters. I do not intend to implement parsing QuickTime type chapters, as it requires a more elaborate process.
Most M4A editors (such as FFMPEG) embed both types of chapters in the media file, so nonetheless a high percentage of M4A files with chapters should be supported after this pull request is merged.
As the previous test file only embedded QT chapters, I have added a new test file with Nero type chapters (nero-chapters.m4a).
partially fixes #4311