Fix timelapse export breaking
This commit is contained in:
parent
1e81810e01
commit
a506bb2a80
3 changed files with 33 additions and 10 deletions
|
@ -270,10 +270,12 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations {
|
|||
mainComposition.frameDuration = CMTimeMake(value: 1, timescale: 30)
|
||||
mainComposition.renderSize = CGSize(width: document!.info.videoFrame.0, height: document!.info.videoFrame.1)
|
||||
|
||||
self.exporter = AVAssetExportSession(asset: mixComposition, presetName: AVAssetExportPresetHighestQuality)
|
||||
self.exporter = AVAssetExportSession(asset: mixComposition, presetName: AVAssetExportPresetMediumQuality)
|
||||
self.exporter?.outputURL = savePanel.url!
|
||||
self.exporter?.videoComposition = mainComposition
|
||||
|
||||
try? FileManager.default.removeItem(at: (self.exporter?.outputURL)!)
|
||||
|
||||
switch(savePanel.allowedFileTypes![0]) {
|
||||
case "mp4":
|
||||
self.exporter?.outputFileType = .mp4;
|
||||
|
@ -291,18 +293,32 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations {
|
|||
let alert = NSAlert()
|
||||
alert.messageText = "Exporting timelapse..."
|
||||
alert.addButton(withTitle: "Cancel")
|
||||
|
||||
let timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { timer in
|
||||
alert.messageText = String(format: "Exporting timelapse... %2.0f%%", self.exporter!.progress * 100.0)
|
||||
}
|
||||
|
||||
self.exporter?.exportAsynchronously {
|
||||
timer.invalidate()
|
||||
|
||||
DispatchQueue.main.sync {
|
||||
if self.exporter?.status == .completed {
|
||||
alert.window.close()
|
||||
} else {
|
||||
if let errorMessage = self.exporter?.error?.localizedDescription {
|
||||
alert.messageText = errorMessage
|
||||
} else {
|
||||
alert.messageText = "An unknown error occurred."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
alert.beginSheetModal(for: originalWindow) { (resonse) in
|
||||
self.exporter?.cancelExport()
|
||||
alert.window.close()
|
||||
}
|
||||
|
||||
self.exporter?.exportAsynchronously {
|
||||
if self.exporter?.status != .cancelled {
|
||||
DispatchQueue.main.sync {
|
||||
alert.window.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -375,6 +375,9 @@ Dk51bWJlciBvZiBMYXllcnM
|
|||
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="y0M-Hn-T88">
|
||||
<rect key="frame" x="0.0" y="0.0" width="485" height="269"/>
|
||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="tHf-wP-P5i"/>
|
||||
<connections>
|
||||
<segue destination="qzy-T7-vHd" kind="show" identifier="showTimelapse" id="5t3-ps-pEB"/>
|
||||
</connections>
|
||||
</imageView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
|
@ -413,7 +416,7 @@ Dk51bWJlciBvZiBMYXllcnM
|
|||
</viewController>
|
||||
<customObject id="2Tp-Fl-jBw" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="132" y="725"/>
|
||||
<point key="canvasLocation" x="89" y="697"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
||||
|
|
|
@ -251,6 +251,10 @@ class Document: NSDocument {
|
|||
}
|
||||
|
||||
func parseBasicObject(key: Any?) -> Any? {
|
||||
if key == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if let objectsArray = self.dict?["$objects"] as? NSArray {
|
||||
let classID = getClassID(id: key)
|
||||
|
||||
|
|
Reference in a new issue