Commit Graph
29 Commits
Author SHA1 Message Date
Scott GarrettandClaude Code 8520d729c6 Edit and add chapters in Matroska documents
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>
2026-11-26 12:54:58 -05:00
Scott GarrettandClaude Code 330236735d Add subtitle tracks to open Matroska documents
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>
2026-11-26 11:53:50 -05:00
Scott GarrettandClaude Code eb386a52c3 Open and edit Matroska files in place, including track removal
.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>
2026-11-25 19:48:34 -05:00
Damiano Galassi 934ae63b95 Expand undo/redo to all the document UI 2026-10-03 11:49:04 +02:00
Damiano Galassi 72a7288834 Fix file extension in the save panel 2025-09-17 17:36:36 +02:00
Michael Mock d88285ece2 Subler Automation Support (#67)
Expand the AppleScript dictionary to support many additional commands.
2025-08-12 11:52:16 +02:00
Damiano Galassi 0ea41244f5 Set autosavesInPlace to false, the default will change in a future sdk 2024-12-16 12:14:20 +01:00
Damiano Galassi 43d56d7851 Do not run the optimize pass if writing was cancelled 2024-11-29 12:53:12 +01:00
Damiano Galassi a6c51bb260 Use inferTracksLanguages() 2024-07-02 17:49:35 +02:00
Damiano Galassi 38927289ce Manually save the save options. 2021-02-23 11:10:15 +01:00
Damiano Galassi 251d3b5555 Fix save options when the save as sheet is dismissed. 2020-09-01 11:52:13 +02:00
Damiano Galassi 0319da5d7c Pass the force hvc1 option to the library instead of sharing a user default. 2020-02-08 13:46:41 +01:00
Damiano Galassi fbc464e643 Rework the preference to avoid stringly typed properties. 2020-02-07 15:31:10 +01:00
Damiano Galassi a03e8f080b Remove a few objc annotations. 2019-05-02 12:14:41 +02:00
Damiano Galassi a8c9590915 Minor code improvements. 2019-03-11 17:43:05 +01:00
Damiano Galassi f993d8dd81 Mark some classes as final. 2019-03-05 10:41:54 +01:00
Damiano Galassi cd36f3349c Rewrite SBQueueItem to Swift. 2019-01-28 18:50:50 +01:00
Damiano Galassi 3074bee3dd Rewrite the queue in Swift. 2019-01-27 14:47:01 +01:00
Damiano Galassi 5725b0f830 Convert to Swift 5, convert QueueController to Swift. 2019-01-27 11:46:31 +01:00
Damiano Galassi 983151aeeb Import MP42Foundation. 2018-05-02 13:06:16 +02:00
Damiano Galassi 08a5ba1109 Fix send to queue optimise action. 2018-04-12 15:17:16 +02:00
Damiano Galassi effa297fc4 Add an "Optimize" checkbox to save as options. 2018-03-15 09:03:56 +01:00
Damiano Galassi 66f4575ffc Convert SBAppDelegate to Swift. 2018-02-17 10:46:53 +01:00
Damiano Galassi 854e5dfcc9 Move sendToQueue to Document.swift 2018-02-14 15:15:16 +01:00
Damiano Galassi f35c3734ee Fix send to queue save panel. 2018-02-14 10:05:27 +01:00
Damiano Galassi 335742eb4f Improve exported tracks name 2018-02-14 09:22:15 +01:00
Damiano Galassi 22b1cbdd08 Add back the import sheet for unsupported brands. 2018-02-14 09:10:50 +01:00
Damiano Galassi 43a74932d3 Set progress label to "Optimizing…" when optimising. 2018-02-10 19:28:04 +01:00
Damiano Galassi 3cc367a00d Convert SBDocument to swift. 2018-02-10 14:53:39 +01:00