KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am using standard AVFoundation classes to capture video and show preview ( http://developer.apple.com/library/ios/#qa/qa1702/_index.html ) Here is my code: - (void)setupCaptureSession { NSError *error = nil; [self setCaptureSession: [[AVCaptureSession alloc] init]]; self.captureSession.sessionPreset = AVCaptureSessionPresetMedium; device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; if ([device isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus] && [device lockForConfiguration:&error]) { [device setFocusMode:AVCaptureFocusModeContinuousAutoFocus]; [device unlockForConfiguration]; } AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error]; if (!input) { // TODO: Obsługa błędu, gdy nie uda się utworzyć wejścia } [[self captureSession] addInput:input]; AVCaptureVideoDataOutput *output = [[[AVCaptureVideoDataOutput alloc] init] autorelease]; [[self captureSession] addOutput:output]; dispatch_queue_t queue = dispatch_queue_create("myQueue", NULL); [output setSampleBufferDelegate:self queue:queue]; dispatch_release(queue); output.videoSettings = [NSDictionary dictionaryWithObject: [NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelFormatTypeKey]; output.minFrameDuration = CMTimeMake(1, 15); [[self captureSession] startRunning]; AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [AVCaptureVideoPreviewLayer layerWithSession:self.captureSession]; captureVideoPreviewLayer.frame = previewLayer.bounds; [previewLayer.layer insertSublayer:captureVideoPreviewLayer atIndex:0]; [previewLayer setHidden:NO];
Tags (comma-separated)
Save Edits
Cancel