Next Level is a media capture camera library for iOS written in Swift.
| Features | |
|---|---|
| π¬ | βVine-likeβ video clip recording and editing |
| πΌ | photo capture (raw, jpeg, and from a video frame) |
| π | customizable gestural interaction and user interface |
| π· | dual camera, wide angle, and telephoto device support |
| π’ | adjustable frame rate on supported hardware (ie fast/slow motion capture) |
| π | video zoom |
| β | white balance, focus, and exposure adjustment |
| π¦ | flash and torch support |
| π― | mirroring support |
| β | configurable encoding and compression settings |
| π | simple media capture and editing API |
| π | extensible API for image processing and CV |
| π¦ | Swift 3 |
Quick Start
# CocoaPods pod "NextLevel", "~> 0.1.0" 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.1.0 # 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.
Overview
Recording 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 NextLevel.sharedInstance.deviceDelegate = self NextLevel.sharedInstance.videoDelegate = self NextLevel.sharedInstance.photoDelegate = 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
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 { // } }) //.. }
Videos can also be processed using the NextLevelSessionExporter, a media transcoding library in Swift.
Documentation
You can find the docs here. Documentation is generated with jazzy and hosted on GitHub-Pages.
About
Next Level was a little weekend project that turned into something more useful. The software provides foundational components for advanced media recording, camera interface customization, and gestural interaction customization for iOS. The same capabilities can also be found in apps such as Snapchat, Instagram, and Vine.
The goal is to continue to provide a good foundation for quick integration β allowing everyone to focus on the functionality that can builds on this. The API provides a means to perform realtime image processing, computer vision methods, augmented reality, or even new cinematographic recording 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
Community
NextLevel is a community β contributions and discussions are welcome!
Project
- 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.
Stickers
If you found this project to be helpful, check out the Next Level stickers.
You can use this sign up link for a $10 credit.
If other projects have interest in providing a similar hex sticker, it conforms to the sticker standard used by several node projects.
Resources
- iOS Device Camera Summary
- AV Foundation Programming Guide
- AV Foundation Framework Reference
- Swift Evolution
- objc.io Camera and Photos
- objc.io Video
- objc.io Core Image and Video
- Cameras, ecommerce and machine learning
- Again, iPhone is the default camera
License
NextLevel is available under the MIT license, see the LICENSE file for more information.
