Add Matroska tagging and track-removal support

- MP42Ebml: EBML vint/ID primitives, flat Segment scanner, block track
  number decoding, and element builders shared by all Matroska writers.
- MP42MkvImporter / MP42FileImporter: tagsOnly mode that mirrors the
  file's own track flags instead of the MP4 conversion heuristics.
- MP42MatroskaTagMapping: read/write SimpleTag maps shared by importer
  and writer, including community names for MP4-only movie fields.
- MP42MkvTagWriter: mkvpropedit-style in-place rewrite of Tags, cover
  art, and per-track name/language/enabled/forced fields with a
  size+mtime staleness guard; an untouched save is a byte-for-byte
  no-op.
- MP42MkvRemuxer: stream-copy rebuild that drops the blocks of removed
  tracks (TrackNumbers keep their gaps; block bytes are never
  rewritten), regenerates SeekHead and Cues, carries metadata edits in
  the same pass, and writes via temp file + atomic rename.
- MP42MkvTagWriter+Internal.h exposes the tag writer's scanning and
  payload builders so the remuxer reuses them unchanged.

Verified with the external matrix harness: 241 assertions green across
layout fixtures (ffmpeg/mkvmerge/streamed), removal scenarios, cue
parity, and idempotency.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
Scott GarrettandClaude Code committed 2026-11-25 19:48:09 -05:00
1 parent bfa477b799
commit 1040f47542
18 files changed
+4397 -86

No files matched your search

+42
View File
@@ -62,6 +62,18 @@
A910B60318394EB20064028F /* MP42H264Importer.mm in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2351823923100416A4E /* MP42H264Importer.mm */; settings = {COMPILER_FLAGS = "-w -Xanalyzer -analyzer-disable-checker"; }; };
A910B60518394EB20064028F /* MP42VobSubImporter.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2571823923200416A4E /* MP42VobSubImporter.m */; };
A910B60718394EB20064028F /* MP42MkvImporter.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C23F1823923100416A4E /* MP42MkvImporter.m */; };
5AB1E120261124000000000007 /* MP42Ebml.h in Headers */ = {isa = PBXBuildFile; fileRef = 5AB1E120261124000000000001 /* MP42Ebml.h */; settings = {ATTRIBUTES = (Public, ); }; };
5AB1E120261124000000000008 /* MP42Ebml.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AB1E120261124000000000002 /* MP42Ebml.m */; };
5AB1E120261124000000000009 /* MP42Ebml.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AB1E120261124000000000002 /* MP42Ebml.m */; };
5AB1E120261124000000000010 /* MP42MatroskaTagMapping.h in Headers */ = {isa = PBXBuildFile; fileRef = 5AB1E120261124000000000003 /* MP42MatroskaTagMapping.h */; settings = {ATTRIBUTES = (Public, ); }; };
5AB1E120261124000000000011 /* MP42MatroskaTagMapping.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AB1E120261124000000000004 /* MP42MatroskaTagMapping.m */; };
5AB1E120261124000000000012 /* MP42MatroskaTagMapping.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AB1E120261124000000000004 /* MP42MatroskaTagMapping.m */; };
5AB1E120261124000000000013 /* MP42MkvTagWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 5AB1E120261124000000000005 /* MP42MkvTagWriter.h */; settings = {ATTRIBUTES = (Public, ); }; };
5AB1E120261124000000000014 /* MP42MkvTagWriter.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AB1E120261124000000000006 /* MP42MkvTagWriter.m */; };
5AB1E120261124000000000015 /* MP42MkvTagWriter.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AB1E120261124000000000006 /* MP42MkvTagWriter.m */; };
5AB1E120261124000000000024 /* MP42MkvRemuxer.h in Headers */ = {isa = PBXBuildFile; fileRef = 5AB1E120261124000000000021 /* MP42MkvRemuxer.h */; settings = {ATTRIBUTES = (Public, ); }; };
5AB1E120261124000000000025 /* MP42MkvRemuxer.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AB1E120261124000000000022 /* MP42MkvRemuxer.m */; };
5AB1E120261124000000000026 /* MP42MkvRemuxer.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AB1E120261124000000000022 /* MP42MkvRemuxer.m */; };
A910B60918394EB20064028F /* MP42Mp4Importer.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2411823923100416A4E /* MP42Mp4Importer.m */; };
A910B60D18394EB20064028F /* MP42SrtImporter.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C24B1823923100416A4E /* MP42SrtImporter.m */; };
A910B60F18394EB20064028F /* MP42AVFImporter.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2241823923100416A4E /* MP42AVFImporter.m */; };
@@ -401,6 +413,15 @@
A9B9C23D1823923100416A4E /* MP42Metadata.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MP42Metadata.m; sourceTree = "<group>"; };
A9B9C23E1823923100416A4E /* MP42MkvImporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MP42MkvImporter.h; sourceTree = "<group>"; };
A9B9C23F1823923100416A4E /* MP42MkvImporter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MP42MkvImporter.m; sourceTree = "<group>"; };
5AB1E120261124000000000001 /* MP42Ebml.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MP42Ebml.h; sourceTree = "<group>"; };
5AB1E120261124000000000002 /* MP42Ebml.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MP42Ebml.m; sourceTree = "<group>"; };
5AB1E120261124000000000003 /* MP42MatroskaTagMapping.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MP42MatroskaTagMapping.h; sourceTree = "<group>"; };
5AB1E120261124000000000004 /* MP42MatroskaTagMapping.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MP42MatroskaTagMapping.m; sourceTree = "<group>"; };
5AB1E120261124000000000005 /* MP42MkvTagWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MP42MkvTagWriter.h; sourceTree = "<group>"; };
5AB1E120261124000000000006 /* MP42MkvTagWriter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MP42MkvTagWriter.m; sourceTree = "<group>"; };
5AB1E120261124000000000021 /* MP42MkvRemuxer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MP42MkvRemuxer.h; sourceTree = "<group>"; };
5AB1E120261124000000000022 /* MP42MkvRemuxer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MP42MkvRemuxer.m; sourceTree = "<group>"; };
5AB1E120261124000000000023 /* MP42MkvTagWriter+Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MP42MkvTagWriter+Internal.h"; sourceTree = "<group>"; };
A9B9C2401823923100416A4E /* MP42Mp4Importer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MP42Mp4Importer.h; sourceTree = "<group>"; };
A9B9C2411823923100416A4E /* MP42Mp4Importer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MP42Mp4Importer.m; sourceTree = "<group>"; };
A9B9C2421823923100416A4E /* MP42Muxer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MP42Muxer.h; sourceTree = "<group>"; };
@@ -687,6 +708,15 @@
A9B9C2571823923200416A4E /* MP42VobSubImporter.m */,
A9B9C23E1823923100416A4E /* MP42MkvImporter.h */,
A9B9C23F1823923100416A4E /* MP42MkvImporter.m */,
5AB1E120261124000000000001 /* MP42Ebml.h */,
5AB1E120261124000000000002 /* MP42Ebml.m */,
5AB1E120261124000000000003 /* MP42MatroskaTagMapping.h */,
5AB1E120261124000000000004 /* MP42MatroskaTagMapping.m */,
5AB1E120261124000000000005 /* MP42MkvTagWriter.h */,
5AB1E120261124000000000006 /* MP42MkvTagWriter.m */,
5AB1E120261124000000000023 /* MP42MkvTagWriter+Internal.h */,
5AB1E120261124000000000021 /* MP42MkvRemuxer.h */,
5AB1E120261124000000000022 /* MP42MkvRemuxer.m */,
A9B9C2401823923100416A4E /* MP42Mp4Importer.h */,
A9B9C2411823923100416A4E /* MP42Mp4Importer.m */,
A9B9C24A1823923100416A4E /* MP42SrtImporter.h */,
@@ -883,6 +913,10 @@
A9422FC71D4917AF000DB435 /* audio_resample.h in Headers */,
A9B9C2AC1823923200416A4E /* mbs.h in Headers */,
A9B9C2891823923200416A4E /* MP42MkvImporter.h in Headers */,
5AB1E120261124000000000007 /* MP42Ebml.h in Headers */,
5AB1E120261124000000000010 /* MP42MatroskaTagMapping.h in Headers */,
5AB1E120261124000000000013 /* MP42MkvTagWriter.h in Headers */,
5AB1E120261124000000000024 /* MP42MkvRemuxer.h in Headers */,
A96D28931BAD390400403327 /* MP42Metadata+Private.h in Headers */,
A97EA7C71D4B8A2D00257CEA /* FFmpegUtils.h in Headers */,
);
@@ -1042,6 +1076,10 @@
A9ED5B141F824BC100E0E4FA /* MP42SSAImporter.m in Sources */,
A91C3ACF1BF20CF1008BCF87 /* MP42FormatUtilites.mm in Sources */,
A910B60718394EB20064028F /* MP42MkvImporter.m in Sources */,
5AB1E120261124000000000008 /* MP42Ebml.m in Sources */,
5AB1E120261124000000000011 /* MP42MatroskaTagMapping.m in Sources */,
5AB1E120261124000000000014 /* MP42MkvTagWriter.m in Sources */,
5AB1E120261124000000000025 /* MP42MkvRemuxer.m in Sources */,
A9D764321E278B8100ED2F78 /* MP42MetadataUtilities.m in Sources */,
A910B60918394EB20064028F /* MP42Mp4Importer.m in Sources */,
A910B60D18394EB20064028F /* MP42SrtImporter.m in Sources */,
@@ -1099,6 +1137,10 @@
7538B2052505AB1800898792 /* SampleCursor.swift in Sources */,
A9B9C28C1823923200416A4E /* MP42Mp4Importer.m in Sources */,
A9B9C28A1823923200416A4E /* MP42MkvImporter.m in Sources */,
5AB1E120261124000000000009 /* MP42Ebml.m in Sources */,
5AB1E120261124000000000012 /* MP42MatroskaTagMapping.m in Sources */,
5AB1E120261124000000000015 /* MP42MkvTagWriter.m in Sources */,
5AB1E120261124000000000026 /* MP42MkvRemuxer.m in Sources */,
A9B9C2731823923200416A4E /* MP42CCImporter.m in Sources */,
A9B9C2801823923200416A4E /* MP42H264Importer.mm in Sources */,
A9B9C2771823923200416A4E /* MP42ClosedCaptionTrack.m in Sources */,