Repository navigation
fix: an M4B whose chapters tagging would break is imported untagged, with its chapters - #524
Merged
Merged
Conversation
…e original imported untagged ffmpeg 9.0.2 (pinned since v1.2.4) writes zero-length chapters when the tagging remux copies an embedded cover next to the chapter track, and exits 0. Before placement the organizer now compares the final tagged copy's chapters with the source's (count, titles in order, start and end within 0.1 s, via ffprobe -show_chapters). On a mismatch, or when the tagged copy cannot be probed, the original is placed exactly as with tagging off, the .tmp is removed, a warning is logged and the request says the file was imported without tags. A source without chapters skips the check; a source ffprobe cannot read keeps today's behaviour. Refs #511. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #511
What changed
src/lib/utils/chapter-guard.ts). Before each tagged copy is placed in the library, the organizer (organize()insrc/lib/utils/file-organizer.ts) compares the copy's chapter table with the source's: same number of chapters, the same titles in the same order, and each start and end within 0.1 s. The tables are read withffprobe -show_chapters(argv list, no shell, 60 s timeout)..tmpcopy is removed as before. The job log gets one warning per file:Tagging changed the chapter table of <file> (N chapters before, M after, first change at chapter K), so it was imported without tags. The request showsthe file was imported without metadata tags (tagging changed the chapter table), like the existing duration check.organize(): download imports (torrent and usenet), Manual Import, Bulk Import, request retries and the failed-import retry job. Ebook imports and chapter merging do not tag, so they are unchanged. A merged M4B that gets tagged is checked against the merged file.documentation/phase3/file-organization.md(new Chapter Guard section, the request message table, Fixed Issues Improve system logs page design and functionality #17) anddocumentation/TABLEOFCONTENTS.md.Why
Since v1.2.4 the image ships ffmpeg 9.0.2. Its MP4 muxer writes zero-length chapters when the tagging remux (
-codec copy ... -movflags +faststart -f mp4) copies an embedded cover next to the chapter track it rebuilds. ffmpeg exits 0, so RMAB placed the damaged copy, reported success, and cleanup later removed the good original. Tagging is on by default.This change is a guard only. Affected files (an MP4 or M4B with an embedded cover and chapters) are now imported untagged, with their chapters intact, until a follow-up fix makes the tagging remux keep the chapters.
Evidence
ghcr.io/kikootwo/readmeabook:1.2.11) on a 3000 s M4B with a cover and 4 chapters. The output has zero-length chapters 2 to 4 (ffmpeg warnsApplication provided duration ... is invalid, exit 0). The branch'scheckTaggedChapterson the host reportschangedfor it (4 chapters before, 4 after, first change at chapter 2) andkeptfor the same remux of the source without a cover.tests/utils/file-organizer.chapter-guard.test.tsruns the realorganize()on temp folders with scripted ffprobe chapter tables: zero-length, missing, reordered and renamed chapters and a start moved by more than 0.1 s all import the original with the warning and leave no.tmp; matching tables (drift within 0.1 s) keep the tagged copy; a source with no chapters skips the check; an ffprobe failure on the tagged copy falls back; one on the source keeps the tagged copy and logs it; the check runs after the freeform step.main'ssrc(abf3639): 9 of its 10 tests fail on an assertion (the tagged copy is placed, no warning, no chapter probe). The matching-tables test passes, as it should.tests/utils/chapter-guard.test.tscovers the comparison (tolerance edge, titles, order, count, missing times) and the ffprobe argv.Checks
vitest relatedon the two changedsrcfiles, plus the two new test files): PASStsc --noEmitclean; ESLint reports nothing new in the touched files compared withmain)src/app, the Dockerfile or the ffmpeg pinRisk and rollback
ffprobe -show_chaptersreads per tagged file (the moov only, no packet walk). The duration check that already runs walks every packet twice, so the added time is small.Release note
🤖 Generated with Claude Code