Skip to content

Fix/mp4 alac and trailing bytes - #124

Merged
ClementBeal merged 2 commits into
mainfrom
fix/mp4-alac-and-trailing-bytes
Oct 28, 2026
Merged

ClementBeal merged 2 commits into
mainfrom
fix/mp4-alac-and-trailing-bytes

Conversation

@ClementBeal

Copy link
Copy Markdown
Owner
  • ALAC sample rate: the parser only read the sample rate from mp4a (AAC) sample entries, so Apple Lossless files returned sampleRate: null. alac uses the same layout and is now handled. Checked on the ALAC sample from some m4a files raise exception #74.
  • Trailing non-box bytes: some taggers append bytes after mdat (e.g. a 256-byte RLTP=… text trailer). The parser read them as an oversized box and rejected the whole file. Invalid box headers now end their scope and keep what was already read, and the writer copies the trailing bytes unchanged. Files that break before moov are still rejected.

A child box that exceeds its parent is now skipped instead of throwing MetadataParserException.

Apple Lossless audio is described by an `alac` sample entry instead of
`mp4a`. Both use the AudioSampleEntry layout, so the sample rate is read
at the same place. The sample rate of ALAC files used to be null.
Some taggers and rippers append bytes that are not a box after `mdat`,
for instance a 256-byte `RLTP=...` text trailer. The parser read them as
a box of an impossible size and rejected the whole file.

A box header that cannot belong to its scope (fewer than 8 bytes left,
an all-zero type, a size smaller than its header or past the parent
end) now ends that scope: the rest of the parent is skipped and what
was read before is kept. A file whose top level breaks before any
`moov` box is still rejected. A malformed iTunes freeform `----` box
only drops that box.

The writer copies such trailing bytes unchanged instead of throwing.
@ClementBeal
ClementBeal merged commit fbacf9a into main Oct 28, 2026
3 checks passed
@ClementBeal
ClementBeal deleted the fix/mp4-alac-and-trailing-bytes branch October 28, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant