├── ImageToVideo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── liudongxu.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── liudongxu.xcuserdatad │ └── xcschemes │ ├── ImageToVideo.xcscheme │ └── xcschememanagement.plist ├── ImageToVideo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── 0.imageset │ │ ├── 7-1.jpg │ │ ├── 7-2.jpg │ │ ├── 7.jpg │ │ └── Contents.json │ ├── 1.imageset │ │ ├── 1-1.jpg │ │ ├── 1-2.jpg │ │ ├── 1.jpg │ │ └── Contents.json │ ├── 2.imageset │ │ ├── 2-1.jpg │ │ ├── 2-2.jpg │ │ ├── 2.jpg │ │ └── Contents.json │ ├── 3.imageset │ │ ├── 3-1.jpg │ │ ├── 3-2.jpg │ │ ├── 3.jpg │ │ └── Contents.json │ ├── 4.imageset │ │ ├── 4-1.jpg │ │ ├── 4-2.jpg │ │ ├── 4.jpg │ │ └── Contents.json │ ├── 5.imageset │ │ ├── 5-1.jpg │ │ ├── 5-2.jpg │ │ ├── 5.jpg │ │ └── Contents.json │ ├── 6.imageset │ │ ├── 6-1.jpg │ │ ├── 6-2.jpg │ │ ├── 6.jpg │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m └── README.md /ImageToVideo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0C399E751F5C4C4F003F18FC /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C399E741F5C4C4F003F18FC /* main.m */; }; 11 | 0C399E781F5C4C4F003F18FC /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C399E771F5C4C4F003F18FC /* AppDelegate.m */; }; 12 | 0C399E7B1F5C4C4F003F18FC /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C399E7A1F5C4C4F003F18FC /* ViewController.m */; }; 13 | 0C399E7E1F5C4C4F003F18FC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0C399E7C1F5C4C4F003F18FC /* Main.storyboard */; }; 14 | 0C399E801F5C4C4F003F18FC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0C399E7F1F5C4C4F003F18FC /* Assets.xcassets */; }; 15 | 0C399E831F5C4C4F003F18FC /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0C399E811F5C4C4F003F18FC /* LaunchScreen.storyboard */; }; 16 | 0C399E8E1F5C4CCF003F18FC /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0C399E8B1F5C4CCF003F18FC /* AVFoundation.framework */; }; 17 | 0C399E8F1F5C4CCF003F18FC /* AVKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0C399E8C1F5C4CCF003F18FC /* AVKit.framework */; }; 18 | 0C399E901F5C4CCF003F18FC /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0C399E8D1F5C4CCF003F18FC /* CoreMedia.framework */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXFileReference section */ 22 | 0C399E701F5C4C4F003F18FC /* ImageToVideo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ImageToVideo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | 0C399E741F5C4C4F003F18FC /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 24 | 0C399E761F5C4C4F003F18FC /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 25 | 0C399E771F5C4C4F003F18FC /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 26 | 0C399E791F5C4C4F003F18FC /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 27 | 0C399E7A1F5C4C4F003F18FC /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 28 | 0C399E7D1F5C4C4F003F18FC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 29 | 0C399E7F1F5C4C4F003F18FC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 30 | 0C399E821F5C4C4F003F18FC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 31 | 0C399E841F5C4C4F003F18FC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | 0C399E8B1F5C4CCF003F18FC /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; 33 | 0C399E8C1F5C4CCF003F18FC /* AVKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVKit.framework; path = System/Library/Frameworks/AVKit.framework; sourceTree = SDKROOT; }; 34 | 0C399E8D1F5C4CCF003F18FC /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; }; 35 | /* End PBXFileReference section */ 36 | 37 | /* Begin PBXFrameworksBuildPhase section */ 38 | 0C399E6D1F5C4C4F003F18FC /* Frameworks */ = { 39 | isa = PBXFrameworksBuildPhase; 40 | buildActionMask = 2147483647; 41 | files = ( 42 | 0C399E8E1F5C4CCF003F18FC /* AVFoundation.framework in Frameworks */, 43 | 0C399E8F1F5C4CCF003F18FC /* AVKit.framework in Frameworks */, 44 | 0C399E901F5C4CCF003F18FC /* CoreMedia.framework in Frameworks */, 45 | ); 46 | runOnlyForDeploymentPostprocessing = 0; 47 | }; 48 | /* End PBXFrameworksBuildPhase section */ 49 | 50 | /* Begin PBXGroup section */ 51 | 0C399E671F5C4C4F003F18FC = { 52 | isa = PBXGroup; 53 | children = ( 54 | 0C399E721F5C4C4F003F18FC /* ImageToVideo */, 55 | 0C399E711F5C4C4F003F18FC /* Products */, 56 | 0C399E8A1F5C4CCF003F18FC /* Frameworks */, 57 | ); 58 | sourceTree = ""; 59 | }; 60 | 0C399E711F5C4C4F003F18FC /* Products */ = { 61 | isa = PBXGroup; 62 | children = ( 63 | 0C399E701F5C4C4F003F18FC /* ImageToVideo.app */, 64 | ); 65 | name = Products; 66 | sourceTree = ""; 67 | }; 68 | 0C399E721F5C4C4F003F18FC /* ImageToVideo */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | 0C399E761F5C4C4F003F18FC /* AppDelegate.h */, 72 | 0C399E771F5C4C4F003F18FC /* AppDelegate.m */, 73 | 0C399E791F5C4C4F003F18FC /* ViewController.h */, 74 | 0C399E7A1F5C4C4F003F18FC /* ViewController.m */, 75 | 0C399E7C1F5C4C4F003F18FC /* Main.storyboard */, 76 | 0C399E7F1F5C4C4F003F18FC /* Assets.xcassets */, 77 | 0C399E811F5C4C4F003F18FC /* LaunchScreen.storyboard */, 78 | 0C399E841F5C4C4F003F18FC /* Info.plist */, 79 | 0C399E731F5C4C4F003F18FC /* Supporting Files */, 80 | ); 81 | path = ImageToVideo; 82 | sourceTree = ""; 83 | }; 84 | 0C399E731F5C4C4F003F18FC /* Supporting Files */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | 0C399E741F5C4C4F003F18FC /* main.m */, 88 | ); 89 | name = "Supporting Files"; 90 | sourceTree = ""; 91 | }; 92 | 0C399E8A1F5C4CCF003F18FC /* Frameworks */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | 0C399E8B1F5C4CCF003F18FC /* AVFoundation.framework */, 96 | 0C399E8C1F5C4CCF003F18FC /* AVKit.framework */, 97 | 0C399E8D1F5C4CCF003F18FC /* CoreMedia.framework */, 98 | ); 99 | name = Frameworks; 100 | sourceTree = ""; 101 | }; 102 | /* End PBXGroup section */ 103 | 104 | /* Begin PBXNativeTarget section */ 105 | 0C399E6F1F5C4C4F003F18FC /* ImageToVideo */ = { 106 | isa = PBXNativeTarget; 107 | buildConfigurationList = 0C399E871F5C4C4F003F18FC /* Build configuration list for PBXNativeTarget "ImageToVideo" */; 108 | buildPhases = ( 109 | 0C399E6C1F5C4C4F003F18FC /* Sources */, 110 | 0C399E6D1F5C4C4F003F18FC /* Frameworks */, 111 | 0C399E6E1F5C4C4F003F18FC /* Resources */, 112 | ); 113 | buildRules = ( 114 | ); 115 | dependencies = ( 116 | ); 117 | name = ImageToVideo; 118 | productName = ImageToVideo; 119 | productReference = 0C399E701F5C4C4F003F18FC /* ImageToVideo.app */; 120 | productType = "com.apple.product-type.application"; 121 | }; 122 | /* End PBXNativeTarget section */ 123 | 124 | /* Begin PBXProject section */ 125 | 0C399E681F5C4C4F003F18FC /* Project object */ = { 126 | isa = PBXProject; 127 | attributes = { 128 | LastUpgradeCheck = 0830; 129 | ORGANIZATIONNAME = "刘东旭"; 130 | TargetAttributes = { 131 | 0C399E6F1F5C4C4F003F18FC = { 132 | CreatedOnToolsVersion = 8.3.3; 133 | DevelopmentTeam = Z5E3E2D8FE; 134 | ProvisioningStyle = Automatic; 135 | }; 136 | }; 137 | }; 138 | buildConfigurationList = 0C399E6B1F5C4C4F003F18FC /* Build configuration list for PBXProject "ImageToVideo" */; 139 | compatibilityVersion = "Xcode 3.2"; 140 | developmentRegion = English; 141 | hasScannedForEncodings = 0; 142 | knownRegions = ( 143 | en, 144 | Base, 145 | ); 146 | mainGroup = 0C399E671F5C4C4F003F18FC; 147 | productRefGroup = 0C399E711F5C4C4F003F18FC /* Products */; 148 | projectDirPath = ""; 149 | projectRoot = ""; 150 | targets = ( 151 | 0C399E6F1F5C4C4F003F18FC /* ImageToVideo */, 152 | ); 153 | }; 154 | /* End PBXProject section */ 155 | 156 | /* Begin PBXResourcesBuildPhase section */ 157 | 0C399E6E1F5C4C4F003F18FC /* Resources */ = { 158 | isa = PBXResourcesBuildPhase; 159 | buildActionMask = 2147483647; 160 | files = ( 161 | 0C399E831F5C4C4F003F18FC /* LaunchScreen.storyboard in Resources */, 162 | 0C399E801F5C4C4F003F18FC /* Assets.xcassets in Resources */, 163 | 0C399E7E1F5C4C4F003F18FC /* Main.storyboard in Resources */, 164 | ); 165 | runOnlyForDeploymentPostprocessing = 0; 166 | }; 167 | /* End PBXResourcesBuildPhase section */ 168 | 169 | /* Begin PBXSourcesBuildPhase section */ 170 | 0C399E6C1F5C4C4F003F18FC /* Sources */ = { 171 | isa = PBXSourcesBuildPhase; 172 | buildActionMask = 2147483647; 173 | files = ( 174 | 0C399E7B1F5C4C4F003F18FC /* ViewController.m in Sources */, 175 | 0C399E781F5C4C4F003F18FC /* AppDelegate.m in Sources */, 176 | 0C399E751F5C4C4F003F18FC /* main.m in Sources */, 177 | ); 178 | runOnlyForDeploymentPostprocessing = 0; 179 | }; 180 | /* End PBXSourcesBuildPhase section */ 181 | 182 | /* Begin PBXVariantGroup section */ 183 | 0C399E7C1F5C4C4F003F18FC /* Main.storyboard */ = { 184 | isa = PBXVariantGroup; 185 | children = ( 186 | 0C399E7D1F5C4C4F003F18FC /* Base */, 187 | ); 188 | name = Main.storyboard; 189 | sourceTree = ""; 190 | }; 191 | 0C399E811F5C4C4F003F18FC /* LaunchScreen.storyboard */ = { 192 | isa = PBXVariantGroup; 193 | children = ( 194 | 0C399E821F5C4C4F003F18FC /* Base */, 195 | ); 196 | name = LaunchScreen.storyboard; 197 | sourceTree = ""; 198 | }; 199 | /* End PBXVariantGroup section */ 200 | 201 | /* Begin XCBuildConfiguration section */ 202 | 0C399E851F5C4C4F003F18FC /* Debug */ = { 203 | isa = XCBuildConfiguration; 204 | buildSettings = { 205 | ALWAYS_SEARCH_USER_PATHS = NO; 206 | CLANG_ANALYZER_NONNULL = YES; 207 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 208 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 209 | CLANG_CXX_LIBRARY = "libc++"; 210 | CLANG_ENABLE_MODULES = YES; 211 | CLANG_ENABLE_OBJC_ARC = YES; 212 | CLANG_WARN_BOOL_CONVERSION = YES; 213 | CLANG_WARN_CONSTANT_CONVERSION = YES; 214 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 215 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 216 | CLANG_WARN_EMPTY_BODY = YES; 217 | CLANG_WARN_ENUM_CONVERSION = YES; 218 | CLANG_WARN_INFINITE_RECURSION = YES; 219 | CLANG_WARN_INT_CONVERSION = YES; 220 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 221 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 222 | CLANG_WARN_UNREACHABLE_CODE = YES; 223 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 224 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 225 | COPY_PHASE_STRIP = NO; 226 | DEBUG_INFORMATION_FORMAT = dwarf; 227 | ENABLE_STRICT_OBJC_MSGSEND = YES; 228 | ENABLE_TESTABILITY = YES; 229 | GCC_C_LANGUAGE_STANDARD = gnu99; 230 | GCC_DYNAMIC_NO_PIC = NO; 231 | GCC_NO_COMMON_BLOCKS = YES; 232 | GCC_OPTIMIZATION_LEVEL = 0; 233 | GCC_PREPROCESSOR_DEFINITIONS = ( 234 | "DEBUG=1", 235 | "$(inherited)", 236 | ); 237 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 238 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 239 | GCC_WARN_UNDECLARED_SELECTOR = YES; 240 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 241 | GCC_WARN_UNUSED_FUNCTION = YES; 242 | GCC_WARN_UNUSED_VARIABLE = YES; 243 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 244 | MTL_ENABLE_DEBUG_INFO = YES; 245 | ONLY_ACTIVE_ARCH = YES; 246 | SDKROOT = iphoneos; 247 | TARGETED_DEVICE_FAMILY = "1,2"; 248 | }; 249 | name = Debug; 250 | }; 251 | 0C399E861F5C4C4F003F18FC /* Release */ = { 252 | isa = XCBuildConfiguration; 253 | buildSettings = { 254 | ALWAYS_SEARCH_USER_PATHS = NO; 255 | CLANG_ANALYZER_NONNULL = YES; 256 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 257 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 258 | CLANG_CXX_LIBRARY = "libc++"; 259 | CLANG_ENABLE_MODULES = YES; 260 | CLANG_ENABLE_OBJC_ARC = YES; 261 | CLANG_WARN_BOOL_CONVERSION = YES; 262 | CLANG_WARN_CONSTANT_CONVERSION = YES; 263 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 264 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 265 | CLANG_WARN_EMPTY_BODY = YES; 266 | CLANG_WARN_ENUM_CONVERSION = YES; 267 | CLANG_WARN_INFINITE_RECURSION = YES; 268 | CLANG_WARN_INT_CONVERSION = YES; 269 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 270 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 271 | CLANG_WARN_UNREACHABLE_CODE = YES; 272 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 273 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 274 | COPY_PHASE_STRIP = NO; 275 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 276 | ENABLE_NS_ASSERTIONS = NO; 277 | ENABLE_STRICT_OBJC_MSGSEND = YES; 278 | GCC_C_LANGUAGE_STANDARD = gnu99; 279 | GCC_NO_COMMON_BLOCKS = YES; 280 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 281 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 282 | GCC_WARN_UNDECLARED_SELECTOR = YES; 283 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 284 | GCC_WARN_UNUSED_FUNCTION = YES; 285 | GCC_WARN_UNUSED_VARIABLE = YES; 286 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 287 | MTL_ENABLE_DEBUG_INFO = NO; 288 | SDKROOT = iphoneos; 289 | TARGETED_DEVICE_FAMILY = "1,2"; 290 | VALIDATE_PRODUCT = YES; 291 | }; 292 | name = Release; 293 | }; 294 | 0C399E881F5C4C4F003F18FC /* Debug */ = { 295 | isa = XCBuildConfiguration; 296 | buildSettings = { 297 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 298 | DEVELOPMENT_TEAM = Z5E3E2D8FE; 299 | INFOPLIST_FILE = ImageToVideo/Info.plist; 300 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 301 | PRODUCT_BUNDLE_IDENTIFIER = com.liudongxu.ImageToVideo; 302 | PRODUCT_NAME = "$(TARGET_NAME)"; 303 | }; 304 | name = Debug; 305 | }; 306 | 0C399E891F5C4C4F003F18FC /* Release */ = { 307 | isa = XCBuildConfiguration; 308 | buildSettings = { 309 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 310 | DEVELOPMENT_TEAM = Z5E3E2D8FE; 311 | INFOPLIST_FILE = ImageToVideo/Info.plist; 312 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 313 | PRODUCT_BUNDLE_IDENTIFIER = com.liudongxu.ImageToVideo; 314 | PRODUCT_NAME = "$(TARGET_NAME)"; 315 | }; 316 | name = Release; 317 | }; 318 | /* End XCBuildConfiguration section */ 319 | 320 | /* Begin XCConfigurationList section */ 321 | 0C399E6B1F5C4C4F003F18FC /* Build configuration list for PBXProject "ImageToVideo" */ = { 322 | isa = XCConfigurationList; 323 | buildConfigurations = ( 324 | 0C399E851F5C4C4F003F18FC /* Debug */, 325 | 0C399E861F5C4C4F003F18FC /* Release */, 326 | ); 327 | defaultConfigurationIsVisible = 0; 328 | defaultConfigurationName = Release; 329 | }; 330 | 0C399E871F5C4C4F003F18FC /* Build configuration list for PBXNativeTarget "ImageToVideo" */ = { 331 | isa = XCConfigurationList; 332 | buildConfigurations = ( 333 | 0C399E881F5C4C4F003F18FC /* Debug */, 334 | 0C399E891F5C4C4F003F18FC /* Release */, 335 | ); 336 | defaultConfigurationIsVisible = 0; 337 | defaultConfigurationName = Release; 338 | }; 339 | /* End XCConfigurationList section */ 340 | }; 341 | rootObject = 0C399E681F5C4C4F003F18FC /* Project object */; 342 | } 343 | -------------------------------------------------------------------------------- /ImageToVideo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ImageToVideo.xcodeproj/project.xcworkspace/xcuserdata/liudongxu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo.xcodeproj/project.xcworkspace/xcuserdata/liudongxu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ImageToVideo.xcodeproj/xcuserdata/liudongxu.xcuserdatad/xcschemes/ImageToVideo.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 | -------------------------------------------------------------------------------- /ImageToVideo.xcodeproj/xcuserdata/liudongxu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ImageToVideo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 0C399E6F1F5C4C4F003F18FC 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ImageToVideo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ImageToVideo 4 | // 5 | // Created by 刘东旭 on 2017/9/3. 6 | // Copyright © 2017年 刘东旭. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /ImageToVideo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ImageToVideo 4 | // 5 | // Created by 刘东旭 on 2017/9/3. 6 | // Copyright © 2017年 刘东旭. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // 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. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // 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. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // 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. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // 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. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/0.imageset/7-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo/Assets.xcassets/0.imageset/7-1.jpg -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/0.imageset/7-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo/Assets.xcassets/0.imageset/7-2.jpg -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/0.imageset/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo/Assets.xcassets/0.imageset/7.jpg -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/0.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "7.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "7-1.jpg", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "7-2.jpg", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/1.imageset/1-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo/Assets.xcassets/1.imageset/1-1.jpg -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/1.imageset/1-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo/Assets.xcassets/1.imageset/1-2.jpg -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/1.imageset/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo/Assets.xcassets/1.imageset/1.jpg -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/1.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "1.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "1-1.jpg", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "1-2.jpg", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/2.imageset/2-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo/Assets.xcassets/2.imageset/2-1.jpg -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/2.imageset/2-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo/Assets.xcassets/2.imageset/2-2.jpg -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/2.imageset/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo/Assets.xcassets/2.imageset/2.jpg -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "2.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "2-1.jpg", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "2-2.jpg", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/3.imageset/3-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo/Assets.xcassets/3.imageset/3-1.jpg -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/3.imageset/3-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo/Assets.xcassets/3.imageset/3-2.jpg -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/3.imageset/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo/Assets.xcassets/3.imageset/3.jpg -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/3.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "3.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "3-1.jpg", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "3-2.jpg", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/4.imageset/4-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo/Assets.xcassets/4.imageset/4-1.jpg -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/4.imageset/4-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo/Assets.xcassets/4.imageset/4-2.jpg -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/4.imageset/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo/Assets.xcassets/4.imageset/4.jpg -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/4.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "4.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "4-1.jpg", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "4-2.jpg", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/5.imageset/5-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo/Assets.xcassets/5.imageset/5-1.jpg -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/5.imageset/5-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo/Assets.xcassets/5.imageset/5-2.jpg -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/5.imageset/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo/Assets.xcassets/5.imageset/5.jpg -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/5.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "5.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "5-1.jpg", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "5-2.jpg", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/6.imageset/6-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo/Assets.xcassets/6.imageset/6-1.jpg -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/6.imageset/6-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo/Assets.xcassets/6.imageset/6-2.jpg -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/6.imageset/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github-liuxu/ImageToVideo/7a3eefdee9f0b3b04dca4b390795424400cc3fa9/ImageToVideo/Assets.xcassets/6.imageset/6.jpg -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/6.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "6.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "6-1.jpg", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "6-2.jpg", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /ImageToVideo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ImageToVideo/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 | -------------------------------------------------------------------------------- /ImageToVideo/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 | -------------------------------------------------------------------------------- /ImageToVideo/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 | -------------------------------------------------------------------------------- /ImageToVideo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // ImageToVideo 4 | // 5 | // Created by 刘东旭 on 2017/9/3. 6 | // Copyright © 2017年 刘东旭. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /ImageToVideo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // ImageToVideo 4 | // 5 | // Created by 刘东旭 on 2017/9/3. 6 | // Copyright © 2017年 刘东旭. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import 11 | #import 12 | #import 13 | 14 | @interface ViewController () 15 | 16 | { 17 | NSMutableArray *imageArr;//未压缩的图片 18 | NSMutableArray *imageArray;//经过压缩的图片 19 | } 20 | 21 | @property (nonatomic, strong) NSString *theVideoPath; 22 | 23 | @end 24 | 25 | @implementation ViewController 26 | 27 | - (void)viewDidLoad { 28 | [super viewDidLoad]; 29 | imageArray = [[NSMutableArray alloc] init]; 30 | imageArr =[[NSMutableArray alloc]initWithObjects: 31 | [UIImage imageNamed:@"1"],[UIImage imageNamed:@"2"],[UIImage imageNamed:@"3"],[UIImage imageNamed:@"4"],[UIImage imageNamed:@"5"],[UIImage imageNamed:@"6"],[UIImage imageNamed:@"0"],nil]; 32 | 33 | for (int i = 0; i%@",moviePath); 90 | // iphone提供了AVFoundation库来方便的操作多媒体设备,AVAssetWriter这个类可以方便的将图像和音频写成一个完整的视频文件 91 | AVAssetWriter *videoWriter = [[AVAssetWriter alloc] initWithURL:[NSURL fileURLWithPath:moviePath] fileType:AVFileTypeQuickTimeMovie error:&error]; 92 | 93 | NSParameterAssert(videoWriter); 94 | if(error) 95 | NSLog(@"error =%@", [error localizedDescription]); 96 | //mov的格式设置 编码格式 宽度 高度 97 | NSDictionary *videoSettings =[NSDictionary dictionaryWithObjectsAndKeys:AVVideoCodecH264,AVVideoCodecKey, 98 | [NSNumber numberWithInt:size.width],AVVideoWidthKey, 99 | [NSNumber numberWithInt:size.height],AVVideoHeightKey,nil]; 100 | 101 | AVAssetWriterInput *writerInput =[AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoSettings]; 102 | 103 | NSDictionary*sourcePixelBufferAttributesDictionary =[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:kCVPixelFormatType_32ARGB],kCVPixelBufferPixelFormatTypeKey,nil]; 104 | // AVAssetWriterInputPixelBufferAdaptor提供CVPixelBufferPool实例, 105 | // 可以使用分配像素缓冲区写入输出文件。使用提供的像素为缓冲池分配通常 106 | // 是更有效的比添加像素缓冲区分配使用一个单独的池 107 | AVAssetWriterInputPixelBufferAdaptor *adaptor =[AVAssetWriterInputPixelBufferAdaptor assetWriterInputPixelBufferAdaptorWithAssetWriterInput:writerInput sourcePixelBufferAttributes:sourcePixelBufferAttributesDictionary]; 108 | 109 | NSParameterAssert(writerInput); 110 | NSParameterAssert([videoWriter canAddInput:writerInput]); 111 | 112 | if ([videoWriter canAddInput:writerInput]) 113 | { 114 | NSLog(@"11111"); 115 | } 116 | else 117 | { 118 | NSLog(@"22222"); 119 | } 120 | 121 | [videoWriter addInput:writerInput]; 122 | 123 | [videoWriter startWriting]; 124 | [videoWriter startSessionAtSourceTime:kCMTimeZero]; 125 | 126 | //合成多张图片为一个视频文件 127 | dispatch_queue_t dispatchQueue =dispatch_queue_create("mediaInputQueue",NULL); 128 | int __block frame =0; 129 | [writerInput requestMediaDataWhenReadyOnQueue:dispatchQueue usingBlock:^{ 130 | //写入时的逻辑:将数组中的每一张图片多次写入到buffer中, 131 | while([writerInput isReadyForMoreMediaData]) 132 | {//数组中一共7张图片此时写入490次 133 | if(++frame >=[imageArray count]*imageArray.count*10) 134 | { 135 | [writerInput markAsFinished]; 136 | [videoWriter finishWriting]; 137 | // [videoWriterfinishWritingWithCompletionHandler:nil]; 138 | break; 139 | } 140 | CVPixelBufferRef buffer =NULL; 141 | //每张图片写入70次换下一张 142 | int idx =frame/(imageArray.count*10); 143 | NSLog(@"idx==%d",idx); 144 | //将图片转成buffer 145 | buffer = (CVPixelBufferRef)[self pixelBufferFromCGImage:[[imageArray objectAtIndex:idx] CGImage] size:size]; 146 | 147 | if (buffer) 148 | {//添加buffer并设置每个buffer出现的时间,每个buffer的出现时间为第n张除以30(30是一秒30张图片,帧率,也可以自己设置其他值)所以为frame/30,即CMTimeMake(frame,30)为每一个buffer出现的时间点 149 | if(![adaptor appendPixelBuffer:buffer withPresentationTime:CMTimeMake(frame,30)])//设置每秒钟播放图片的个数 150 | { 151 | NSLog(@"FAIL"); 152 | } 153 | else 154 | { 155 | NSLog(@"OK"); 156 | } 157 | 158 | CFRelease(buffer); 159 | } 160 | } 161 | }]; 162 | 163 | } 164 | 165 | - (CVPixelBufferRef)pixelBufferFromCGImage:(CGImageRef)image size:(CGSize)size { 166 | NSDictionary *options =[NSDictionary dictionaryWithObjectsAndKeys: 167 | [NSNumber numberWithBool:YES],kCVPixelBufferCGImageCompatibilityKey, 168 | [NSNumber numberWithBool:YES],kCVPixelBufferCGBitmapContextCompatibilityKey,nil]; 169 | CVPixelBufferRef pxbuffer =NULL; 170 | CVReturn status =CVPixelBufferCreate(kCFAllocatorDefault,size.width,size.height,kCVPixelFormatType_32ARGB,(__bridge CFDictionaryRef) options,&pxbuffer); 171 | 172 | NSParameterAssert(status ==kCVReturnSuccess && pxbuffer !=NULL); 173 | 174 | CVPixelBufferLockBaseAddress(pxbuffer,0); 175 | 176 | void *pxdata =CVPixelBufferGetBaseAddress(pxbuffer); 177 | NSParameterAssert(pxdata !=NULL); 178 | CGColorSpaceRef rgbColorSpace=CGColorSpaceCreateDeviceRGB(); 179 | // 当你调用这个函数的时候,Quartz创建一个位图绘制环境,也就是位图上下文。当你向上下文中绘制信息时,Quartz把你要绘制的信息作为位图数据绘制到指定的内存块。一个新的位图上下文的像素格式由三个参数决定:每个组件的位数,颜色空间,alpha选项 180 | CGContextRef context =CGBitmapContextCreate(pxdata,size.width,size.height,8,4*size.width,rgbColorSpace,kCGImageAlphaPremultipliedFirst); 181 | NSParameterAssert(context); 182 | //使用CGContextDrawImage绘制图片 这里设置不正确的话 会导致视频颠倒 183 | // 当通过CGContextDrawImage绘制图片到一个context中时,如果传入的是UIImage的CGImageRef,因为UIKit和CG坐标系y轴相反,所以图片绘制将会上下颠倒 184 | CGContextDrawImage(context,CGRectMake(0,0,CGImageGetWidth(image),CGImageGetHeight(image)), image); 185 | // 释放色彩空间 186 | CGColorSpaceRelease(rgbColorSpace); 187 | // 释放context 188 | CGContextRelease(context); 189 | // 解锁pixel buffer 190 | CVPixelBufferUnlockBaseAddress(pxbuffer,0); 191 | 192 | return pxbuffer; 193 | } 194 | 195 | //播放 196 | -(void)playAction 197 | { 198 | NSLog(@"************%@",self.theVideoPath); 199 | NSURL *sourceMovieURL = [NSURL fileURLWithPath:self.theVideoPath]; 200 | AVAsset *movieAsset = [AVURLAsset URLAssetWithURL:sourceMovieURL options:nil]; 201 | AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:movieAsset]; 202 | AVPlayer *player = [AVPlayer playerWithPlayerItem:playerItem]; 203 | AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player]; 204 | playerLayer.frame = self.view.layer.bounds; 205 | playerLayer.videoGravity = AVLayerVideoGravityResizeAspect; 206 | [self.view.layer addSublayer:playerLayer]; 207 | [player play]; 208 | } 209 | 210 | 211 | - (void)didReceiveMemoryWarning { 212 | [super didReceiveMemoryWarning]; 213 | // Dispose of any resources that can be recreated. 214 | } 215 | 216 | 217 | @end 218 | -------------------------------------------------------------------------------- /ImageToVideo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ImageToVideo 4 | // 5 | // Created by 刘东旭 on 2017/9/3. 6 | // Copyright © 2017年 刘东旭. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ImageToVideo 2 | 核心代码为,给AVAssetWriterInput加一个适配器对象这样就可以写入PixelBuffer,之后将图片转成PixelBuffer写入即可 3 | //mov的格式设置 编码格式 宽度 高度 4 | NSDictionary *videoSettings =[NSDictionary dictionaryWithObjectsAndKeys:AVVideoCodecH264,AVVideoCodecKey, 5 | [NSNumber numberWithInt:size.width],AVVideoWidthKey, 6 | [NSNumber numberWithInt:size.height],AVVideoHeightKey,nil]; 7 | AVAssetWriterInput *writerInput =[AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoSettings]; 8 | NSDictionary*sourcePixelBufferAttributesDictionary =[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:kCVPixelFormatType_32ARGB],kCVPixelBufferPixelFormatTypeKey,nil]; 9 | // AVAssetWriterInputPixelBufferAdaptor提供CVPixelBufferPool实例, 10 | // 可以使用分配像素缓冲区写入输出文件。使用提供的像素为缓冲池分配通常 11 | // 是更有效的比添加像素缓冲区分配使用一个单独的池 12 | AVAssetWriterInputPixelBufferAdaptor *adaptor =[AVAssetWriterInputPixelBufferAdaptor assetWriterInputPixelBufferAdaptorWithAssetWriterInput:writerInput sourcePixelBufferAttributes:sourcePixelBufferAttributesDictionary]; 13 | 14 | [writerInput requestMediaDataWhenReadyOnQueue:dispatchQueue usingBlock:^{ 15 | //写入时的逻辑:将数组中的每一张图片多次写入到buffer中, 16 | while([writerInput isReadyForMoreMediaData]) 17 | {//数组中一共7张图片此时写入490次 18 | if(++frame >=[imageArray count]*imageArray.count*10) 19 | { 20 | [writerInput markAsFinished]; 21 | [videoWriter finishWriting]; 22 | // [videoWriterfinishWritingWithCompletionHandler:nil]; 23 | break; 24 | } 25 | CVPixelBufferRef buffer =NULL; 26 | //每张图片写入70次换下一张 27 | int idx =frame/(imageArray.count*10); 28 | NSLog(@"idx==%d",idx); 29 | //将图片转成buffer 30 | buffer = (CVPixelBufferRef)[self pixelBufferFromCGImage:[[imageArray objectAtIndex:idx] CGImage] size:size]; 31 | if (buffer) 32 | {//添加buffer并设置每个buffer出现的时间,每个buffer的出现时间为第n张除以30(30是一秒30张图片,帧率,也可以自己设置其他值)所以为frame/30,即CMTimeMake(frame,30)为每一个buffer出现的时间点 33 | if(![adaptor appendPixelBuffer:buffer withPresentationTime:CMTimeMake(frame,30)])//设置每秒钟播放图片的个数 34 | { 35 | NSLog(@"FAIL"); 36 | } 37 | else 38 | { 39 | NSLog(@"OK"); 40 | } 41 | CFRelease(buffer); 42 | } 43 | } 44 | }]; 45 |    以下为图片转buffer 46 | - (CVPixelBufferRef)pixelBufferFromCGImage:(CGImageRef)image size:(CGSize)size { 47 | NSDictionary *options =[NSDictionary dictionaryWithObjectsAndKeys: 48 | [NSNumber numberWithBool:YES],kCVPixelBufferCGImageCompatibilityKey, 49 | [NSNumber numberWithBool:YES],kCVPixelBufferCGBitmapContextCompatibilityKey,nil]; 50 | CVPixelBufferRef pxbuffer =NULL; 51 | CVReturn status =CVPixelBufferCreate(kCFAllocatorDefault,size.width,size.height,kCVPixelFormatType_32ARGB,(__bridge CFDictionaryRef) options,&pxbuffer); 52 | NSParameterAssert(status ==kCVReturnSuccess && pxbuffer !=NULL); 53 | CVPixelBufferLockBaseAddress(pxbuffer,0); 54 | void *pxdata =CVPixelBufferGetBaseAddress(pxbuffer); 55 | NSParameterAssert(pxdata !=NULL); 56 | CGColorSpaceRef rgbColorSpace=CGColorSpaceCreateDeviceRGB(); 57 | // 当你调用这个函数的时候,Quartz创建一个位图绘制环境,也就是位图上下文。当你向上下文中绘制信息时,Quartz把你要绘制的信息作为位图数据绘制到指定的内存块。一个新的位图上下文的像素格式由三个参数决定:每个组件的位数,颜色空间,alpha选项 58 | CGContextRef context =CGBitmapContextCreate(pxdata,size.width,size.height,8,4*size.width,rgbColorSpace,kCGImageAlphaPremultipliedFirst); 59 | NSParameterAssert(context); 60 | //使用CGContextDrawImage绘制图片 这里设置不正确的话 会导致视频颠倒 61 | // 当通过CGContextDrawImage绘制图片到一个context中时,如果传入的是UIImage的CGImageRef,因为UIKit和CG坐标系y轴相反,所以图片绘制将会上下颠倒 62 | CGContextDrawImage(context,CGRectMake(0,0,CGImageGetWidth(image),CGImageGetHeight(image)), image); 63 | // 释放色彩空间 64 | CGColorSpaceRelease(rgbColorSpace); 65 | // 释放context 66 | CGContextRelease(context); 67 | // 解锁pixel buffer 68 | CVPixelBufferUnlockBaseAddress(pxbuffer,0); 69 | return pxbuffer; 70 | } 71 | --------------------------------------------------------------------------------