0cf79eca1c4b1c56f521d914d83bd07d89ec3318
MP42MkvRemuxer gains replacementChapters: when set, the Chapters element is rebuilt from the model track instead of copied verbatim (chapterCount 0 removes the element and its SeekHead entry). Chapter timecodes are written as absolute nanoseconds — libmatroska/mkvtoolnix/ffmpeg all treat them as ns regardless of TimecodeScale, confirmed by hex-dumping a mkvmerge-written file and reading it back with mkvinfo and ffprobe. ChapterAtom is 0xB6 (0xB0 is PixelWidth), and mandatory EditionUID/ ChapterUID are derived deterministically from the content because ffmpeg silently skips atoms without a ChapterUID. Starts are sorted ascending with ties clamped to previous+1ms (mkvmerge rejects non-ascending), empty titles get the importer's "Chapter N" fallback, and the last atom's end rides the track duration only when known. An existing Info Duration is recomputed as the greatest written block start+1ms: the Info payload is rewritten with a fixed 8-byte double slot patched after the clusters stream past, converted to TimecodeScale units. Added blocks measure start+1 like source blocks so a second no-op remux stays byte-identical (including BlockDuration broke idempotence). Files without a source Duration keep having none. The importer's chapter /1e6 needed no change (Start is already ns); a comment now records that so it doesn't get "fixed" to scale-based math. Co-Authored-By: Claude Code <noreply@anthropic.com>
Languages
Objective-C
74%
C
10.5%
Objective-C++
9.7%
Swift
5%
C++
0.7%