Skip to content

Commit 4add126

Browse files
committed
Minor tweaks
1 parent 4da5aa2 commit 4add126

11 files changed

+35
-19
lines changed

Gifski.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
isa = PBXContainerItemProxy;
7070
containerPortal = 5F6ABD7D278BA5A20040DDF0 /* gifski.xcodeproj */;
7171
proxyType = 1;
72-
remoteGlobalIDString = CA6080A63FCEFE2C55B82F1B;
72+
remoteGlobalIDString = CA60A67DACCD4143D7A47BBE;
7373
remoteInfo = "gifski-staticlib";
7474
};
7575
E359A4CB28B2A9A2007435A8 /* PBXContainerItemProxy */ = {
@@ -808,7 +808,7 @@
808808
repositoryURL = "https://github.com/sindresorhus/Defaults";
809809
requirement = {
810810
kind = upToNextMajorVersion;
811-
minimumVersion = 7.0.0;
811+
minimumVersion = 7.1.0;
812812
};
813813
};
814814
E3339E982395768F00303839 /* XCRemoteSwiftPackageReference "CircularProgress" */ = {

Gifski/Constants.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Cocoa
2-
import Defaults
32

43
enum Constants {
54
static let defaultWindowSize = CGSize(width: 360, height: 240)

Gifski/ConversionCompletedViewController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import Cocoa
22
import Quartz
33
import UserNotifications
44
import StoreKit
5-
import Defaults
65

76
final class ConversionCompletedViewController: NSViewController {
87
@IBOutlet private var draggableFileWrapper: NSView!

Gifski/ConversionViewController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import AppKit
22
import CircularProgress
33
import DockProgress
4-
import Defaults
54

65
final class ConversionViewController: NSViewController {
76
private static let circularProgressSize = 160.0

Gifski/EditVideoViewController.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import SwiftUI
2-
import Combine
32
import AVKit
4-
import Defaults
53

64
struct SpeedView: View {
75
@Default(.outputSpeed) private var outputSpeed

Gifski/TimeRemainingEstimator.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Foundation
2-
import Combine
32

43
final class TimeRemainingEstimator {
54
private var progressCancellable: AnyCancellable?

Gifski/Tooltip.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import AppKit
2-
import Defaults
32

43
final class Tooltip: NSPopover {
54
private let identifier: String

Gifski/TrimmingAVPlayerViewController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import Combine
21
import AVKit
32

43
/**

Gifski/Utilities.swift

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import StoreKit.SKStoreReviewController
66
import Accelerate.vImage
77
import Defaults
88

9+
typealias Defaults = _Defaults
10+
typealias Default = _Default
11+
typealias AnyCancellable = Combine.AnyCancellable
12+
913

1014
/**
1115
Convenience function for initializing an object and modifying its properties
@@ -750,7 +754,7 @@ extension AVAssetTrack {
750754
// swiftlint:disable:next force_cast
751755
let formatDescription = rawDescription as! CMFormatDescription
752756

753-
return CMFormatDescriptionGetMediaSubType(formatDescription).fourCharCodeToString()
757+
return CMFormatDescriptionGetMediaSubType(formatDescription).fourCharCodeToString().nilIfEmpty
754758
}
755759

756760
// TODO: When I switch to the async `.load()` method to retrieve video properties, this property is moot.
@@ -1265,7 +1269,7 @@ extension AVAsset {
12651269
Audio codec: \(describing: audioCodec)
12661270
Duration: \(describing: durationFormatter.stringSafe(from: duration.seconds))
12671271
Dimension: \(describing: dimensions?.formatted)
1268-
Frame rate: \(describing: frameRate?.rounded(toDecimalPlaces: 2).formatted)
1272+
Frame rate: \(describing: frameRate?.rounded(toDecimalPlaces: 2).formatted())
12691273
File size: \(fileSizeFormatted)
12701274
Is readable: \(isReadable)
12711275
Is playable: \(isPlayable)
@@ -1284,7 +1288,7 @@ extension AVAsset {
12841288
Duration: \(describing: durationFormatter.stringSafe(from: track.timeRange.duration.seconds))
12851289
Dimensions: \(describing: track.dimensions?.formatted)
12861290
Natural size: \(describing: track.naturalSize)
1287-
Frame rate: \(describing: track.frameRate?.rounded(toDecimalPlaces: 2).formatted)
1291+
Frame rate: \(describing: track.frameRate?.rounded(toDecimalPlaces: 2).formatted())
12881292
Is playable: \(track.isPlayable)
12891293
Is decodable: \(track.isDecodable)
12901294
----
@@ -3920,7 +3924,6 @@ extension NSAttributedString {
39203924
}
39213925

39223926
static func += (lhs: inout NSAttributedString, rhs: NSAttributedString) {
3923-
// swiftlint:disable:next shorthand_operator
39243927
lhs = lhs + rhs
39253928
}
39263929

@@ -4446,7 +4449,6 @@ extension CMTime {
44464449
}
44474450

44484451
static func *= (lhs: inout Self, rhs: Double) {
4449-
// swiftlint:disable:next shorthand_operator
44504452
lhs = lhs * rhs
44514453
}
44524454

@@ -4455,7 +4457,6 @@ extension CMTime {
44554457
}
44564458

44574459
static func /= (lhs: inout Self, rhs: Double) {
4458-
// swiftlint:disable:next shorthand_operator
44594460
lhs = lhs / rhs
44604461
}
44614462
}
@@ -4687,3 +4688,11 @@ extension ClosedRange {
46874688
bound1 <= bound2 ? bound1...bound2 : bound2...bound1
46884689
}
46894690
}
4691+
4692+
4693+
extension Collection {
4694+
/**
4695+
Works on strings too, since they're just collections.
4696+
*/
4697+
var nilIfEmpty: Self? { isEmpty ? nil : self }
4698+
}

Gifski/VideoValidator.swift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ struct VideoValidator {
9494
return .failure
9595
}
9696

97+
let cannotReadVideoExplanation = "This could happen if the video is corrupt or the codec profile level is not supported. macOS unfortunately doesn't provide Gifski a reason for why the video could not be decoded. Try re-exporting using a different configuration or try converting the video to HEVC (MP4) with the free HandBrake app."
98+
9799
// We already specify the UTIs we support, so this can only happen on invalid video files or unsupported codecs.
98100
guard asset.isVideoDecodable else {
99101
if
@@ -103,7 +105,7 @@ struct VideoValidator {
103105
NSAlert.showModalAndReportToCrashlytics(
104106
for: window,
105107
title: "The video could not be decoded even though its codec “\(codec)” is supported.",
106-
message: "This could happen if the video is corrupt or the codec profile level is not supported. macOS unfortunately doesn't provide Gifski a reason for why the video could not be decoded. Try re-exporting using a different configuration or try converting the video to HEVC (MP4) with the free HandBrake app.",
108+
message: cannotReadVideoExplanation,
107109
showDebugInfo: false,
108110
debugInfo: asset.debugInfo
109111
)
@@ -132,10 +134,21 @@ struct VideoValidator {
132134
return .failure
133135
}
134136

135-
NSAlert.showModalAndReportToCrashlytics(
137+
NSAlert.showModal(
136138
for: window,
137139
title: "The video codec “\(codecTitle)” is not supported.",
138-
message: "Re-export or convert the video to a supported format. For the best possible quality, export to ProRes 4444 XQ (supports alpha). Alternatively, use the free HandBrake app to convert the video to HEVC (MP4).",
140+
message: "Re-export or convert the video to a supported format. For the best possible quality, export to ProRes 4444 XQ (supports alpha). Alternatively, use the free HandBrake app to convert the video to HEVC (MP4)."
141+
)
142+
143+
return .failure
144+
}
145+
146+
// AVFoundation reports some videos as `.isReadable == true` even though they are not. We detect this through missing codec info. See "Fixture 211". (macOS 13.1)
147+
guard firstVideoTrack.codecTitle != nil else {
148+
NSAlert.showModalAndReportToCrashlytics(
149+
for: window,
150+
title: "The video file is not supported.",
151+
message: cannotReadVideoExplanation,
139152
showDebugInfo: false,
140153
debugInfo: asset.debugInfo
141154
)

0 commit comments

Comments
 (0)