diff --git a/MP42/MP42MkvImporter.m b/MP42/MP42MkvImporter.m index a2df4b9..0ecfabc 100644 --- a/MP42/MP42MkvImporter.m +++ b/MP42/MP42MkvImporter.m @@ -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]