avfoundation

Changing AVCaptureDeviceInput leads to AVAssetWriterStatusFailed

风格不统一 提交于 2020-01-20 04:55:09
问题 I am trying to change the Camera View Front and Back .it is working well.if video is recorded without flipping with Pause/Record Option it is working fine.But if we Flip Camera View once then, further recording video is not saving which leads to AVAssetWriterStatusFailed - The operation could not be completed . Can anybody help me to find where i have gone wrong ? Below is my code. Camera.m - (void)flipCamera{ NSArray * inputs = _session.inputs; for ( AVCaptureDeviceInput * INPUT in inputs )

Preventing AVCaptureVideoPreviewLayer from rotating, but allow UI layer to rotate with orientation

大城市里の小女人 提交于 2020-01-20 03:34:31
问题 I have two view controllers. One is the root VC and contains the UI interface such as the record button. On this view controller, I also display the view of another VC at index 0. This view contains a AVCaptureVideoPreviewLayer. I would like my video camera to mimic the Apple video camera app, where the interface layout adjusts with the rotation, but the video preview layer does not. You can see how the recording timer (UILabel) in the stock video app disappears and reappears at the top

Custom Camera and Crop image in Swift

纵饮孤独 提交于 2020-01-16 17:09:58
问题 I have created a custom camera and have implemented below code to crop the taken image, I have shown guides in the preview layer so I want to crop the image which appears in that area. func imageByCropToRect(rect:CGRect, scale:Bool) -> UIImage { var rect = rect var scaleFactor: CGFloat = 1.0 if scale { scaleFactor = self.scale rect.origin.x *= scaleFactor rect.origin.y *= scaleFactor rect.size.width *= scaleFactor rect.size.height *= scaleFactor } var image: UIImage? = nil; if rect.size.width

Custom Camera and Crop image in Swift

╄→гoц情女王★ 提交于 2020-01-16 17:09:08
问题 I have created a custom camera and have implemented below code to crop the taken image, I have shown guides in the preview layer so I want to crop the image which appears in that area. func imageByCropToRect(rect:CGRect, scale:Bool) -> UIImage { var rect = rect var scaleFactor: CGFloat = 1.0 if scale { scaleFactor = self.scale rect.origin.x *= scaleFactor rect.origin.y *= scaleFactor rect.size.width *= scaleFactor rect.size.height *= scaleFactor } var image: UIImage? = nil; if rect.size.width

Creating a video from the visible window or view

陌路散爱 提交于 2020-01-16 14:56:21
问题 I have requirement to record video from the visible view.i,e not form camera. like in TalkingTom application. Can any suggest the solution. 回答1: You can take screenshot (using UIGetScreenImage) and store the images into an array. Then convert it into video using mpeg coder. 来源: https://stackoverflow.com/questions/4335886/creating-a-video-from-the-visible-window-or-view

AVPlayerViewController not loading remote URL

£可爱£侵袭症+ 提交于 2020-01-16 05:18:08
问题 I'm trying to play a remote MP4 video in an AVPlayerViewController : self.vcVideo = [[AVPlayerViewController alloc] init]; self.vcVideo.player = [AVPlayer playerWithURL:[NSURL URLWithString:videoURL]]; [self presentViewController:self.vcVideo animated:YES completion:^{ [self.vcVideo.player play]; }]; The view controller is presented but the play button is disabled: This is on iOS 9. 回答1: In iOS9 security policy is changed. In your log you should see something about the security. I believe

AVCaptureSession, AVCaptureAudioDataOutput and background Music

[亡魂溺海] 提交于 2020-01-16 04:05:05
问题 I record audio/video with AVFoundation using AVCaptureVideoDataOutput and AVCaptureAudioDataOutput . But when I add my AVCaptureAudioDataOutput to my AVCaptureSession , AVFoundation stop background music (in my case from iPod app). So I'm looking for a solution to let my music playing during my record ? Thanks, Alak ps: I'm targeting iOS8 and I user Swift 2.0 回答1: do { try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, withOptions:

How to accurately set fast shutter speeds (exposure duration) on an AVCaptureDevice?

亡梦爱人 提交于 2020-01-15 06:31:47
问题 I'm working on a camera app for IOS (13). For that I use an AVCaptureSession in conjunction with an AVCaptureVideoPreviewLayer. So far everything works fine. Now I want to let the user choose and set a custom shutter speed (exposure duration) out of an given array of typical shutter speed values (in 1/3-exposure-stops) as an [Int32]: let shutterSpeedValues: [Int32] = [1, 2, 3, 4, 5, 6, 8, 10, 13, 15, 20, 25, 30, 40, 50, 60, 80, 100, 125, 160, 200, 250, 320, 400, 500, 640, 800, 1000, 1250,

Using AVFoundation to scan PDF417 barcodes

别等时光非礼了梦想. 提交于 2020-01-14 13:46:06
问题 I have a working iOS barcode scanner using the new AVFoundation barcode scanning classes in iOS 7. I can successfully get a string representation of a 1D barcode (for example, a UPC barcode) but I also need to scan two dimensional PDF417 barcodes. I can't seem to figure out how to get a string representation (or any representation) of the data stored in a PDF417 barcode. The scanner recognizes the barcode and returns a AVMetadataMachineReadableCodeObject but sending the stringValue message to

Generating thumbnails from videos created using AVAssetWriter

血红的双手。 提交于 2020-01-14 10:13:29
问题 I'm recording video+audio using AVAssetWriter and the captureOutput callback. The problem is that in about 5% of the cases I cannot generate a thumbnail from second zero(If I try to go further in the video, then there is no problem). The error I'm getting is: Error Domain=AVFoundationErrorDomain Code=-11832 "Cannot Open" UserInfo=0x4b31b0 {NSLocalizedFailureReason=This media cannot be used., NSUnderlyingError=0x4effb0 "The operation couldn’t be completed. (OSStatus error -12431.)",