2012-05-14 86 views
1

我的init AVCaptureVideoDataOutput用這種方法:AVCaptureVideoDataOutput問題IOS 5

// Setup the video output 
_videoOutput = [[AVCaptureVideoDataOutput alloc] init]; 
_videoOutput.alwaysDiscardsLateVideoFrames = YES; 
_videoOutput.minFrameDuration = kCMTimeZero; 
_videoOutput.videoSettings = 
[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA],(id)kCVPixelBufferPixelFormatTypeKey 
,AVVideoCodecH264, AVVideoCodecKey, nil]; 

// Setup the audio output 
_audioOutput = [[AVCaptureAudioDataOutput alloc] init]; 

NSLog(@"dispatch_queue_t"); 
// Setup the queue 
dispatch_queue_t queue = dispatch_queue_create("MyQueue", NULL); 
[_videoOutput setSampleBufferDelegate:self queue:queue]; 
[_audioOutput setSampleBufferDelegate:self queue:queue]; 
dispatch_release(queue); 

,我有一個問題,即委託方法:

  • (無效)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer :(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection

是不會被調用的。在iOS4中調用這個方法,任何想法爲什麼會發生?

回答

2

將輸入和輸出添加到會話中。 然後調用[會話啓動運行]。