Giter Club home page Giter Club logo

filtercam's Introduction





Overview

FilterCam is a simple iOS camera framework for recording videos with custom CIFilters applied. Also FilterCam is made very inspired by SwiftyCam.

Features

FilterCam
๐Ÿ‘ Support iOS 10.0+
๐ŸŽฅ Video capture
๐Ÿ‘“ Custom filter
๐Ÿ“ˆ Manual image quality settings
๐ŸŽ‰ Front and rear camera support
๐Ÿ”ฆ Support torch
๐Ÿ‘€ Supports manual focus
๐Ÿ”ˆ Background audio support

Requirements

  • iOS 10.0+

  • Swift 4.1+

License

FilterCam is available under the MIT license. See the LICENSE file for more info.

Installation

Carthage:

Add this to Cartfile

github "nkmrh/FilterCam"
$ carthage update FilterCam

Cocoapods:

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

pod "FilterCam"

Manual Installation:

Simply copy the contents of the FilterCam folder into your project.

Usage

Using FilterCam is very simple.

Prerequisites:

As of iOS 10, Apple requires the additon of the NSCameraUsageDescription and NSMicrophoneUsageDescription strings to the info.plist of your application. Example:

<key>NSCameraUsageDescription</key>
	<string>To record video</string>
<key>NSMicrophoneUsageDescription</key>
	<string>To record audio with video</string>

Getting Started:

If you install FilterCam from Cocoapods, be sure to import the module into your View Controller:

import FilterCam

FilterCam is a drop-in convenience framework. To create a Camera instance, create a new UIViewController subclass. Replace the UIViewController subclass declaration with FilterCamViewController:

class MyCameraViewController : FilterCamViewController

That is all that is required to setup the AVSession for photo and video capture. FilterCam will prompt the user for permission to use the camera/microphone, and configure both the device inputs and outputs.

Capture

Capturing Video is just as easy. To begin recording video, call the startRecording function:

startRecording()

To end the capture of a video, call the stopRecording function:

stopRecording()

Delegate

You must implement the FilterCamViewControllerDelegate and set the cameraDelegate to your view controller instance:

class MyCameraViewController : FilterCamViewController, FilterCamViewControllerDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()
        cameraDelegate = self
    }
    ...
}

Delegate methods:

func filterCamDidStartRecording(_ filterCam: FilterCamViewController) {
	// Called when startRecording() is called
}

func filterCamDidFinishRecording(_ filterCame: FilterCamViewController) {
	// Called when stopRecording() is called
}

func filterCam(_ filterCam: FilterCamViewController, didFinishWriting outputURL: URL) {
	// Called when stopRecording() is called and the video is finished processing
	// Returns a URL in the temporary directory where video is stored
}

func filterCam(_ filterCam: FilterCamViewController, didFocusAtPoint tapPoint: CGPoint) {
	// Called when a user initiates a tap gesture on the preview layer
	// Returns a CGPoint of the tap location on the preview layer
}

func filterCam(_ filterCam: FilterCamViewController, didFailToRecord error: Error) {
	// Called when recorder fail to record
}

Torch

The torch can be enabled by changing the torchLevel property:

torchLevel = 1

Torch level specifies the value between 0.0 and 1.0.

Switching Camera

By default, FilterCam will launch to the rear facing camera. This can be changed by changing the defaultCamera property in viewDidLoad:

devicePosition = .front

Configuration

Apply filter

You can apply custom filters by specifying an array of filters in the filters property:

filters = [CIFilter(name: "CIPhotoEffectInstant")!, CIFilter(name: "CIPhotoEffectNoir")!]

filters property type is an array of CIFilter. It is applied sequentially from the first filter.

Preview view

If you want to specify the preview frame, you can use custom initializer:

MyCameraViewController(previewViewRect: CGRect)

Video Quality

Video quality can be set by the videoQuality property of FilterCamViewController. The choices available AVCaptureSessionPreset.

Contact

If you have any questions, requests, or enhancements, feel free to submit a pull request, create an issue.

Hajime Nakamura [email protected]

filtercam's People

Contributors

nkmrh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

filtercam's Issues

Front camera having an mirror.

How can I remove a mirror in front camera? I have tried in

private func handleVideoSampleBuffer(buffer: CMSampleBuffer) {
    filteredImage = filteredImage.transformed(by: CGAffineTransform(scaleX: 1, y: -1))}

It works without start recording. but when I start recording it just black screen record.

Capture some UIView

Hi,
how to add some UIView (for example, or UILabel...) and to be captured on video?

Thanks

Doesn't work with bluetooth headphones

Doesn't record when you have bluetooth headphones (like airpods or beats) connected. Keeps printing out "Could not write audio data, recording aborted" from the didFailToRecord delegate method. Do you have any idea how I can include support for airpods or other bluetooth devices?

I am currently using this in an app and would love to use it in production, but I can't release it until this is fixed.

Thank you so much, any help is appreciated!

Black overlay appearance

Great work guys, Black overlay appeared when i launch the app and took much time to load the camera. Could you guys come up with solution pls.

Unable to make long videos

Firstly, your repo is just great, I guess the only ios solution which provides video recording with filter. But, at my side, the behaviour is a little unexpected. The sample app actually creates video but not of more than 4 seconds. And sometimes not even that. Can you please suggest where I am going wrong?

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.