Mirror the file's chapter atoms verbatim in tagsOnly mode
The importer's MP4 normalizations (force the first chapter start to 0, drop non-first zero-timestamp chapters) belong to the conversion path only. In tagsOnly mode the model is the baseline a later Chapters rewrite rebuilds from, so those quirks silently corrupted real files: mkvmerge happily writes a first chapter starting after 0 and atoms tied at 0, and the first chapter edit would then shift or delete them. The remuxer's strictly-ascending clamp already shifts tied starts by +1 ms at write time, so nothing is lost by keeping every atom at read time. Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
1 parent
10dcee30a6
commit
e8231dea59
1 file changed
+15
-5
+15
-5
@@ -346,11 +346,21 @@ MP42_OBJC_DIRECT_MEMBERS
|
||||
// Seg.Duration, by contrast, is already ns-scaled.
|
||||
for (unsigned int xi = 0; xi < chapters->nChildren; xi++) {
|
||||
uint64_t timestamp = (chapters->Children[xi].Start) / SCALE_FACTOR;
|
||||
if (!xi) {
|
||||
timestamp = 0;
|
||||
}
|
||||
if (xi && timestamp == 0) {
|
||||
continue;
|
||||
if (!tagsOnly) {
|
||||
// MP4 chapter tracks start at 0 and never carry a second
|
||||
// zero-start entry — normalize for the conversion path.
|
||||
// Matroska allows both shapes (mkvmerge writes them), and
|
||||
// in tagsOnly mode the model is the baseline a later
|
||||
// Chapters rewrite rebuilds from: dropping an atom or
|
||||
// shifting the first start here would silently corrupt
|
||||
// those chapters on the first edit. The remuxer sorts and
|
||||
// clamps ties to previous+1ms on the way out.
|
||||
if (!xi) {
|
||||
timestamp = 0;
|
||||
}
|
||||
if (xi && timestamp == 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (chapters->Children[xi].Display && strlen(chapters->Children[xi].Display->String)) {
|
||||
[newTrack addChapter:[NSString stringWithUTF8String:chapters->Children[xi].Display->String]
|
||||
|
||||
Reference in new issue
Block a user