avcapturesession

IOS adding UIProgressView to AVFoundation AVCaptureMovieFileOutput

a 夏天 提交于 2019-12-06 13:35:55
问题 I am using AVCaptureMovieFileOutput to record videos and I want to add a UIProgressView to represent how much time there is left before the video stops recording. I set a max duration of 15 seconds: CMTime maxDuration = CMTimeMakeWithSeconds(15, 50); [[self movieFileOutput] setMaxRecordedDuration:maxDuration]; I can't seem to find if AVCaptureMovieFileOutput has a callback for when the video is recording or for when recording begins. My question is, how can I get updates on the progress of

IOS Toggle AVFoundation Camera

▼魔方 西西 提交于 2019-12-06 13:24:52
In my App I'm capturing images using AVFoundation I made a button to switch between front and back cameras but it won't work. Here's the code I used : if (captureDevice.position == AVCaptureDevicePositionFront) { for ( AVCaptureDevice *device in [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo] ) { if ( device.position == AVCaptureDevicePositionBack) { NSError * error; AVCaptureDeviceInput * newDeviceInput = [[AVCaptureDeviceInput alloc]initWithDevice:device error:&error]; [captureSesion beginConfiguration]; for (AVCaptureDeviceInput *oldInput in [captureSesion inputs]) { [captureSesion

How to resolve AVCaptureSession v AVAudioSession conflict in iOS?

拜拜、爱过 提交于 2019-12-06 10:18:11
问题 I'm trying to run an AVCaptureSession in a view controller, but within the same, I'm also calling a function from a library that uses AVAudioSession. I can't seem to get much info out of the debugger, other than it crashes exactly when I call this particular library's function. The library is libpd: https://github.com/libpd and it calls AVAudioSession as sharedInstance. I call libpd as: [self.audioController configurePlaybackWithSampleRate:44100 numberChannels:2 inputEnabled:YES mixingEnabled

Weird bug with AVCaptureSession

不羁岁月 提交于 2019-12-06 07:25:49
I use the following code to set up an AVCaptureSession, record a video file, and play it back: Sometimes this works just fine, and other times I get a black screen on playback. As far as I can tell it's completely random. When the bug happens, if I try to open the file in quicktime, i get a "file cannot be opened, format not recognized" message. This leads me to believe its a recording issue rather than a playback issue. Also, if comment out the part of the code which adds the microphone input, the bug does not occur (but my video file doesn't have an audio track of course)...so maybe the

AVCaptureSession returning blank image on iPhone 3G only

余生长醉 提交于 2019-12-06 06:29:13
问题 I'm using Apple's example code for AVCaptureSession, and the UIImage that gets created is completely blank. This only happens on the iPhone 3G, along with a unique error that shows up on console that says - Error: CGDataProviderCreateWithCopyOfData: vm_copy failed: status 2. I've researched the error online and found this StackOverflow answer, and it gets rid of the error...but the image is still blank. Has anyone else experienced this and know how to fix it? Thanks in advance. My Code -

iOS Swift 2 Record Video AVCaptureSession

末鹿安然 提交于 2019-12-06 06:00:39
问题 I created an AVCaptureSession and attached to it the front facing camera do { try captureSession.addInput(AVCaptureDeviceInput(device: captureDevice)) }catch{print("err")} Now I want to start and stop recording on touche events. How do I do this? override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { print("touch") //Start Recording } override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) { print("release"); //End Recording and Save } 回答1: You

Using CATransform3D to create flip animation

感情迁移 提交于 2019-12-06 03:21:51
I'm trying to recreate UIViewAnimationTransitionFlipFromRight (and left). My reason for doing so, as shown below, is to make changes to AVCaptureVideoPreviewLayer in the middle of the animation, when the layer is obstructed. UIViewAnimationTransitionFlipFromRight won't let me stop the animation half way, make session changes, and continue, so here is my best shot at it. While this works, it's just not the same as UIViewAnimationTransitionFlipFromRight. The layer starts to rotate, but more of a slide, backwards and diagonally (very hard to describe), and then reverses for the second part of the

Audio/video out of sync after switch camera

≡放荡痞女 提交于 2019-12-05 23:21:47
问题 I'm try create application where I can record video from different cameras on device during recording. For example. User press button "start record" from front camera, after 5 second recording user press button "Switch Camera" and application change video source from front to back camera and recording continue. For camera swithcing I use next code: NSError *error; AVCaptureDeviceInput *newVideoInput; AVCaptureDevicePosition currentCameraPosition = [[videoInput device] position]; if

Pause & resume video capture using AVCaptureMovieFileOutput and AVCaptureVideoDataOutput in iOS

爷,独闯天下 提交于 2019-12-05 16:53:06
问题 I have to implement functionality to repeatedly pause and resume video capture in a single session, but have each new segment (the captured segments after each pause) added to the same video file, with AVFoundation . Currently, every time I press "stop" then "record" again, it just saves a new video file to my iPhone's Document directory and starts capturing to a new file. I need to be able to press the "record/stop" button over, only capture video & audio when record is active... then when

AVCaptureSession fails when returning from background

家住魔仙堡 提交于 2019-12-05 08:03:07
I have a camera preview window which is working well 90% of the time. Sometimes however, when returning to my app if it's been in the background, the preview will not display. This is the code I call when the view loads: - (void) startCamera { session = [[AVCaptureSession alloc] init]; session.sessionPreset = AVCaptureSessionPresetPhoto; AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session]; captureVideoPreviewLayer.frame = _cameraView.bounds; [_cameraView.layer addSublayer:captureVideoPreviewLayer]; captureVideoPreviewLayer