├── test.gif
├── STMovingImages
├── earth
│ ├── earth_01.jpg
│ ├── earth_02.jpg
│ ├── earth_03.jpg
│ ├── earth_04.jpg
│ ├── earth_05.jpg
│ ├── earth_06.jpg
│ ├── earth_07.jpg
│ ├── earth_08.jpg
│ ├── earth_09.jpg
│ ├── earth_10.jpg
│ ├── earth_11.jpg
│ └── earth_12.jpg
├── STMovingImages.xcodeproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ ├── xcshareddata
│ │ └── xcschemes
│ │ │ ├── STMoviewImage_OSX.xcscheme
│ │ │ └── STMovingImages_iOS.xcscheme
│ └── project.pbxproj
├── STMovingImages_iOS
│ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── ViewController.swift
│ ├── Info.plist
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ └── AppDelegate.swift
├── STGIFMaker.swift
├── STMoviewImage_OSX
│ └── main.swift
└── STMovieMaker.swift
├── README.md
├── LICENSE
└── .gitignore
/test.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nst/STMovingImages/master/test.gif
--------------------------------------------------------------------------------
/STMovingImages/earth/earth_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nst/STMovingImages/master/STMovingImages/earth/earth_01.jpg
--------------------------------------------------------------------------------
/STMovingImages/earth/earth_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nst/STMovingImages/master/STMovingImages/earth/earth_02.jpg
--------------------------------------------------------------------------------
/STMovingImages/earth/earth_03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nst/STMovingImages/master/STMovingImages/earth/earth_03.jpg
--------------------------------------------------------------------------------
/STMovingImages/earth/earth_04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nst/STMovingImages/master/STMovingImages/earth/earth_04.jpg
--------------------------------------------------------------------------------
/STMovingImages/earth/earth_05.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nst/STMovingImages/master/STMovingImages/earth/earth_05.jpg
--------------------------------------------------------------------------------
/STMovingImages/earth/earth_06.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nst/STMovingImages/master/STMovingImages/earth/earth_06.jpg
--------------------------------------------------------------------------------
/STMovingImages/earth/earth_07.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nst/STMovingImages/master/STMovingImages/earth/earth_07.jpg
--------------------------------------------------------------------------------
/STMovingImages/earth/earth_08.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nst/STMovingImages/master/STMovingImages/earth/earth_08.jpg
--------------------------------------------------------------------------------
/STMovingImages/earth/earth_09.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nst/STMovingImages/master/STMovingImages/earth/earth_09.jpg
--------------------------------------------------------------------------------
/STMovingImages/earth/earth_10.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nst/STMovingImages/master/STMovingImages/earth/earth_10.jpg
--------------------------------------------------------------------------------
/STMovingImages/earth/earth_11.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nst/STMovingImages/master/STMovingImages/earth/earth_11.jpg
--------------------------------------------------------------------------------
/STMovingImages/earth/earth_12.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nst/STMovingImages/master/STMovingImages/earth/earth_12.jpg
--------------------------------------------------------------------------------
/STMovingImages/STMovingImages.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # STMovingImages
2 | Create .MOV and .GIF from NSImages in Swift 3
3 |
4 | #### Create .GIF
5 |
6 | For macOS and iOS
7 |
8 | let gm = STGIFMaker(destinationPath: "/tmp/test.gif", loop: true)!
9 |
10 | for i in images {
11 | gm.append(image: i, duration: 0.5)
12 | }
13 |
14 | gm.write()
15 |
16 | 
17 |
18 | #### Create .MOV
19 |
20 | For macOS only (for now)
21 |
22 | let mm = STMovieMaker(path: "/tmp/test.mov",
23 | frameSize: CGSize(width:600, height:300),
24 | fps: 2)!
25 |
26 | for i in images {
27 | mm.append(i)
28 | }
29 |
30 | mm.write { (path) in
31 | //
32 | }
33 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Nicolas Seriot
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/STMovingImages/STMovingImages_iOS/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/STMovingImages/STMovingImages_iOS/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // STMovingImages_iOS
4 | //
5 | // Created by Nicolas Seriot on 09.11.16.
6 | // Copyright © 2016 ch.seriot. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class ViewController: UIViewController {
12 |
13 | func makeGIF() {
14 |
15 | let documentsPath = NSURL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0])
16 | guard let path = documentsPath.appendingPathComponent("test.gif")?.path else { assertionFailure(); return }
17 |
18 | guard let gm = STGIFMaker(destinationPath: path, loop: true) else {
19 | assertionFailure();
20 | return
21 | }
22 |
23 | for i in 1...12 {
24 | let s = String(format: "%02d", i)
25 | guard let image = UIImage(named:"earth_\(s).jpg") else { continue }
26 |
27 | gm.append(image: image, duration: 0.5)
28 | }
29 |
30 | _ = gm.write()
31 | }
32 |
33 | override func viewDidLoad() {
34 | super.viewDidLoad()
35 | // Do any additional setup after loading the view, typically from a nib.
36 |
37 | makeGIF()
38 | }
39 |
40 | override func didReceiveMemoryWarning() {
41 | super.didReceiveMemoryWarning()
42 | // Dispose of any resources that can be recreated.
43 | }
44 |
45 |
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/STMovingImages/STMovingImages_iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## Build generated
6 | build/
7 | DerivedData/
8 |
9 | ## Various settings
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata/
19 |
20 | ## Other
21 | *.moved-aside
22 | *.xcuserstate
23 |
24 | ## Obj-C/Swift specific
25 | *.hmap
26 | *.ipa
27 | *.dSYM.zip
28 | *.dSYM
29 |
30 | ## Playgrounds
31 | timeline.xctimeline
32 | playground.xcworkspace
33 |
34 | # Swift Package Manager
35 | #
36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
37 | # Packages/
38 | .build/
39 |
40 | # CocoaPods
41 | #
42 | # We recommend against adding the Pods directory to your .gitignore. However
43 | # you should judge for yourself, the pros and cons are mentioned at:
44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
45 | #
46 | # Pods/
47 |
48 | # Carthage
49 | #
50 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
51 | # Carthage/Checkouts
52 |
53 | Carthage/Build
54 |
55 | # fastlane
56 | #
57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
58 | # screenshots whenever they are needed.
59 | # For more information about the recommended setup visit:
60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
61 |
62 | fastlane/report.xml
63 | fastlane/Preview.html
64 | fastlane/screenshots
65 | fastlane/test_output
66 |
--------------------------------------------------------------------------------
/STMovingImages/STMovingImages_iOS/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/STMovingImages/STMovingImages_iOS/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/STMovingImages/STGIFMaker.swift:
--------------------------------------------------------------------------------
1 | //
2 | // STGIFMaker.swift
3 | // STMovingImages
4 | //
5 | // Created by nst on 21/11/15.
6 | // Copyright © 2015 Nicolas Seriot. All rights reserved.
7 | //
8 |
9 | #if os(OSX)
10 | import AppKit
11 | import CoreServices
12 | public typealias STImage = NSImage
13 | #elseif os(iOS)
14 | import UIKit
15 | import MobileCoreServices
16 | import CoreGraphics
17 | import ImageIO
18 | public typealias STImage = UIImage
19 | #endif
20 |
21 | public class STGIFMaker {
22 |
23 | let imageDestination : CGImageDestination
24 | let outPath : String
25 |
26 | init?(destinationPath: String, loop: Bool) {
27 |
28 | guard let id = CGImageDestinationCreateWithURL(
29 | URL(fileURLWithPath: destinationPath) as CFURL,
30 | kUTTypeGIF,
31 | 0,
32 | nil) else {
33 | return nil
34 | }
35 |
36 | self.imageDestination = id
37 | self.outPath = destinationPath
38 |
39 | let loopCount = loop ? 0 : 1
40 | let gifProperties = [ kCGImagePropertyGIFDictionary as String : [kCGImagePropertyGIFLoopCount as String:loopCount] ] as CFDictionary
41 |
42 | CGImageDestinationSetProperties(imageDestination, gifProperties)
43 | }
44 |
45 | func append(image : STImage, duration : Double) {
46 | #if os(OSX)
47 | let optCGImage = image.cgImage(forProposedRect: nil, context: nil, hints: nil)
48 | #elseif os(iOS)
49 | let optCGImage = image.cgImage
50 | #endif
51 |
52 | guard let cgImage = optCGImage else { assertionFailure(); return }
53 | let frameProperties = [ kCGImagePropertyGIFDictionary as String : [kCGImagePropertyGIFDelayTime as String:duration] ] as CFDictionary
54 | CGImageDestinationAddImage(imageDestination, cgImage, frameProperties)
55 | }
56 |
57 | func write() -> Bool {
58 |
59 | let success = CGImageDestinationFinalize(imageDestination)
60 |
61 | if success {
62 | print("-- wrote \(outPath)")
63 | }
64 |
65 | return success
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/STMovingImages/STMovingImages_iOS/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // STMovingImages_iOS
4 | //
5 | // Created by Nicolas Seriot on 09.11.16.
6 | // Copyright © 2016 ch.seriot. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 |
17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
18 | // Override point for customization after application launch.
19 | return true
20 | }
21 |
22 | func applicationWillResignActive(_ application: UIApplication) {
23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
25 | }
26 |
27 | func applicationDidEnterBackground(_ application: UIApplication) {
28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30 | }
31 |
32 | func applicationWillEnterForeground(_ application: UIApplication) {
33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
34 | }
35 |
36 | func applicationDidBecomeActive(_ application: UIApplication) {
37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
38 | }
39 |
40 | func applicationWillTerminate(_ application: UIApplication) {
41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42 | }
43 |
44 |
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/STMovingImages/STMoviewImage_OSX/main.swift:
--------------------------------------------------------------------------------
1 | //
2 | // main.swift
3 | // MovieMaker
4 | //
5 | // Created by nst on 05.11.16.
6 | // Copyright © 2016 Nicolas Seriot. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import AppKit
11 |
12 | func makeMovie() {
13 |
14 | guard let mm = STMovieMaker(
15 | path: "/tmp/test.mov",
16 | frameSize: CGSize(width:600, height:300),
17 | fps: 2) else {
18 | assertionFailure();
19 | return
20 | }
21 |
22 | for i in 1...12 {
23 | let s = String(format: "%02d", i)
24 | let path = "/System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/ImageKit.framework/Versions/A/Resources/earth_\(s).jpg"
25 | guard let image = NSImage(byReferencingFile: path) else { continue }
26 | _ = mm.append(image:image)
27 | }
28 |
29 | mm.write { (path) in
30 | //
31 | }
32 | }
33 |
34 | func makeGIF() {
35 |
36 | guard let gm = STGIFMaker(destinationPath: "/tmp/test.gif", loop: true) else {
37 | assertionFailure();
38 | return
39 | }
40 |
41 | for i in 1...12 {
42 | let s = String(format: "%02d", i)
43 | let path = "/System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/ImageKit.framework/Versions/A/Resources/earth_\(s).jpg"
44 | guard let image = NSImage(byReferencingFile: path) else { continue }
45 |
46 | gm.append(image: image, duration: 0.5)
47 | }
48 |
49 | _ = gm.write()
50 | }
51 |
52 | func makeMovieWithDrawings() {
53 |
54 | guard let mm = STMovieMaker(
55 | path: "/tmp/test2.mov",
56 | frameSize: CGSize(width:600, height:300),
57 | fps: 2) else {
58 | assertionFailure();
59 | return
60 | }
61 |
62 | for i in 1...12 {
63 | let s = String(format: "%02d", i)
64 | let path = "/System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/ImageKit.framework/Versions/A/Resources/earth_\(s).jpg"
65 | guard let image = NSImage(byReferencingFile: path) else { continue }
66 | _ = mm.appendImageFromDrawing({ (c) in
67 |
68 | // draw image
69 | let rect = CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height)
70 | image.draw(in: rect)
71 |
72 | // draw string frame
73 | let STRING_RECT_ORIGIN_X : CGFloat = rect.size.width - 60
74 | let STRING_RECT_ORIGIN_Y : CGFloat = 30
75 | let STRING_RECT_WIDTH : CGFloat = 40
76 | let STRING_RECT_HEIGHT : CGFloat = 30
77 | let stringRect : CGRect = CGRect(x: STRING_RECT_ORIGIN_X, y: STRING_RECT_ORIGIN_Y, width: STRING_RECT_WIDTH, height: STRING_RECT_HEIGHT);
78 |
79 | NSColor.white.setFill()
80 | NSColor.black.setStroke()
81 | NSRectFill(stringRect)
82 | NSBezierPath.stroke(stringRect)
83 |
84 | // draw string
85 | let font = NSFont(name:"Courier", size:24)!
86 | let attributes : [String:AnyObject] = [NSFontAttributeName:font, NSForegroundColorAttributeName:NSColor.blue]
87 |
88 | let s = NSAttributedString(string: s, attributes: attributes)
89 | s.draw(at: CGPoint(x: STRING_RECT_ORIGIN_X + 6, y: STRING_RECT_ORIGIN_Y + 2))
90 | })
91 | }
92 |
93 | mm.write { (path) in
94 | //
95 | }
96 | }
97 |
98 | makeMovie()
99 | makeGIF()
100 | makeMovieWithDrawings()
101 |
102 | RunLoop.main.run()
103 |
--------------------------------------------------------------------------------
/STMovingImages/STMovingImages.xcodeproj/xcshareddata/xcschemes/STMoviewImage_OSX.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/STMovingImages/STMovingImages.xcodeproj/xcshareddata/xcschemes/STMovingImages_iOS.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/STMovingImages/STMovieMaker.swift:
--------------------------------------------------------------------------------
1 | //
2 | // STMovieMaker.swift
3 | // STMovingImages
4 | //
5 | // Created by nst on 08/01/16.
6 | // Copyright © 2016 Nicolas Seriot. All rights reserved.
7 | //
8 |
9 | // adapted from Erica Sadun's MovieMaker class
10 | // https://github.com/erica/useful-things/tree/master/useful%20pack/Movie%20Maker
11 |
12 | import AppKit
13 | import AVFoundation
14 |
15 | open class STMovieMaker {
16 |
17 | fileprivate var height : Int
18 | fileprivate var width : Int
19 | fileprivate var framesPerSecond : UInt = 0
20 | fileprivate var frameCount : UInt = 0
21 |
22 | fileprivate var writer : AVAssetWriter!
23 | fileprivate var input : AVAssetWriterInput?
24 | fileprivate var adaptor : AVAssetWriterInputPixelBufferAdaptor?
25 |
26 | public init?(path:String, frameSize:CGSize, fps:UInt) {
27 |
28 | self.height = Int(frameSize.height)
29 | self.width = Int(frameSize.width)
30 |
31 | let dm = FileManager.default
32 |
33 | if dm.fileExists(atPath: path) {
34 | let globallyUniqueString = ProcessInfo.processInfo.globallyUniqueString
35 | let newPath = path + "_\(globallyUniqueString)"
36 |
37 | do {
38 | try dm.moveItem(atPath: path, toPath: newPath)
39 | } catch {
40 | print("-- cannot move \(path) to \(newPath)")
41 | return nil
42 | }
43 | }
44 |
45 | self.framesPerSecond = fps
46 |
47 | // Create Movie URL
48 | let movieURL = URL(fileURLWithPath: path)
49 |
50 | // Create Asset Writer
51 | do {
52 | self.writer = try AVAssetWriter(outputURL: movieURL, fileType: AVFileTypeQuickTimeMovie)
53 | } catch {
54 | print("-- error: cannot create asset writer, \(error)")
55 | return nil
56 | }
57 |
58 | // Create Input
59 | var videoSettings = [String:AnyObject]()
60 | videoSettings[AVVideoCodecKey] = AVVideoCodecH264 as AnyObject?
61 | videoSettings[AVVideoWidthKey] = width as AnyObject?
62 | videoSettings[AVVideoHeightKey] = height as AnyObject?
63 |
64 | self.input = AVAssetWriterInput(mediaType: AVMediaTypeVideo, outputSettings: videoSettings)
65 |
66 | self.writer.add(input!)
67 |
68 | // Build adapter
69 | self.adaptor = AVAssetWriterInputPixelBufferAdaptor(assetWriterInput: input!, sourcePixelBufferAttributes: nil)
70 |
71 | guard writer.startWriting() else {
72 | print("-- cannot start writing")
73 | return nil
74 | }
75 |
76 | writer.startSession(atSourceTime: kCMTimeZero)
77 | }
78 |
79 | @objc(mergeMovieAtPaths:intoPath:completionHandler:error:)
80 | open class func mergeMovies(_ inPath:[String], outPath:String, completionHandler:@escaping ((_ path:String) -> ())) throws {
81 |
82 | let composition = AVMutableComposition()
83 |
84 | let composedTrack = composition.addMutableTrack(withMediaType: AVMediaTypeVideo, preferredTrackID: kCMPersistentTrackID_Invalid)
85 |
86 | var time = kCMTimeZero
87 |
88 | try inPath.forEach { (inPath) -> () in
89 | let fileURL = URL(fileURLWithPath: inPath)
90 | let asset = AVURLAsset(url: fileURL)
91 | let videoTracks = asset.tracks(withMediaType: AVMediaTypeVideo)
92 | let firstTrack = videoTracks.first
93 |
94 | guard let existingFirstTrack = firstTrack else { return }
95 |
96 | let timeRange = CMTimeRangeMake(kCMTimeZero, asset.duration)
97 |
98 | try composedTrack.insertTimeRange(timeRange, of: existingFirstTrack, at: time)
99 |
100 | try composedTrack.insertTimeRange(
101 | CMTimeRangeMake(kCMTimeZero, asset.duration),
102 | of: existingFirstTrack,
103 | at: time)
104 |
105 | time = CMTimeAdd(time, asset.duration);
106 | }
107 |
108 | /**/
109 |
110 | let fm = FileManager.default
111 |
112 | if fm.fileExists(atPath: outPath) {
113 | try fm.removeItem(atPath: outPath)
114 | }
115 |
116 | guard let exporter = AVAssetExportSession(asset: composition, presetName: AVAssetExportPresetAppleProRes422LPCM) else { return }
117 |
118 | exporter.outputURL = URL(fileURLWithPath: outPath)
119 | exporter.outputFileType = AVFileTypeQuickTimeMovie
120 | exporter.shouldOptimizeForNetworkUse = true
121 |
122 | exporter.exportAsynchronously(completionHandler: { () -> Void in
123 | /*
124 | AVAssetExportSessionStatusUnknown,
125 | AVAssetExportSessionStatusWaiting,
126 | AVAssetExportSessionStatusExporting,
127 | AVAssetExportSessionStatusCompleted,
128 | AVAssetExportSessionStatusFailed,
129 | AVAssetExportSessionStatusCancelled
130 | */
131 |
132 | switch(exporter.status) {
133 | case .completed:
134 | completionHandler(outPath)
135 | default:
136 | print(exporter.status)
137 | }
138 | })
139 | }
140 |
141 | open func append(image:NSImage) -> Bool {
142 |
143 | return self.appendImageFromDrawing({ [unowned self] (context) -> () in
144 | let rect = CGRect(x:0, y:0, width:CGFloat(self.width), height:CGFloat(self.height))
145 | NSColor.black.set()
146 | NSRectFill(rect)
147 | image.draw(in:rect)
148 | })
149 | }
150 |
151 | open func appendImageFromDrawing(_ drawingBlock: (_ context:CGContext) -> ()) -> Bool {
152 |
153 | guard let pixelBufferRef = self.createPixelBufferFromDrawing(drawingBlock) else {
154 | return false
155 | }
156 |
157 | guard let existingInput = input else {
158 | return false
159 | }
160 |
161 | while(existingInput.isReadyForMoreMediaData == false) {}
162 |
163 | guard let existingAdaptor = self.adaptor else { return false }
164 |
165 | let cmTime = CMTimeMake(Int64(frameCount), Int32(framesPerSecond))
166 | let success = existingAdaptor.append(pixelBufferRef, withPresentationTime: cmTime)
167 |
168 | if success == false {
169 | print("-- error writing frame \(self.frameCount)")
170 | return false
171 | }
172 |
173 | self.frameCount += 1
174 |
175 | return success
176 | }
177 |
178 | open func write(_ completionHandler:@escaping (_ path:String) -> ()) {
179 | guard let existingInput = self.input else {
180 | print("-- no input -> don't write")
181 | return
182 | }
183 |
184 | existingInput.markAsFinished()
185 |
186 | self.writer.finishWriting { () -> Void in
187 | let path = self.writer.outputURL.path
188 | print("-- wrote", path)
189 | self.input = nil
190 | self.adaptor = nil
191 | completionHandler(path)
192 | }
193 | }
194 |
195 | fileprivate func createPixelBuffer() -> CVPixelBuffer? {
196 |
197 | // Create Pixel Buffer
198 | let pixelBufferOptions : NSDictionary = [kCVPixelBufferCGImageCompatibilityKey as NSString:true, kCVPixelBufferCGBitmapContextCompatibilityKey as NSString:true];
199 |
200 | var pixelBuffer : CVPixelBuffer? = nil;
201 |
202 | let status : CVReturn = CVPixelBufferCreate(kCFAllocatorDefault,
203 | self.width,
204 | self.height,
205 | kCVPixelFormatType_32ARGB,
206 | pixelBufferOptions as NSDictionary,
207 | &pixelBuffer)
208 |
209 | if (status != kCVReturnSuccess) {
210 | print("-- error creating pixel buffer")
211 | return nil
212 | }
213 |
214 | return pixelBuffer
215 | }
216 |
217 | fileprivate func createPixelBufferFromDrawing(_ contextDrawingBlock: (_ context:CGContext) -> ()) -> CVPixelBuffer? {
218 |
219 | guard let pixelBufferRef = self.createPixelBuffer() else { return nil }
220 |
221 | CVPixelBufferLockBaseAddress(pixelBufferRef, CVPixelBufferLockFlags(rawValue: CVOptionFlags(0)))
222 | let pixelData = CVPixelBufferGetBaseAddress(pixelBufferRef)
223 | let RGBColorSpace = CGColorSpaceCreateDeviceRGB()
224 |
225 | guard let context = CGContext(
226 | data: pixelData,
227 | width: self.width,
228 | height: self.height,
229 | bitsPerComponent: 8,
230 | bytesPerRow: 4 * self.width,
231 | space: RGBColorSpace,
232 | bitmapInfo: CGImageAlphaInfo.noneSkipFirst.rawValue) else {
233 | print("-- error creating bitmap context")
234 | CVPixelBufferUnlockBaseAddress(pixelBufferRef, CVPixelBufferLockFlags(rawValue: CVOptionFlags(0)))
235 | return nil
236 | }
237 |
238 | NSGraphicsContext.saveGraphicsState()
239 | let gc = NSGraphicsContext(cgContext: context, flipped: false)
240 | NSGraphicsContext.setCurrent(gc)
241 |
242 | contextDrawingBlock(context)
243 |
244 | NSGraphicsContext.restoreGraphicsState()
245 |
246 | CVPixelBufferUnlockBaseAddress(pixelBufferRef, CVPixelBufferLockFlags(rawValue: CVOptionFlags(0)));
247 |
248 | return pixelBufferRef;
249 | }
250 | }
251 |
--------------------------------------------------------------------------------
/STMovingImages/STMovingImages.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 03C317141DD3436D001B03F8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03C317131DD3436D001B03F8 /* AppDelegate.swift */; };
11 | 03C317161DD3436D001B03F8 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03C317151DD3436D001B03F8 /* ViewController.swift */; };
12 | 03C317191DD3436D001B03F8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 03C317171DD3436D001B03F8 /* Main.storyboard */; };
13 | 03C3171B1DD3436D001B03F8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 03C3171A1DD3436D001B03F8 /* Assets.xcassets */; };
14 | 03C3171E1DD3436D001B03F8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 03C3171C1DD3436D001B03F8 /* LaunchScreen.storyboard */; };
15 | 03C317301DD348FE001B03F8 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03C3172F1DD348FE001B03F8 /* main.swift */; };
16 | 03C317521DD357E0001B03F8 /* STGIFMaker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03C3174F1DD357E0001B03F8 /* STGIFMaker.swift */; };
17 | 03C317541DD357E0001B03F8 /* STMovieMaker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03C317501DD357E0001B03F8 /* STMovieMaker.swift */; };
18 | 03C317551DD35844001B03F8 /* STGIFMaker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03C3174F1DD357E0001B03F8 /* STGIFMaker.swift */; };
19 | 03C317631DD358DF001B03F8 /* earth_01.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 03C317571DD358DF001B03F8 /* earth_01.jpg */; };
20 | 03C317641DD358DF001B03F8 /* earth_02.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 03C317581DD358DF001B03F8 /* earth_02.jpg */; };
21 | 03C317651DD358DF001B03F8 /* earth_03.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 03C317591DD358DF001B03F8 /* earth_03.jpg */; };
22 | 03C317661DD358DF001B03F8 /* earth_04.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 03C3175A1DD358DF001B03F8 /* earth_04.jpg */; };
23 | 03C317671DD358DF001B03F8 /* earth_05.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 03C3175B1DD358DF001B03F8 /* earth_05.jpg */; };
24 | 03C317681DD358DF001B03F8 /* earth_06.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 03C3175C1DD358DF001B03F8 /* earth_06.jpg */; };
25 | 03C317691DD358DF001B03F8 /* earth_07.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 03C3175D1DD358DF001B03F8 /* earth_07.jpg */; };
26 | 03C3176A1DD358DF001B03F8 /* earth_08.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 03C3175E1DD358DF001B03F8 /* earth_08.jpg */; };
27 | 03C3176B1DD358DF001B03F8 /* earth_09.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 03C3175F1DD358DF001B03F8 /* earth_09.jpg */; };
28 | 03C3176C1DD358DF001B03F8 /* earth_10.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 03C317601DD358DF001B03F8 /* earth_10.jpg */; };
29 | 03C3176D1DD358DF001B03F8 /* earth_11.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 03C317611DD358DF001B03F8 /* earth_11.jpg */; };
30 | 03C3176E1DD358DF001B03F8 /* earth_12.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 03C317621DD358DF001B03F8 /* earth_12.jpg */; };
31 | /* End PBXBuildFile section */
32 |
33 | /* Begin PBXCopyFilesBuildPhase section */
34 | 03C3172B1DD348FE001B03F8 /* CopyFiles */ = {
35 | isa = PBXCopyFilesBuildPhase;
36 | buildActionMask = 2147483647;
37 | dstPath = /usr/share/man/man1/;
38 | dstSubfolderSpec = 0;
39 | files = (
40 | );
41 | runOnlyForDeploymentPostprocessing = 1;
42 | };
43 | /* End PBXCopyFilesBuildPhase section */
44 |
45 | /* Begin PBXFileReference section */
46 | 03C317111DD3436D001B03F8 /* STMovingImages_iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = STMovingImages_iOS.app; sourceTree = BUILT_PRODUCTS_DIR; };
47 | 03C317131DD3436D001B03F8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
48 | 03C317151DD3436D001B03F8 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
49 | 03C317181DD3436D001B03F8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
50 | 03C3171A1DD3436D001B03F8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
51 | 03C3171D1DD3436D001B03F8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
52 | 03C3171F1DD3436D001B03F8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
53 | 03C3172D1DD348FE001B03F8 /* STMoviewImage_OSX */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = STMoviewImage_OSX; sourceTree = BUILT_PRODUCTS_DIR; };
54 | 03C3172F1DD348FE001B03F8 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; };
55 | 03C3174F1DD357E0001B03F8 /* STGIFMaker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STGIFMaker.swift; sourceTree = ""; };
56 | 03C317501DD357E0001B03F8 /* STMovieMaker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STMovieMaker.swift; sourceTree = ""; };
57 | 03C317571DD358DF001B03F8 /* earth_01.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = earth_01.jpg; sourceTree = ""; };
58 | 03C317581DD358DF001B03F8 /* earth_02.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = earth_02.jpg; sourceTree = ""; };
59 | 03C317591DD358DF001B03F8 /* earth_03.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = earth_03.jpg; sourceTree = ""; };
60 | 03C3175A1DD358DF001B03F8 /* earth_04.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = earth_04.jpg; sourceTree = ""; };
61 | 03C3175B1DD358DF001B03F8 /* earth_05.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = earth_05.jpg; sourceTree = ""; };
62 | 03C3175C1DD358DF001B03F8 /* earth_06.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = earth_06.jpg; sourceTree = ""; };
63 | 03C3175D1DD358DF001B03F8 /* earth_07.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = earth_07.jpg; sourceTree = ""; };
64 | 03C3175E1DD358DF001B03F8 /* earth_08.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = earth_08.jpg; sourceTree = ""; };
65 | 03C3175F1DD358DF001B03F8 /* earth_09.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = earth_09.jpg; sourceTree = ""; };
66 | 03C317601DD358DF001B03F8 /* earth_10.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = earth_10.jpg; sourceTree = ""; };
67 | 03C317611DD358DF001B03F8 /* earth_11.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = earth_11.jpg; sourceTree = ""; };
68 | 03C317621DD358DF001B03F8 /* earth_12.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = earth_12.jpg; sourceTree = ""; };
69 | /* End PBXFileReference section */
70 |
71 | /* Begin PBXFrameworksBuildPhase section */
72 | 03C3170E1DD3436D001B03F8 /* Frameworks */ = {
73 | isa = PBXFrameworksBuildPhase;
74 | buildActionMask = 2147483647;
75 | files = (
76 | );
77 | runOnlyForDeploymentPostprocessing = 0;
78 | };
79 | 03C3172A1DD348FE001B03F8 /* Frameworks */ = {
80 | isa = PBXFrameworksBuildPhase;
81 | buildActionMask = 2147483647;
82 | files = (
83 | );
84 | runOnlyForDeploymentPostprocessing = 0;
85 | };
86 | /* End PBXFrameworksBuildPhase section */
87 |
88 | /* Begin PBXGroup section */
89 | 03C316F41DD34346001B03F8 = {
90 | isa = PBXGroup;
91 | children = (
92 | 03C3174F1DD357E0001B03F8 /* STGIFMaker.swift */,
93 | 03C317501DD357E0001B03F8 /* STMovieMaker.swift */,
94 | 03C317121DD3436D001B03F8 /* STMovingImages_iOS */,
95 | 03C3172E1DD348FE001B03F8 /* STMoviewImage_OSX */,
96 | 03C316FE1DD34346001B03F8 /* Products */,
97 | );
98 | sourceTree = "";
99 | };
100 | 03C316FE1DD34346001B03F8 /* Products */ = {
101 | isa = PBXGroup;
102 | children = (
103 | 03C317111DD3436D001B03F8 /* STMovingImages_iOS.app */,
104 | 03C3172D1DD348FE001B03F8 /* STMoviewImage_OSX */,
105 | );
106 | name = Products;
107 | sourceTree = "";
108 | };
109 | 03C317121DD3436D001B03F8 /* STMovingImages_iOS */ = {
110 | isa = PBXGroup;
111 | children = (
112 | 03C317131DD3436D001B03F8 /* AppDelegate.swift */,
113 | 03C317151DD3436D001B03F8 /* ViewController.swift */,
114 | 03C317171DD3436D001B03F8 /* Main.storyboard */,
115 | 03C3171A1DD3436D001B03F8 /* Assets.xcassets */,
116 | 03C3171C1DD3436D001B03F8 /* LaunchScreen.storyboard */,
117 | 03C3171F1DD3436D001B03F8 /* Info.plist */,
118 | 03C317561DD358DF001B03F8 /* earth */,
119 | );
120 | path = STMovingImages_iOS;
121 | sourceTree = "";
122 | };
123 | 03C3172E1DD348FE001B03F8 /* STMoviewImage_OSX */ = {
124 | isa = PBXGroup;
125 | children = (
126 | 03C3172F1DD348FE001B03F8 /* main.swift */,
127 | );
128 | path = STMoviewImage_OSX;
129 | sourceTree = "";
130 | };
131 | 03C317561DD358DF001B03F8 /* earth */ = {
132 | isa = PBXGroup;
133 | children = (
134 | 03C317571DD358DF001B03F8 /* earth_01.jpg */,
135 | 03C317581DD358DF001B03F8 /* earth_02.jpg */,
136 | 03C317591DD358DF001B03F8 /* earth_03.jpg */,
137 | 03C3175A1DD358DF001B03F8 /* earth_04.jpg */,
138 | 03C3175B1DD358DF001B03F8 /* earth_05.jpg */,
139 | 03C3175C1DD358DF001B03F8 /* earth_06.jpg */,
140 | 03C3175D1DD358DF001B03F8 /* earth_07.jpg */,
141 | 03C3175E1DD358DF001B03F8 /* earth_08.jpg */,
142 | 03C3175F1DD358DF001B03F8 /* earth_09.jpg */,
143 | 03C317601DD358DF001B03F8 /* earth_10.jpg */,
144 | 03C317611DD358DF001B03F8 /* earth_11.jpg */,
145 | 03C317621DD358DF001B03F8 /* earth_12.jpg */,
146 | );
147 | name = earth;
148 | path = ../earth;
149 | sourceTree = "";
150 | };
151 | /* End PBXGroup section */
152 |
153 | /* Begin PBXNativeTarget section */
154 | 03C317101DD3436D001B03F8 /* STMovingImages_iOS */ = {
155 | isa = PBXNativeTarget;
156 | buildConfigurationList = 03C317201DD3436D001B03F8 /* Build configuration list for PBXNativeTarget "STMovingImages_iOS" */;
157 | buildPhases = (
158 | 03C3170D1DD3436D001B03F8 /* Sources */,
159 | 03C3170E1DD3436D001B03F8 /* Frameworks */,
160 | 03C3170F1DD3436D001B03F8 /* Resources */,
161 | );
162 | buildRules = (
163 | );
164 | dependencies = (
165 | );
166 | name = STMovingImages_iOS;
167 | productName = STMovingImages_iOS;
168 | productReference = 03C317111DD3436D001B03F8 /* STMovingImages_iOS.app */;
169 | productType = "com.apple.product-type.application";
170 | };
171 | 03C3172C1DD348FE001B03F8 /* STMoviewImage_OSX */ = {
172 | isa = PBXNativeTarget;
173 | buildConfigurationList = 03C317311DD348FE001B03F8 /* Build configuration list for PBXNativeTarget "STMoviewImage_OSX" */;
174 | buildPhases = (
175 | 03C317291DD348FE001B03F8 /* Sources */,
176 | 03C3172A1DD348FE001B03F8 /* Frameworks */,
177 | 03C3172B1DD348FE001B03F8 /* CopyFiles */,
178 | );
179 | buildRules = (
180 | );
181 | dependencies = (
182 | );
183 | name = STMoviewImage_OSX;
184 | productName = STMoviewImage_OSX;
185 | productReference = 03C3172D1DD348FE001B03F8 /* STMoviewImage_OSX */;
186 | productType = "com.apple.product-type.tool";
187 | };
188 | /* End PBXNativeTarget section */
189 |
190 | /* Begin PBXProject section */
191 | 03C316F51DD34346001B03F8 /* Project object */ = {
192 | isa = PBXProject;
193 | attributes = {
194 | LastSwiftUpdateCheck = 0800;
195 | LastUpgradeCheck = 0800;
196 | ORGANIZATIONNAME = ch.seriot;
197 | TargetAttributes = {
198 | 03C317101DD3436D001B03F8 = {
199 | CreatedOnToolsVersion = 8.0;
200 | ProvisioningStyle = Automatic;
201 | };
202 | 03C3172C1DD348FE001B03F8 = {
203 | CreatedOnToolsVersion = 8.0;
204 | ProvisioningStyle = Automatic;
205 | };
206 | };
207 | };
208 | buildConfigurationList = 03C316F81DD34346001B03F8 /* Build configuration list for PBXProject "STMovingImages" */;
209 | compatibilityVersion = "Xcode 3.2";
210 | developmentRegion = English;
211 | hasScannedForEncodings = 0;
212 | knownRegions = (
213 | en,
214 | Base,
215 | );
216 | mainGroup = 03C316F41DD34346001B03F8;
217 | productRefGroup = 03C316FE1DD34346001B03F8 /* Products */;
218 | projectDirPath = "";
219 | projectRoot = "";
220 | targets = (
221 | 03C317101DD3436D001B03F8 /* STMovingImages_iOS */,
222 | 03C3172C1DD348FE001B03F8 /* STMoviewImage_OSX */,
223 | );
224 | };
225 | /* End PBXProject section */
226 |
227 | /* Begin PBXResourcesBuildPhase section */
228 | 03C3170F1DD3436D001B03F8 /* Resources */ = {
229 | isa = PBXResourcesBuildPhase;
230 | buildActionMask = 2147483647;
231 | files = (
232 | 03C3176D1DD358DF001B03F8 /* earth_11.jpg in Resources */,
233 | 03C3176C1DD358DF001B03F8 /* earth_10.jpg in Resources */,
234 | 03C317641DD358DF001B03F8 /* earth_02.jpg in Resources */,
235 | 03C317661DD358DF001B03F8 /* earth_04.jpg in Resources */,
236 | 03C317651DD358DF001B03F8 /* earth_03.jpg in Resources */,
237 | 03C317671DD358DF001B03F8 /* earth_05.jpg in Resources */,
238 | 03C3176A1DD358DF001B03F8 /* earth_08.jpg in Resources */,
239 | 03C317681DD358DF001B03F8 /* earth_06.jpg in Resources */,
240 | 03C317691DD358DF001B03F8 /* earth_07.jpg in Resources */,
241 | 03C3176B1DD358DF001B03F8 /* earth_09.jpg in Resources */,
242 | 03C3176E1DD358DF001B03F8 /* earth_12.jpg in Resources */,
243 | 03C3171E1DD3436D001B03F8 /* LaunchScreen.storyboard in Resources */,
244 | 03C3171B1DD3436D001B03F8 /* Assets.xcassets in Resources */,
245 | 03C317191DD3436D001B03F8 /* Main.storyboard in Resources */,
246 | 03C317631DD358DF001B03F8 /* earth_01.jpg in Resources */,
247 | );
248 | runOnlyForDeploymentPostprocessing = 0;
249 | };
250 | /* End PBXResourcesBuildPhase section */
251 |
252 | /* Begin PBXSourcesBuildPhase section */
253 | 03C3170D1DD3436D001B03F8 /* Sources */ = {
254 | isa = PBXSourcesBuildPhase;
255 | buildActionMask = 2147483647;
256 | files = (
257 | 03C317161DD3436D001B03F8 /* ViewController.swift in Sources */,
258 | 03C317551DD35844001B03F8 /* STGIFMaker.swift in Sources */,
259 | 03C317141DD3436D001B03F8 /* AppDelegate.swift in Sources */,
260 | );
261 | runOnlyForDeploymentPostprocessing = 0;
262 | };
263 | 03C317291DD348FE001B03F8 /* Sources */ = {
264 | isa = PBXSourcesBuildPhase;
265 | buildActionMask = 2147483647;
266 | files = (
267 | 03C317541DD357E0001B03F8 /* STMovieMaker.swift in Sources */,
268 | 03C317521DD357E0001B03F8 /* STGIFMaker.swift in Sources */,
269 | 03C317301DD348FE001B03F8 /* main.swift in Sources */,
270 | );
271 | runOnlyForDeploymentPostprocessing = 0;
272 | };
273 | /* End PBXSourcesBuildPhase section */
274 |
275 | /* Begin PBXVariantGroup section */
276 | 03C317171DD3436D001B03F8 /* Main.storyboard */ = {
277 | isa = PBXVariantGroup;
278 | children = (
279 | 03C317181DD3436D001B03F8 /* Base */,
280 | );
281 | name = Main.storyboard;
282 | sourceTree = "";
283 | };
284 | 03C3171C1DD3436D001B03F8 /* LaunchScreen.storyboard */ = {
285 | isa = PBXVariantGroup;
286 | children = (
287 | 03C3171D1DD3436D001B03F8 /* Base */,
288 | );
289 | name = LaunchScreen.storyboard;
290 | sourceTree = "";
291 | };
292 | /* End PBXVariantGroup section */
293 |
294 | /* Begin XCBuildConfiguration section */
295 | 03C317081DD34346001B03F8 /* Debug */ = {
296 | isa = XCBuildConfiguration;
297 | buildSettings = {
298 | ALWAYS_SEARCH_USER_PATHS = NO;
299 | CLANG_ANALYZER_NONNULL = YES;
300 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
301 | CLANG_CXX_LIBRARY = "libc++";
302 | CLANG_ENABLE_MODULES = YES;
303 | CLANG_ENABLE_OBJC_ARC = YES;
304 | CLANG_WARN_BOOL_CONVERSION = YES;
305 | CLANG_WARN_CONSTANT_CONVERSION = YES;
306 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
307 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
308 | CLANG_WARN_EMPTY_BODY = YES;
309 | CLANG_WARN_ENUM_CONVERSION = YES;
310 | CLANG_WARN_INFINITE_RECURSION = YES;
311 | CLANG_WARN_INT_CONVERSION = YES;
312 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
313 | CLANG_WARN_SUSPICIOUS_MOVES = YES;
314 | CLANG_WARN_UNREACHABLE_CODE = YES;
315 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
316 | CODE_SIGN_IDENTITY = "-";
317 | COPY_PHASE_STRIP = NO;
318 | DEBUG_INFORMATION_FORMAT = dwarf;
319 | ENABLE_STRICT_OBJC_MSGSEND = YES;
320 | ENABLE_TESTABILITY = YES;
321 | GCC_C_LANGUAGE_STANDARD = gnu99;
322 | GCC_DYNAMIC_NO_PIC = NO;
323 | GCC_NO_COMMON_BLOCKS = YES;
324 | GCC_OPTIMIZATION_LEVEL = 0;
325 | GCC_PREPROCESSOR_DEFINITIONS = (
326 | "DEBUG=1",
327 | "$(inherited)",
328 | );
329 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
330 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
331 | GCC_WARN_UNDECLARED_SELECTOR = YES;
332 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
333 | GCC_WARN_UNUSED_FUNCTION = YES;
334 | GCC_WARN_UNUSED_VARIABLE = YES;
335 | MACOSX_DEPLOYMENT_TARGET = 10.12;
336 | MTL_ENABLE_DEBUG_INFO = YES;
337 | ONLY_ACTIVE_ARCH = YES;
338 | SDKROOT = macosx;
339 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
340 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
341 | };
342 | name = Debug;
343 | };
344 | 03C317091DD34346001B03F8 /* Release */ = {
345 | isa = XCBuildConfiguration;
346 | buildSettings = {
347 | ALWAYS_SEARCH_USER_PATHS = NO;
348 | CLANG_ANALYZER_NONNULL = YES;
349 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
350 | CLANG_CXX_LIBRARY = "libc++";
351 | CLANG_ENABLE_MODULES = YES;
352 | CLANG_ENABLE_OBJC_ARC = YES;
353 | CLANG_WARN_BOOL_CONVERSION = YES;
354 | CLANG_WARN_CONSTANT_CONVERSION = YES;
355 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
356 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
357 | CLANG_WARN_EMPTY_BODY = YES;
358 | CLANG_WARN_ENUM_CONVERSION = YES;
359 | CLANG_WARN_INFINITE_RECURSION = YES;
360 | CLANG_WARN_INT_CONVERSION = YES;
361 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
362 | CLANG_WARN_SUSPICIOUS_MOVES = YES;
363 | CLANG_WARN_UNREACHABLE_CODE = YES;
364 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
365 | CODE_SIGN_IDENTITY = "-";
366 | COPY_PHASE_STRIP = NO;
367 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
368 | ENABLE_NS_ASSERTIONS = NO;
369 | ENABLE_STRICT_OBJC_MSGSEND = YES;
370 | GCC_C_LANGUAGE_STANDARD = gnu99;
371 | GCC_NO_COMMON_BLOCKS = YES;
372 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
373 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
374 | GCC_WARN_UNDECLARED_SELECTOR = YES;
375 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
376 | GCC_WARN_UNUSED_FUNCTION = YES;
377 | GCC_WARN_UNUSED_VARIABLE = YES;
378 | MACOSX_DEPLOYMENT_TARGET = 10.12;
379 | MTL_ENABLE_DEBUG_INFO = NO;
380 | SDKROOT = macosx;
381 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
382 | };
383 | name = Release;
384 | };
385 | 03C317211DD3436D001B03F8 /* Debug */ = {
386 | isa = XCBuildConfiguration;
387 | buildSettings = {
388 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
389 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
390 | INFOPLIST_FILE = STMovingImages_iOS/Info.plist;
391 | IPHONEOS_DEPLOYMENT_TARGET = 10.0;
392 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
393 | PRODUCT_BUNDLE_IDENTIFIER = "ch.seriot.STMovingImages-iOS";
394 | PRODUCT_NAME = "$(TARGET_NAME)";
395 | SDKROOT = iphoneos;
396 | SWIFT_VERSION = 3.0;
397 | TARGETED_DEVICE_FAMILY = "1,2";
398 | };
399 | name = Debug;
400 | };
401 | 03C317221DD3436D001B03F8 /* Release */ = {
402 | isa = XCBuildConfiguration;
403 | buildSettings = {
404 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
405 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
406 | INFOPLIST_FILE = STMovingImages_iOS/Info.plist;
407 | IPHONEOS_DEPLOYMENT_TARGET = 10.0;
408 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
409 | PRODUCT_BUNDLE_IDENTIFIER = "ch.seriot.STMovingImages-iOS";
410 | PRODUCT_NAME = "$(TARGET_NAME)";
411 | SDKROOT = iphoneos;
412 | SWIFT_VERSION = 3.0;
413 | TARGETED_DEVICE_FAMILY = "1,2";
414 | VALIDATE_PRODUCT = YES;
415 | };
416 | name = Release;
417 | };
418 | 03C317321DD348FE001B03F8 /* Debug */ = {
419 | isa = XCBuildConfiguration;
420 | buildSettings = {
421 | PRODUCT_NAME = "$(TARGET_NAME)";
422 | SWIFT_VERSION = 3.0;
423 | };
424 | name = Debug;
425 | };
426 | 03C317331DD348FE001B03F8 /* Release */ = {
427 | isa = XCBuildConfiguration;
428 | buildSettings = {
429 | PRODUCT_NAME = "$(TARGET_NAME)";
430 | SWIFT_VERSION = 3.0;
431 | };
432 | name = Release;
433 | };
434 | /* End XCBuildConfiguration section */
435 |
436 | /* Begin XCConfigurationList section */
437 | 03C316F81DD34346001B03F8 /* Build configuration list for PBXProject "STMovingImages" */ = {
438 | isa = XCConfigurationList;
439 | buildConfigurations = (
440 | 03C317081DD34346001B03F8 /* Debug */,
441 | 03C317091DD34346001B03F8 /* Release */,
442 | );
443 | defaultConfigurationIsVisible = 0;
444 | defaultConfigurationName = Release;
445 | };
446 | 03C317201DD3436D001B03F8 /* Build configuration list for PBXNativeTarget "STMovingImages_iOS" */ = {
447 | isa = XCConfigurationList;
448 | buildConfigurations = (
449 | 03C317211DD3436D001B03F8 /* Debug */,
450 | 03C317221DD3436D001B03F8 /* Release */,
451 | );
452 | defaultConfigurationIsVisible = 0;
453 | defaultConfigurationName = Release;
454 | };
455 | 03C317311DD348FE001B03F8 /* Build configuration list for PBXNativeTarget "STMoviewImage_OSX" */ = {
456 | isa = XCConfigurationList;
457 | buildConfigurations = (
458 | 03C317321DD348FE001B03F8 /* Debug */,
459 | 03C317331DD348FE001B03F8 /* Release */,
460 | );
461 | defaultConfigurationIsVisible = 0;
462 | defaultConfigurationName = Release;
463 | };
464 | /* End XCConfigurationList section */
465 | };
466 | rootObject = 03C316F51DD34346001B03F8 /* Project object */;
467 | }
468 |
--------------------------------------------------------------------------------