Open tonychan818 opened 9 years ago
Try this:
[recorder capturePhoto:^(NSError *error, UIImage *image) {
if (image) {
[self showImageOverlayWithUIImage:image];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failed to capture photo" message:error.localizedDescription delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
}];
Hope that helps!! Just need to convert to Swift :)
You should get this effect without the need to generate an image anyway since when you switch camera modes the last frame stays on screen until the mode is changed... Try this code when switching camera modes
#define kVideoPreset AVCaptureSessionPresetHigh
#define kPhotoPreset AVCaptureSessionPresetPhoto
if ([recorder.captureSessionPreset isEqualToString:kPhotoPreset]) {
recorder.captureSessionPreset = kVideoPreset;
} else {
recorder.captureSessionPreset = kPhotoPreset;
}
I found that there would be some delay while switching from Video to Photo preset. You can put a UIVisualEffectView with blur effect to have a behaviour similar to the Native Camera App when it switches from video to photo mode.
You can use -[SCRecorder snapshotOfLastVideoBuffer]
may be you should snap the last video buffer when switch the device.
I wanna use SCRecorder for both photo and video capture. but when switching between them, there is a 2 seconds delay. I wanna make a image to cover it. and I created this function for get the screen.
func captureVideoScreen(imageCapturedCB:((img:UIImage)->())){
but i got this error 2015-08-28 16:02:02.815 TCMedia[853:106239] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* Cannot add output <AVCaptureStillImageOutput: 0x1706241c0> to capture session <AVCaptureSession: 0x17020a590 [AVCaptureSessionPresetPhoto]> <AVCaptureDeviceInput: 0x17482d660 [Back Camera]> -> <AVCaptureVideoDataOutput: 0x17482d000> <AVCaptureDeviceInput: 0x17482d660 [Back Camera]> -> <AVCaptureStillImageOutput: 0x17482d3a0> <AVCaptureDeviceInput: 0x17482d660 [Back Camera]> -> <AVCaptureVideoPreviewLayer: 0x174426180> <AVCaptureDeviceInput: 0x17482dc00 [iPhone 咪高風]> -> <AVCaptureAudioDataOutput: 0x17482d240> because more than one output of the same type is unsupported.'
any idea?