GithubHelp home page GithubHelp logo

mitchellporter / gifcameracontroller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lawrnce/gifcameracontroller

0.0 0.0 0.0 1.56 MB

An implementation of AVCaptureVideoDataOuput that takes successive photos.

License: MIT License

Swift 76.43% Ruby 0.74% Objective-C 16.66% Shell 6.16%

gifcameracontroller's Introduction

Gif Camera Controller

Gif Camera Controller is a camera output that takes successive photos to create GIFs.

Version License Platform

Features

  • Full camera functionality
  • Control frames per second

Usage

Instantiate a GifCameraController and run setupSession() in a do-catch statement. To see the camera's preview use a GifCameraPreview view. Note that GifCameraPreview is currently not supported in interface builder. You must instantiate in code.

var gifCamera: GifCameraController!
var previewView: GifCameraPreviewView!
self.gifCamera = GifCameraController()
do {
    if try self.gifCamera.setupSession() {
    self.gifCamera.setPreviewView(self.previewView)
    }
} catch let error as NSError {
    self.gifCamera = nil
    print(error.localizedDescription)
}

Then set the duration and frames per second.

self.gifCamera.maxDuration = 2.0
self.gifCamera.framesPerSecond = 3

Begin the capture session and start recording.

self.gifCamera.startSession()
self.gifCaemra.startRecording()

When recording finishes, the delegate will output the frames.

Documentation

Variables

var delegate: GifCameraControllerDelegate

The delegate for the camera controller. This must be set.

var maxDuration: Double

The maximum duration of the gif. Defaults to 4 seconds.

var framesPerSecond: Int

The capture rate of the camera. Defaults to 18 fps.

var currentDevicePosition: AVCaptureDevicePosition

The current device position. (read-only)

Methods

func setupSession() throws -> Bool

Setup the camera controller. This must be called before the sessiong begins.

func setPreviewView(view: GifCameraPreviewView)

Adds a preview view to the camera controller. You must instantiate GifCameraPreviewView in code.

func startSession()

Starts the capture session.

func stopSession()

Stops the capture session.

func isRecording() -> Bool

Returns if session is recording.

func startRecording()

Starts recording.

func pauseRecording() 

Pauses recording. Does not reset current parameters.

func cancelRecording()

Stops recording and resets all variables.

func stopRecording()

Ends the recording.

func toggleCamera()

Toggles between the front camera and the back. Note GifCameraController defaults to the front camera.

func toggleTorch(forceKill forceKill: Bool) -> Bool

Toggles the torch and returns if the torch is on. Set forceKill to true to turn off the torch.

Delegate

func cameraController(cameraController: GifCameraController, didFinishRecordingWithFrames frames: [CGImage], withTotalDuration duration: Double)

Returns to the delegate the bitmaps the frames along with the duration of the gif. This is called with stopRecording() or when maxDuration is reached.

func cameraController(cameraController: GifCameraController, didAppendFrameNumber index: Int)

Notifies the delegate that a frame was appended.

Demo

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • Swift 2.0+
  • iOS 8.0+

Installation

GifCameraController is available through CocoaPods. To install it, simply add the following line to your Podfile:

use_frameworks!
pod "GifCameraController"

Author

Lawrence Tran

License

See the LICENSE file for more info.

gifcameracontroller's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.