A simple, customizable camera control - video recorder for iOS.
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:###
###Version 5.0 notes:###
###Version 4.2 notes:###
New features:
###Version 4.1 notes:###
Merged some PRs:
###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.
pod ‘LLSimpleCamera’, ‘~> 4.1’
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;
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.
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.
Ömer Faruk Gül
Some significant changes have been made at both internal structure and api.