A simple, customizable camera control - video recorder for iOS.

Overview

LLSimpleCamera: A simple customizable camera - video recorder control

Screenshot

LLSimpleCamera is a library for creating a customized camera - video recorder screens similar to snapchat's. You don't have to present the camera in a new view controller.

You can also use my LLVideoEditor library to easily edit recorded videos.

###LLSimpleCamera:###

  • lets you easily capture photos and record videos
  • handles the position and flash of the camera
  • hides the nitty gritty details from the developer
  • doesn't have to be presented in a new modal view controller, simply can be embedded inside any of your VCs. (like Snapchat)

###Version 5.0 notes:###

  • Better recording API
  • Improved reliability

###Version 4.2 notes:### New features:

  • zoom feature
  • white balance configuration
  • attaching to view controller improved

###Version 4.1 notes:### Merged some PRs:

  • camera mirroring option
  • implementation of *- (instancetype)initWithCoder:(NSCoder )aDecoder

###Version 4.0 notes:### Thanks to the open source community, recently I have merged about 10 PR's to make this library much better and reliable. Also I did some cleanups which contains some breaking changes (sorry for that). Therefore I'm incrementing the major version.

Install

pod 'LLSimpleCamera', '~> 4.1'

Example usage

Initialize the LLSimpleCamera

CGRect screenRect = [[UIScreen mainScreen] bounds];

// create camera with standard settings
self.camera = [[LLSimpleCamera alloc] init];

// camera with video recording capability
self.camera =  [[LLSimpleCamera alloc] initWithVideoEnabled:YES];

// camera with precise quality, position and video parameters.
self.camera = [[LLSimpleCamera alloc] initWithQuality:AVCaptureSessionPresetHigh
                                             position:LLCameraPositionRear
                                         videoEnabled:YES];
// attach to the view
[self.camera attachToViewController:self withFrame:CGRectMake(0, 0, screenRect.size.width, screenRect.size.height)];

To capture a photo:

// capture
[self.camera capture:^(LLSimpleCamera *camera, UIImage *image, NSDictionary *metadata, NSError *error) {
    if(!error) {    
        // we should stop the camera, since we don't need it anymore. We will open a new vc.
        // this very important, otherwise you may experience memory crashes
        [camera stop];
            
        // show the image
        ImageViewController *imageVC = [[ImageViewController alloc] initWithImage:image];
        [self presentViewController:imageVC animated:NO completion:nil];
       }
}];

To start recording a video:

// start recording
NSURL *outputURL = [[[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"test1"] URLByAppendingPathExtension:@"mov"];
[self.camera startRecordingWithOutputUrl:outputURL didRecord:^(LLSimpleCamera *camera, NSURL *outputFileUrl, NSError *error) {
    VideoViewController *vc = [[VideoViewController alloc] initWithVideoUrl:outputFileUrl];
    [self.navigationController pushViewController:vc animated:YES];
}];

To stop recording the video:

[self.camera stopRecording];

Changing the focus layer and animation:

- (void)alterFocusBox:(CALayer *)layer animation:(CAAnimation *)animation;

Adding the camera controls

You have to add your own camera controls (flash, camera switch etc). Simply add the controls to the view where LLSimpleCamera is attached to. You can see a full camera example in the example project. Download and try it on your device.

Stopping and restarting the camera

You should never forget to stop the camera either after the capture block is triggered, or inside somewhere -viewWillDisappear of the parent controller to make sure that the app doesn't use the camera when it is not needed. You can call -start() to reuse the camera. So it may be good idea to to place -start() inside -viewWillAppear or in another relevant method.

Contact

Ömer Faruk Gül

Personal Site

[email protected]

Version History

Version 3.0.0

  • added video recording capability
  • class is heavily refactored

Version 2.2.0

  • camera permissions are supported, if the permission is not given by the user, onError will be triggered.
  • camera flash methods are altered. Now you have to call - (BOOL)updateFlashMode:(CameraFlash)cameraFlash;
  • cameraFlash and cameraPosition property names are simplified to: flash and position.
  • added support for device orientation in case your vc orientation is locked but you want to use the device orientation no matter what.

Version 2.1.1

  • freezing the screen just after the photo is taken for better user experience.

Version 2.1.0

  • added an extra parameter exactSeenImage:(BOOL)exactSeenImage to -capture method to easily get the exact seen image on the screen instead of the raw uncropped image. The default value is NO.
  • fixed an orientation bug inside capture method.

Version 2.0.0

Some significant changes have been made at both internal structure and api.

  • added tap to focus feature (it is fully customizable, if you don't like the default layer and animation)
  • removed delegates and added blocks
  • interface is significantly improved

Version 1.1.1

  • fixed a potential crash scenario if -stop() is called multiple times

Version 1.1.0

  • fixed a problem that sometimes caused a crash after capturing a photo.
  • improved code structure, didChangeDevice delegate is now also triggered for the first default device.
Comments
  • Provide an option for camera mirror.

    Provide an option for camera mirror.

    This PR will provide a new option for CameraMirror.

    • Auto: Only set mirror on when using the front camera, this will make sure that the resulting media(video/picture) is flipped properly.
    • On: Always mirror.
    • Off: No mirror.
    opened by siong1987 7
  • Torch/flash not working (iOS 8)

    Torch/flash not working (iOS 8)

    Hello guys.

    I couldn't make flash/torch work on iOS 8. I tried to turn the flash on in both my own project and LLSimpleCamera's example and it didn't work neither.

    I tried to workaround as well but I didn't got any success.

    Anybody notice that?

    Thanks.

    opened by lms11 7
  • Images turn out way too dark

    Images turn out way too dark

    I am taking pictures with LLSimpleCamera This is my setup:

    fullsizerender

    Now I did two pictures. The first turns out to be ok:

    92b58a0c-2-0

    But the second one is way too dark and has a shift in color towards blue. Even though the image looks OK on the screen when taking it.

    92b58a0c-2-1

    Internal reference #37

    opened by besi 5
  • Feature request: Pause/resume recording

    Feature request: Pause/resume recording

    Kayıt yaparken, kayıdı pause moduna alıp, ardından tekrar resume edebilmek ve bunların aynı dosyada toplanıp çıktısı verilirse büyük bir eksiği kapanmış olur library'nin.

    opened by batuhansk 4
  • setOnError on Swift

    setOnError on Swift

    Does anyone know how to set onError on Swift? I know in Objective-C, you can do:

    [self.camera setOnError:^(LLSimpleCamera *camera, NSError *error) {
        // Something
    }];
    

    but on Swift, I don't have access to setOnError. I tried doing:

    self.camera.onError = ({(camera : LLSimpleCamera!, error : NSError!) -> Void! in 
        // Something
    })
    

    but I would get an error. I just started working with Swift so this might be a syntax issue. Thanks for the great library and for the help!

    opened by kevinnguy 4
  • fixed video orientation in saved output file

    fixed video orientation in saved output file

    Previously, when the video was saved to an output file, even though the view was responding correctly to the orientation changes, the output file's orientation was wrong (eg. when the camera was in landscape mode, the video was still being saved in portrait, causing the video to be playbacked at a 90 degree flip).

    Now, the movie is saved in the correct orientation to the output file.

    opened by vijay120 3
  • Swift 3 Compatibility

    Swift 3 Compatibility

    Hi, I just updated to Xcode 8 and Swift 3 yesterday, and I'm getting a lot of "Ambiguous use of" errors, specifically with the enums such as "LLCameraPositionFront", and "LLCameraFlashOff", etc. Also, the onError method's error parameter can't find its property domain or code.. the code example I've been using https://github.com/strawb3rryx7/LLSimpleCamera-Swift-Example is now broken... Would you be able to add Swift 3 Compatibility anytime soon? Thanks. The image is here: http://i.imgur.com/T9F6H9P.png

    opened by tonymuu 2
  • Better User Experience to freeze live preview upon taking picture

    Better User Experience to freeze live preview upon taking picture

    IMO it's better User Experience to freeze live preview upon taking picture, rather than freezing live preview only after successfully taken the picture

    opened by ivanfoong 2
  • Quick flash of photo in opposite orientation

    Quick flash of photo in opposite orientation

    When using LLSimpleCamera (the example project or my own implementation of it) after capturing a photo I see a quick flash of the image in the opposite orientation before the imageViewController shows up. So if the device is in portrait mode when I take the photo, I very quickly see a flash of that image in landscape mode and then it goes into portrait again when the imageviewcontroller.

    In my implementation, when I dismiss the imageviewcontroller followed by the camera one I see that sideways flash again quick. Not sure if you're seeing the same thing.

    opened by LeenaMansour 2
  • Clear session after stop

    Clear session after stop

    First of all, my congrats to this awesome library!

    I'm starting a new app that is using your simple camera library. When the user opens the screen it should start the camera with video disabled at first. Current implementation doesn't allow to enable video in a latter time because it reuses the session.

    opened by leonereveel 1
  • [AVCaptureSession startRunning] should be called from background thread

    [AVCaptureSession startRunning] should be called from background thread

    if (@available(iOS 16.0, *)) { [self.session performSelectorInBackground:@selector(startRunning) withObject:nil]; } else { [self.session startRunning]; }

    opened by zengkebing3630 0
  • Captured Image Orientation

    Captured Image Orientation

    Hello, I'm Using this library to capture image and video in my application. Its works fine but problem is there when I'm capturing picture in portrait mode then captured Image return by SDK is landscape. Another Issue when capturing picture with landscape left then result Image 90 degree rotated.

    Please Resolve this issue ASAP.

    opened by KrishnaPatell 0
  • How to Remove the Camera Layer from LLSimpleCamera?

    How to Remove the Camera Layer from LLSimpleCamera?

    I am trying to remove the Camera from my view but I can't. I have tried [camera stop], [self.camera removeFromParentViewController] and self.camera = nil.

    Still it's not removing from super. Could you please provide me a solution for this problem?

    Thanks in advance

    opened by binitvermani 1
Owner
Ömer Faruk Gül
Ömer Faruk Gül
Video and photo camera for iOS

Features: Description Records video ?? takes photos ?? Flash on/off ⚡ Front / Back camera ↕️ Hold to record video ✊ Tap to take photo ?? Tap to focus

André J 192 Dec 17, 2022
Fasttt and easy camera framework for iOS with customizable filters

FastttCamera is a wrapper around AVFoundation that allows you to build your own powerful custom camera app without all the headaches of using AVFounda

IFTTT 1.8k Dec 10, 2022
A light weight & simple & easy camera for iOS by Swift.

DKCamera Description A light weight & simple & easy camera for iOS by Swift. It uses CoreMotion framework to detect device orientation, so the screen-

Bannings 86 Aug 18, 2022
Simple Swift class to provide all the configurations you need to create custom camera view in your app

Camera Manager This is a simple Swift class to provide all the configurations you need to create custom camera view in your app. It follows orientatio

Imaginary Cloud 1.3k Dec 29, 2022
BarcodeScanner is a simple and beautiful wrapper around the camera with barcode capturing functionality and a great user experience.

Description BarcodeScanner is a simple and beautiful wrapper around the camera with barcode capturing functionality and a great user experience. Barco

HyperRedink 1.6k Jan 7, 2023
NextLevel is a Swift camera system designed for easy integration, customized media capture, and image streaming in iOS

NextLevel is a Swift camera system designed for easy integration, customized media capture, and image streaming in iOS. Integration can optionally leverage AVFoundation or ARKit.

NextLevel 2k Jan 2, 2023
Custom camera with AVFoundation. Beautiful, light and easy to integrate with iOS projects.

?? Warning This repository is DEPRECATED and not maintained anymore. Custom camera with AVFoundation. Beautiful, light and easy to integrate with iOS

Tudo Gostoso Internet 1.4k Dec 16, 2022
A fully customisable and modern camera implementation for iOS made with AVFoundation.

Features Extremely simple and easy to use Controls autofocus & exposure Customizable interface Code-made UI assets that do not lose resolution quality

Gabriel Alvarado 1.3k Nov 30, 2022
iOS camera engine with Vine-like tap to record, animatable filters, slow motion, segments editing

SCRecorder A Vine/Instagram like audio/video recorder and filter framework in Objective-C. In short, here is a short list of the cool things you can d

Simon Corsin 3.1k Dec 25, 2022
Camera engine for iOS, written in Swift, above AVFoundation. :monkey:

?? The most advanced Camera framework in Swift ?? CameraEngine is an iOS camera engine library that allows easy integration of special capture feature

Remi ROBERT 575 Dec 25, 2022
A Snapchat Inspired iOS Camera Framework written in Swift

Overview SwiftyCam is a a simple, Snapchat-style iOS Camera framework for easy photo and video capture. SwiftyCam allows users to capture both photos

Andrew Walz 2k Dec 21, 2022
An iOS framework that uses the front camera, detects your face and takes a selfie.

TakeASelfie An iOS framework that uses the front camera, detects your face and takes a selfie. This api opens the front camera and draws an green oval

Abdullah Selek 37 Jan 3, 2023
ALCameraViewController - A camera view controller with custom image picker and image cropping.

ALCameraViewController A camera view controller with custom image picker and image cropping. Features Front facing and rear facing camera Simple and c

Alex Littlejohn 2k Dec 6, 2022
UIView+CameraBackground - Show camera layer as a background to any UIView.

UIView+CameraBackground Show camera layer as a background to any UIView. Features Both front and back camera supported. Flash modes: auto, on, off. Co

Yonat Sharon 63 Nov 15, 2022
Instagram-like photo browser and a camera feature with a few line of code in Swift.

Fusuma is a Swift library that provides an Instagram-like photo browser with a camera feature using only a few lines of code.

Yuta Akizuki 2.4k Dec 31, 2022
This plugin defines a global navigator.camera object, which provides an API for taking pictures and for choosing images from the system's image library.

title description Camera Take pictures with the device camera. AppVeyor Travis CI cordova-plugin-camera This plugin defines a global navigator.camera

null 0 Nov 2, 2021
A camera designed in Swift for easily integrating CoreML models - as well as image streaming, QR/Barcode detection, and many other features

Would you like to use a fully-functional camera in an iOS application in seconds? Would you like to do CoreML image recognition in just a few more sec

David Okun 868 Dec 29, 2022
Mock UIImagePickerController for testing camera based UI in simulator

Mock UIImagePickerController to simulate the camera in iOS simulator.

Yonat Sharon 18 Aug 18, 2022
ScanBarcodes is a SwiftUI view that scans barcodes using an iPhone or iPad camera.

ScanBarcodes ScanBarcodes is a SwiftUI view that scans barcodes using an iPhone or iPad camera. The framework uses AVFoundation for high performance v

NASA Jet Propulsion Laboratory 6 Nov 29, 2022