Files
MP42Foundation/MP42/MP42ConversionSettings.h
Scott GarrettandClaude Code 57772086a5 Convert Matroska PGS tracks to VobSub and name flagged tracks SDH
A PGS track inside an MKV can now be muxed as a real subp track: the
muxer's bitmap-converter branch recognizes a PGS source with a VobSub
target (new MP42ConversionSettings subtitlesVobSubConversion) and uses
the new MP42PgsToVobSubConverter instead of MP42BitmapSubConverter.

The converter rebuilds the PGS elementary stream from the source
container up-front, because mkvmerge stores each PGS segment with its
13-byte "PG" envelope removed (type + 2-byte length + payload,
zlib-compressed) — a plain concatenation of demuxed blocks is not a
.sup. Each block is walked segment-by-segment and the envelope is
restored as PG + 90 kHz pts (from the block's nanosecond timestamp) +
four zero bytes + type + length, byte-identical to what mkvextract
writes; blocks that already carry envelopes pass through verbatim. The
rebuilt temp .sup then rides the existing MP42VobSubImporter wholesale
for palette, DVD geometry, and raw-SPU samples, which replay through
copyEncodedSample while the live muxing stream is discarded.

Subtitle type recognition now names any flagged track "SDH" (hearing
impaired, commentary, forced, lyrics, closed captions) instead of a
per-type name, and MKV container tracks get the same treatment on the
conversion path: the TrackEntry Name runs through the recognizer, or
the MKV's own filename when there is no Name element. tagsOnly mode
stays verbatim — that model is the tag writer's diff baseline.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-28 20:00:08 -05:00

48 lines
1.4 KiB
Objective-C

//
// MP42ConversionSettings.h
// MP42Foundation
//
// Created by Damiano Galassi on 12/09/2016.
// Copyright © 2022 Damiano Galassi. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <MP42Foundation/MP42MediaFormat.h>
NS_ASSUME_NONNULL_BEGIN
@interface MP42ConversionSettings : NSObject <NSCopying, NSSecureCoding>
+ (instancetype)subtitlesConversion;
// Convert a bitmap subtitle (VobSub/PGS) *to* VobSub rather than to tx3g —
// the muxer picks MP42PgsToVobSubConverter when the source is PGS and this
// is the requested format (a PGS-in-MKV track muxed as a real MP4 subp track).
+ (instancetype)subtitlesVobSubConversion;
@property (nonatomic, readonly) FourCharCode format;
@end
@interface MP42AudioConversionSettings : MP42ConversionSettings <NSCopying, NSSecureCoding>
+ (instancetype)audioConversionWithBitRate:(UInt32)bitrate mixDown:(MP42AudioMixdown)mixDown drc:(float)drc;
- (instancetype)initWithFormat:(FourCharCode)format bitRate:(UInt32)bitRate mixDown:(MP42AudioMixdown)mixDown drc:(float)drc;
@property (nonatomic, readonly) UInt32 bitRate;
@property (nonatomic, readonly) MP42AudioMixdown mixDown;
@property (nonatomic, readonly) float drc;
@end
@interface MP42RawConversionSettings : MP42ConversionSettings <NSCopying, NSSecureCoding>
+ (instancetype)rawConversionWithFrameRate:(NSUInteger)frameRate;
@property (nonatomic, readonly) NSUInteger frameRate;
@end
NS_ASSUME_NONNULL_END