1

我用这个方法初始化 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 *)connection

不会被调用。在 IOS4 中调用了这个方法,知道为什么会这样吗?

4

1 回答 1

2

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

于 2012-10-12T22:50:42.267 回答