IOS 5中的AVCaptureVideoDataOutput问题

时间:2012-05-14 15:08:04

标签: iphone objective-c

我用这种方法初始化AVCaptureVideoDataOutput:

// 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);

我有一个问题就是委托方法:

  • (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer    fromConnection:(AVCaptureConnection *)连接

是不会被调用的。在IOS4这个方法调用时,任何想法为什么会发生?

1 个答案:

答案 0 :(得分:2)

向会话添加输入和输出。 然后调用[session startRunning]。