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 |
# 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.
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.
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 used by several node projects.
Import the library.
import NextLevel
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 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.
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.
- 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
- iOS Device Camera Summary
- AV Foundation Programming Guide
- AV Foundation Framework Reference
- Swift Evolution
- objc.io Camera and Photos
- objc.io Video
- Cameras, ecommerce and machine learning
NextLevel is available under the MIT license, see the LICENSE file for more information.