I am trying to put in a 150 CMSampleBufferRef array that I get from my iPhone camcorder. Somehow, the camera stops calling the delegate after 13 buffers. I tried working with NSMutableArray, CFArray. nothing helped. I suspect this is something with memory, but I don't know anything about warning the memory.
I will be happy for helping with this.
Thanks in advance.
session = [[AVCaptureSession alloc]init]; //Quality Preset if ([session canSetSessionPreset:AVCaptureSessionPresetLow]) { session.sessionPreset = AVCaptureSessionPresetLow; } [session beginConfiguration]; AVCaptureDevice *videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; AVCaptureDeviceInput *newVideoDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:nil]; AVCaptureVideoDataOutput *output = [[AVCaptureVideoDataOutput alloc] init]; output.videoSettings = @{ (NSString *)kCVPixelBufferPixelFormatTypeKey : @(kCVPixelFormatType_32BGRA) }; dispatch_queue_t queue = dispatch_queue_create("MyQueue", NULL); [output setSampleBufferDelegate:self queue:queue]; [session addOutput:output]; [session addInput:newVideoDeviceInput]; AVCaptureConnection *conn = [output connectionWithMediaType:AVMediaTypeVideo]; if (conn.supportsVideoMinFrameDuration) conn.videoMinFrameDuration = CMTimeMake(1, 10); if (conn.supportsVideoMaxFrameDuration) conn.videoMaxFrameDuration = CMTimeMake(1, 10); [session commitConfiguration]; arr = CFArrayCreateMutable( NULL, 150, &kCFTypeArrayCallBacks ); counter=0; [session startRunning];
That was my StartRecording method.
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection { if (counter==150) { [self StopRecording:nil]; return; } CFArrayInsertValueAtIndex(arr, counter, sampleBuffer); counter= (counter+1)%150; } @end
Tha buffer collection method.
source share