Next Level is a media capture camera library for iOS written in Swift.
Currently initial beta, several features are being tested and have bugs – these are being addressed.
Features
- simple and extensible API
- camera user interface and gestural interaction customization
- “Vine-like” video clip recording
- slow motion capture on supported hardware (iPhone, iPad)
- video zoom
- white balance, focus, and exposure adjustment
- flash/torch support
- mirroring support
- photo capture
- dual camera, wide angle, telephoto device switching
- Swift 3
Quick Start
# CocoaPods pod "NextLevel", "~> 0.0.1-beta.5" post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['SWIFT_VERSION'] = '3.0' end end end # Carthage github "nextlevel/NextLevel" ~> 0.0.1-beta.5 # Swift PM let package = Package( dependencies: [ .Package(url: "https://github.com/nextlevel/NextLevel", majorVersion: 0) ] )
Alternatively, drop the NextLevel source files or project file into your Xcode project.
Community
NextLevel is a community – contributions and discussions are welcome!
- Feature idea? Open an issue.
- Found a bug? Open an issue.
- Need help? Use Stack Overflow with the tag ’nextlevel’.
- Questions? Use Stack Overflow with the tag 'nextlevel'.
- Want to contribute? Submit a pull request.
Sticker
If you found this project to be helpful, check out the Next Level sticker.
For a $10 credit, use this sign up link.
If other projects have interest in providing something similar, this conforms to the sticker standard which is also used by several node projects.
Overview
Record Video Clips
Import the library.
Setup the camera preview.
let screenBounds = UIScreen.main.bounds self.previewView = UIView(frame: screenBounds) if let previewView = self.previewView { previewView.autoresizingMask = [.flexibleWidth, .flexibleHeight] previewView.backgroundColor = UIColor.black NextLevel.sharedInstance.previewLayer.frame = previewView.bounds previewView.layer.addSublayer(NextLevel.sharedInstance.previewLayer) self.view.addSubview(previewView) }
Configure the capture session.
override func viewDidLoad() { NextLevel.sharedInstance.delegate = self // modify .videoConfiguration, .audioConfiguration, .photoConfiguration properties // Compression, resolution, and maximum recording time options are available NextLevel.sharedInstance.videoConfiguration.maxRecordDuration = CMTimeMakeWithSeconds(5, 600) NextLevel.sharedInstance.audioConfiguration.bitRate = 44000 }
Start/stop the session when appropriate. These methods create a new "session" instance for 'NextLevel.sharedInstance.session' when called.
override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) NextLevel.sharedInstance.start() // … }
override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) NextLevel.sharedInstance.stop() // … }
Video record/pause.
// record NextLevel.sharedInstance.record() // pause NextLevel.sharedInstance.pause()
Editing and finalizing the recorded session.
if let session = NextLevel.sharedInstance.session { //.. // undo session.removeLastClip() // various editing operations can be done using the NextLevelSession methods // export session.mergeClips(usingPreset: AVAssetExportPresetHighestQuality, completionHandler: { (url: URL?, error: Error?) in if let _ = url { // } else if let _ = error { // } }) //.. }
About
Next Level is just a little weekend project that kept going.
The software provides foundational components for advanced media recording, camera interface customization, and gestural interaction customization on iOS. The same capabilities can also be found in apps such as Snapchat, Instagram, Vine, Peach, and others.
It's goal is to provide a good foundation for quick integration – allowing everyone to focus on the functionality that builds on this, such as image processing, computer vision methods including 3D photography, augmented reality, depth of field, or even new technology aided cinematographic techniques.
Related Projects
- Player (Swift), video player in Swift
- PBJVideoPlayer (obj-c), video player in obj-c
- GPUImage2, image processing library
- SCRecorder, obj-c capture library
- PBJVision, obj-c capture library
- NextLevelSessionExporter, media transcoding in Swift
- SDAVAssetExportSession, media transcoding in obj-c
Resources
- iOS Device Camera Summary
- AV Foundation Programming Guide
- AV Foundation Framework Reference
- Swift Evolution
- objc.io Camera and Photos
- objc.io Video
License
NextLevel is available under the MIT license, see the LICENSE file for more information.
