The chapters tab leaves read-only jail on MKV docs: didSelect exempts
ChapterViewController from the tags-only blanket, and chapter-less docs
can gain chapters through the same txt/csv dispatch MP4 documents use
(selectFile's MKV branch and drag-drop now allow .txt/.csv alongside
the subtitle extensions; addChapters/updateChapters assign the display
trackId and flag the document dirty on MKV).
Chapter edits ride the remuxer, never the tag writer: Chapters sits
before the Clusters, so any size change shifts every following byte.
Document.mkvChaptersSnapshot holds the baseline rows and drives a
chaptersChanged check against the model (model-vs-model, because the
reader itself drops duplicate zero-timestamp atoms and those must not
look like user edits); when changed, remuxMatroska passes mp4.chapters
(or an empty track to delete every chapter) as the remuxer's
replacementChapters, then refreshes the snapshot so an untouched save
goes back to the byte-stable tag-writer path.
Verified live: add a chapter row in the UI, File>Save — the file gains
the atom (ties clamped to 1ms), mkvmerge/ffmpeg both read it, a
forced no-op re-save is byte-identical, and reopening shows all rows.
Co-Authored-By: Claude Code <noreply@anthropic.com>
MKV docs can now import .srt/.ssa/.ass subtitle files, written as
S_TEXT/UTF8 by MP42MkvRemuxer (submodule bump). Video/audio adds and
other subtitle formats stay refused by both sides.
- DocumentWindowController: split selectFile: validation so MKV docs
get an Import panel restricted to matroskaSubtitleExtensions (kept
in sync with the remuxer's gate); showImportSheet routes MKV docs
to importSubtitleTracksForMatroska, which imports each file with a
plain MP42FileImporter (no track-selection sheet), attaches the
conversion-settings defaults addTrack: asserts on, and assigns the
next display trackId. Drag-drop already funnels through
showImportSheet. didSelect skips
organizeAlternateGroups/inferMediaCharacteristics on MKV docs —
same TrackEntry-pairing protection as delete.
- Document: the tagsChanged check already caught additions; the
post-remux snapshot now appends the added tracks behind the kept
ones, matching the TrackEntry order in the written file, so a
later tags-only save pairs correctly instead of double-appending.
- ScriptCommand: the AppleScript "save as" command called
mp4.write(to:) directly, which muxed a QuickTime MP4 over a
Matroska document. Route isMatroska documents through
Document.save(saveAsOperation) so writeMatroska picks the
tag-writer/remux path and enforces the mkv destination.
Verified with the /tmp/subler-mkv-test harness (matrix PASS=276: add
srt/ass, add+drop mix, no-cues source, bad-file and drop-all
refusals, idempotent re-save, post-add tag edit) and against the
live app (scripted import + save on a fixture copy; output checked
with mkvmerge/mkvextract/ffmpeg and reopened cleanly).
Co-Authored-By: Claude Code <noreply@anthropic.com>
.mkv/.mka/.mks now open directly into a tags-only document instead of
forcing the convert-import sheet:
- Metadata, cover art, and the four per-track fields Matroska stores
(name, language, enabled, subtitle forced) save back into the same
file via MP42MkvTagWriter; MP4-only properties stay read-only.
- Real tracks can be deleted and Save-As is enabled; both go through
MP42MkvRemuxer's stream-copy rebuild (Document keeps an importer-order
track snapshot and pairs TrackEntry elements by object identity).
Destinations must stay .mkv/.mka/.mks.
- Info.plist: the Matroska document type becomes Editor so NSDocument
offers .mkv Save-As instead of defaulting to the MP4 type.
- Delete on MKV docs skips organizeAlternateGroups/
inferMediaCharacteristics because they reorder the model, which the
TrackEntry pairing depends on; chapter rows stay undeletable.
Bumps MP42Foundation for the Matroska tagging/remux support.
Co-Authored-By: Claude Code <noreply@anthropic.com>