- Notifications
You must be signed in to change notification settings - Fork19
A video capture framework that can easily apply your custom filters.
License
nkmrh/FilterCam
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
FilterCam is a simple iOS camera framework for recording videos with custom CIFilters applied. Also FilterCam is made very inspired bySwiftyCam.
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 |
iOS 10.0+
Swift 4.1+
FilterCam is available under the MIT license. See the LICENSE file for more info.
Add this toCartfile
github "nkmrh/FilterCam"
$ carthage update FilterCam
FilterCam is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "FilterCam"
Simply copy the contents of the FilterCam folder into your project.
Using FilterCam is very simple.
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>
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 withFilterCamViewController
:
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.
Capturing Video is just as easy. To begin recording video, call thestartRecording
function:
startRecording()
To end the capture of a video, call thestopRecording
function:
stopRecording()
You must implement theFilterCamViewControllerDelegate
and set thecameraDelegate
to your view controller instance:
classMyCameraViewController:FilterCamViewController,FilterCamViewControllerDelegate{overridefunc viewDidLoad(){ super.viewDidLoad() cameraDelegate=self}...}
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}
The torch can be enabled by changing the torchLevel property:
torchLevel=1
Torch level specifies the value between 0.0 and 1.0.
By default, FilterCam will launch to the rear facing camera. This can be changed by changing the defaultCamera property in viewDidLoad:
devicePosition=.front
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.
If you want to specify the preview frame, you can use custom initializer:
MyCameraViewController(previewViewRect: CGRect)
Video quality can be set by the videoQuality property of FilterCamViewController. The choices available AVCaptureSessionPreset.
If you have any questions, requests, or enhancements, feel free to submit a pull request, create an issue.
Hajime Nakamurankmrhj@gmail.com
About
A video capture framework that can easily apply your custom filters.