Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions Base.lproj/AdvancedPrefsViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,33 @@
</connections>
</popUpButton>
<textField focusRingType="none" verticalHuggingPriority="750" preferredMaxLayoutWidth="400" translatesAutoresizingMaskIntoConstraints="NO" id="hgg-QV-i0I">
<rect key="frame" x="18" y="294" width="133" height="16"/>
<rect key="frame" x="18" y="314" width="133" height="16"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Alternate Groups:" id="agM-jg-8mH">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField focusRingType="none" verticalHuggingPriority="750" preferredMaxLayoutWidth="400" translatesAutoresizingMaskIntoConstraints="NO" id="exotic-audio-label">
<rect key="frame" x="18" y="132" width="133" height="16"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Exotic audio:" id="exotic-audio-label-cell">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" verticalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="exotic-audio-checkbox">
<rect key="frame" x="155" y="131" width="263" height="18"/>
<buttonCell key="cell" type="check" title="Disable multi-channel tracks by default" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="exotic-audio-checkbox-cell">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="3" name="value" keyPath="values.SBDisableExoticAudio" id="exotic-audio-binding"/>
</connections>
</button>
<button verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" verticalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="QpA-Yd-jpF">
<rect key="frame" x="155" y="291" width="238" height="18"/>
<rect key="frame" x="155" y="271" width="187" height="18"/>
<buttonCell key="cell" type="check" title="Infer media characteristics" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="86R-Dj-j6Y">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
Expand Down Expand Up @@ -232,6 +251,7 @@
</connections>
</popUpButton>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="edJ-A5-eyf">
<rect key="frame" x="172" y="162" width="92" height="18"/>
<rect key="frame" x="172" y="142" width="92" height="18"/>
<buttonCell key="cell" type="check" title="Keep AC-3" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="Zgy-z5-6UG">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
Expand Down Expand Up @@ -285,13 +305,19 @@
<constraint firstItem="101" firstAttribute="leading" secondItem="hgg-QV-i0I" secondAttribute="leading" id="V5i-g6-rPa"/>
<constraint firstItem="olE-Dy-uJm" firstAttribute="leading" secondItem="101" secondAttribute="trailing" constant="8" id="Wck-0t-JIW"/>
<constraint firstItem="Pud-GM-vyU" firstAttribute="leading" secondItem="189" secondAttribute="leading" id="Wxi-ZW-QRQ"/>
<constraint firstItem="115" firstAttribute="top" secondItem="edJ-A5-eyf" secondAttribute="bottom" constant="20" id="ZB0-Ig-fhK"/>
<constraint firstItem="115" firstAttribute="top" secondItem="edJ-A5-eyf" secondAttribute="bottom" constant="40" id="ZB0-Ig-fhK"/>
<constraint firstItem="hjZ-wQ-Sbb" firstAttribute="leading" secondItem="101" secondAttribute="trailing" constant="8" id="ZKS-d6-oJ6"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="edJ-A5-eyf" secondAttribute="trailing" constant="20" symbolic="YES" id="ZYM-ne-01S"/>
<constraint firstItem="olE-Dy-uJm" firstAttribute="top" secondItem="hjZ-wQ-Sbb" secondAttribute="bottom" constant="7" id="ZpI-qc-wxr"/>
<constraint firstItem="ETf-LE-57P" firstAttribute="leading" secondItem="Pud-GM-vyU" secondAttribute="trailing" constant="7" id="avr-Vp-M13"/>
<constraint firstItem="Z2f-U9-9ZT" firstAttribute="width" secondItem="Pud-GM-vyU" secondAttribute="width" id="cXa-gD-TzD"/>
<constraint firstItem="113" firstAttribute="width" secondItem="189" secondAttribute="width" id="dg6-kk-hDf"/>
<constraint firstItem="exotic-audio-checkbox" firstAttribute="baseline" secondItem="exotic-audio-label" secondAttribute="baseline" id="exotic-audio-checkbox-baseline"/>
<constraint firstItem="exotic-audio-checkbox" firstAttribute="leading" secondItem="exotic-audio-label" secondAttribute="trailing" constant="8" id="exotic-audio-checkbox-leading"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="exotic-audio-checkbox" secondAttribute="trailing" constant="20" symbolic="YES" id="exotic-audio-checkbox-trailing"/>
<constraint firstItem="exotic-audio-label" firstAttribute="leading" secondItem="hgg-QV-i0I" secondAttribute="leading" id="exotic-audio-label-leading"/>
<constraint firstItem="exotic-audio-label" firstAttribute="top" secondItem="edJ-A5-eyf" secondAttribute="bottom" constant="15" id="exotic-audio-label-top"/>
<constraint firstItem="exotic-audio-label" firstAttribute="width" secondItem="hgg-QV-i0I" secondAttribute="width" id="exotic-audio-label-width"/>
<constraint firstItem="191" firstAttribute="baseline" secondItem="201" secondAttribute="baseline" id="fjE-Sl-C45"/>
<constraint firstItem="rmU-Gb-jzF" firstAttribute="top" secondItem="olE-Dy-uJm" secondAttribute="bottom" constant="5" id="hEg-lY-NlJ"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="fTk-UL-aoX" secondAttribute="trailing" constant="20" symbolic="YES" id="hvb-cB-oAO"/>
Expand Down
14 changes: 14 additions & 0 deletions Classes/Document.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,21 @@ final class Document: NSDocument {
override func read(from url: URL, ofType typeName: String) throws {
do {
mp4 = try MP42File(url: url)
// Check if this is an AAC file with more than 2 channels that needs downmixing
for track in mp4.tracks {
if let audioTrack = track as? MP42AudioTrack,
audioTrack.format == kMP42AudioCodecType_MPEG4AAC,
audioTrack.channels > 2,
audioTrack.fallbackTrack == nil,
Prefs.audioMixdown != 0 {
// Clear the mp4 property and mark as unsupported
mp4 = MP42File()
unsupportedMp4Brand = true
}
}
} catch {
// Clear the mp4 property when marking as unsupported
mp4 = MP42File()
unsupportedMp4Brand = true
}
}
Expand Down
56 changes: 49 additions & 7 deletions Classes/FileImportController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ final class FileImportController: ViewController, NSTableViewDataSource, NSTable
tag: 6,
enabled: true)
actions.append(conversionAction)
let conversionAction2 = Action(title: NSLocalizedString("AAC + AC3", comment: "File Import action menu item."),
tag: 7,
enabled: true)
actions.append(conversionAction2)
}

if (track.format == kMP42AudioCodecType_Opus || track.format == kMP42AudioCodecType_TrueHD) && channelCount > 2 {
let conversionAction = Action(title: NSLocalizedString("AAC + AC3", comment: "File Import action menu item."),
tag: 7,
enabled: true)
actions.append(conversionAction)
}

default:
Expand All @@ -132,13 +143,44 @@ final class FileImportController: ViewController, NSTableViewDataSource, NSTable
self.actions = actions

// Set the action menu selection
// AAC, 6 channel Specific actions
if track.format == kMP42AudioCodecType_MPEG4AAC,
let audioTrack = track as? MP42AudioTrack,
audioTrack.channels > 2,
Prefs.audioMixdown != 0 {
// This handles AAC, 6 ch without any fallback stereo track
if audioTrack.fallbackTrack != nil {
self.selectedActionTag = 0 // Passthru
} else {
self.selectedActionTag = 7 // AAC + AC3
}
}

// Exotic audio Specific actions
else if (track.format == kMP42AudioCodecType_Opus || track.format == kMP42AudioCodecType_TrueHD),
let audioTrack = track as? MP42AudioTrack {
if audioTrack.channels > 2 {
if Prefs.disableExoticAudio {
// If multi-channelexotic audio is disabled, we default to off and AAC - Multichannel
self.checked = false
self.selectedActionTag = 5 // AAC - Multichannel
} else {
// If multi-channel exotic audio is enabled, we default to AAC + AC3
self.selectedActionTag = 7 // AAC + AC3
}
} else {
// Otherwise, default to AAC - Stereo
self.selectedActionTag = 3 // AAC - Stereo
}
}

// AC-3 Specific actions
if (track.format == kMP42AudioCodecType_AC3 || track.format == kMP42AudioCodecType_EnhancedAC3) &&
else if (track.format == kMP42AudioCodecType_AC3 || track.format == kMP42AudioCodecType_EnhancedAC3) &&
Prefs.audioConvertAC3, let audioTrack = track as? MP42AudioTrack {
if Prefs.audioKeepAC3 && audioTrack.fallbackTrack == nil {
self.selectedActionTag = 6
self.selectedActionTag = 6 // AAC + Passthru
} else if audioTrack.fallbackTrack != nil {
self.selectedActionTag = 0
self.selectedActionTag = 0 // Passthru
} else {
self.selectedActionTag = Prefs.audioMixdown
}
Expand All @@ -147,7 +189,7 @@ final class FileImportController: ViewController, NSTableViewDataSource, NSTable
else if track.format == kMP42AudioCodecType_DTS &&
Prefs.audioConvertDts, let audioTrack = track as? MP42AudioTrack {
if audioTrack.fallbackTrack != nil {
self.selectedActionTag = 0
self.selectedActionTag = 0 // Passthru
}
else {
switch Prefs.audioDtsOptions {
Expand All @@ -159,18 +201,18 @@ final class FileImportController: ViewController, NSTableViewDataSource, NSTable
}
// Vobsub
else if track.format == kMP42SubtitleCodecType_VobSub && Prefs.subtitleConvertBitmap {
self.selectedActionTag = 1
self.selectedActionTag = 1 // Tx3g
}
// Generic actions
else if needsConversion {
if track is MP42AudioTrack {
self.selectedActionTag = Prefs.audioMixdown
} else {
self.selectedActionTag = 1
self.selectedActionTag = 1 // Tx3g
}
}
else {
self.selectedActionTag = 0
self.selectedActionTag = 0 // Passthru
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion Classes/Prefs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ enum Prefs {
_audioBitrate, _audioDRC, _audioConvertAC3, _audioKeepAC3, _audioConvertDts,
_audioDtsOptions, _subtitleConvertBitmap, _ratingsCountry, _chaptersPreviewPosition,
_chaptersPreviewTrack, _mp464bitOffset, _mp464bitTimes, _mp4SaveAsOptimize, _forceHvc1,
_logFormat])
_logFormat,_disableExoticAudio])
}

@Stored(key: "NSApplicationCrashOnException", defaultValue: true)
Expand Down Expand Up @@ -161,6 +161,9 @@ enum Prefs {

@Stored(key: "SBLogFormat", defaultValue: 0)
static var logFormat: Int // 0 = Time Only, 1 = Date and Time

@Stored(key: "SBDisableExoticAudio", defaultValue: true)
static var disableExoticAudio: Bool
}

enum MetadataPrefs {
Expand Down
Loading