Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Mar 7, 2023. It is now read-only.
/PBJVisionPublic archive

📸 iOS Media Capture – features touch-to-record video, slow motion, and photography

License

NotificationsYou must be signed in to change notification settings

piemonte/PBJVision

Repository files navigation

PBJVision

PBJVision

PBJVision is a camera library for iOS that enables easy integration of special capture features and camera interface customizations in your iOS app.Next Level is the Swift counterpart.

Build StatusPod VersionGitHub license

Features

  • touch-to-record video capture
  • slow motion capture (120 fps onsupported hardware)
  • photo capture
  • customizable user interface and gestural interactions
  • ghosting (onion skinning) of last recorded segment
  • flash/torch support
  • white balance, focus, and exposure adjustment support
  • mirroring support

Capture is also possible without having to use the touch-to-record gesture interaction as the sample project provides.

About

This library was originally created atDIY as a fun means for kids to author video and share theirskills. The touch-to-record interaction was pioneered byVine andInstagram.

Thanks to everyone who has contributed and helped make this a fun project and community.

Quick Start

PBJVision is available and recommended for installation using the dependency managerCocoaPods.

To integrate, just add the following line to yourPodfile:

pod'PBJVision'

Usage

Import the header.

#import"PBJVision.h"

Setup the camera preview using[[PBJVision sharedInstance] previewLayer].

// preview and AV layer    _previewView = [[UIViewalloc]initWithFrame:CGRectZero];    _previewView.backgroundColor = [UIColorblackColor];CGRect previewFrame = CGRectMake(0,60.0f, CGRectGetWidth(self.view.frame), CGRectGetWidth(self.view.frame));    _previewView.frame = previewFrame;    _previewLayer = [[PBJVisionsharedInstance]previewLayer];    _previewLayer.frame = _previewView.bounds;    _previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;    [_previewView.layeraddSublayer:_previewLayer];

If your view controller is managed by a Storyboard, keep the previewLayer updated for device sizes

- (void)viewDidLayoutSubviews{    _previewLayer.frame = _previewView.bounds;}

Setup and configure thePBJVision controller, then start the camera preview.

- (void)_setup{    _longPressGestureRecognizer.enabled =YES;    PBJVision *vision = [PBJVisionsharedInstance];    vision.delegate = self;    vision.cameraMode = PBJCameraModeVideo;    vision.cameraOrientation = PBJCameraOrientationPortrait;    vision.focusMode = PBJFocusModeContinuousAutoFocus;    vision.outputFormat = PBJOutputFormatSquare;    [visionstartPreview];}

Start/pause/resume recording.

- (void)_handleLongPressGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer{switch (gestureRecognizer.state) {case UIGestureRecognizerStateBegan:        {if (!_recording)                [[PBJVisionsharedInstance]startVideoCapture];else                [[PBJVisionsharedInstance]resumeVideoCapture];break;        }case UIGestureRecognizerStateEnded:case UIGestureRecognizerStateCancelled:case UIGestureRecognizerStateFailed:        {            [[PBJVisionsharedInstance]pauseVideoCapture];break;        }default:break;    }}

End recording.

    [[PBJVisionsharedInstance]endVideoCapture];

Handle the final video output or error accordingly.

- (void)vision:(PBJVision *)vision capturedVideo:(NSDictionary *)videoDict error:(NSError *)error{if (error && [error.domainisEqual:PBJVisionErrorDomain] && error.code == PBJVisionErrorCancelled) {NSLog(@"recording session cancelled");return;    }elseif (error) {NSLog(@"encounted an error in video capture (%@)", error);return;    }    _currentVideo = videoDict;NSString *videoPath = [_currentVideoobjectForKey:PBJVisionVideoPathKey];    [_assetLibrarywriteVideoAtPathToSavedPhotosAlbum:[NSURLURLWithString:videoPath]completionBlock:^(NSURL *assetURL,NSError *error1) {        UIAlertView *alert = [[UIAlertViewalloc]initWithTitle:@"Video Saved!"message:@"Saved to the camera roll."delegate:selfcancelButtonTitle:nilotherButtonTitles:@"OK",nil];        [alertshow];    }];}

To specify an automatic end capture maximum duration, set the following property on the 'PBJVision' controller.

    [[PBJVisionsharedInstance]setMaximumCaptureDuration:CMTimeMakeWithSeconds(5,600)];// ~ 5 seconds

To adjust the video quality and compression bit rate, modify the following properties on thePBJVision controller.

    @property (nonatomic, copy)NSString *captureSessionPreset;    @property (nonatomic)CGFloat videoBitRate;    @property (nonatomic)NSInteger audioBitRate;    @property (nonatomic)NSDictionary *additionalCompressionProperties;

Community

Contributions and discussions are welcome!

Project

Related Projects

Resources

License

PBJVision is available under the MIT license, see theLICENSE file for more information.


[8]ページ先頭

©2009-2025 Movatter.jp