diff --git a/SilicaViewer/AppDelegate.swift b/SilicaViewer/AppDelegate.swift
index 0c4d060..5b93b91 100644
--- a/SilicaViewer/AppDelegate.swift
+++ b/SilicaViewer/AppDelegate.swift
@@ -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()
- }
- }
- }
+
}
}
}
diff --git a/SilicaViewer/Base.lproj/Main.storyboard b/SilicaViewer/Base.lproj/Main.storyboard
index ff97351..817d766 100644
--- a/SilicaViewer/Base.lproj/Main.storyboard
+++ b/SilicaViewer/Base.lproj/Main.storyboard
@@ -375,6 +375,9 @@ Dk51bWJlciBvZiBMYXllcnM
+
+
+
@@ -413,7 +416,7 @@ Dk51bWJlciBvZiBMYXllcnM
-
+
diff --git a/SilicaViewer/Document.swift b/SilicaViewer/Document.swift
index a60dffc..561eac7 100644
--- a/SilicaViewer/Document.swift
+++ b/SilicaViewer/Document.swift
@@ -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)