rahimizad / NextLevel

⬆️ Rad Media Capture in Swift

Home Page:http://nextlevel.engineering

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Next Level

Next Level is a media capture camera library for iOS written in Swift.

Build Status Pod Version

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.

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

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

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

License

NextLevel is available under the MIT license, see the LICENSE file for more information.

About

⬆️ Rad Media Capture in Swift

http://nextlevel.engineering

License:Other


Languages

Language:Swift 98.9%Language:Objective-C 0.7%Language:Ruby 0.2%Language:Shell 0.2%