Objective c 委托回调中的CMSampleBufferRef参数为空

Objective c 委托回调中的CMSampleBufferRef参数为空,objective-c,macos,avfoundation,screen-capture,cmsamplebufferref,Objective C,Macos,Avfoundation,Screen Capture,Cmsamplebufferref,我正在使用此代码创建AVCaptureSession,但当调用-(void)captureOutput:(AVCaptureOutput*)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)SampleBufferfromConnection:(AVCaptureConnection*)连接时,sampleBuffer大小为0 - (BOOL)createCaptureSession:(NSError **)outError{ /* C

我正在使用此代码创建AVCaptureSession,但当调用
-(void)captureOutput:(AVCaptureOutput*)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)SampleBufferfromConnection:(AVCaptureConnection*)连接时,sampleBuffer大小为0

- (BOOL)createCaptureSession:(NSError **)outError{
/* Create a capture session. */
self.captureSession = [[AVCaptureSession alloc] init];
if ([self.captureSession canSetSessionPreset:AVCaptureSessionPresetHigh])
{
    /* Specifies capture settings suitable for high quality video and audio output. */
    [self.captureSession setSessionPreset:AVCaptureSessionPresetHigh];
}

/* Add the main display as a capture input. */
display = CGMainDisplayID();
self.captureScreenInput = [[AVCaptureScreenInput alloc] initWithDisplayID:display];
if ([self.captureSession canAddInput:self.captureScreenInput])
{
    [self.captureSession addInput:self.captureScreenInput];
}
else
{   NSLog(@"nevyslo");
    return NO;
}

/* Register for notifications of errors during the capture session so we can display an alert. */
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(captureSessionRuntimeErrorDidOccur:) name:AVCaptureSessionRuntimeErrorNotification object:self.captureSession];


AVCaptureVideoDataOutput *output = [[AVCaptureVideoDataOutput alloc] init];
[self.captureSession addOutput:output];

dispatch_queue_t queue = dispatch_queue_create("myQueue", NULL);
[output setSampleBufferDelegate:self queue:queue];

[self.captureSession startRunning];
    return YES;
}
我的方法有什么问题吗?这个错误可能在别的地方吗? 我正在使用ARC

编辑
缓冲区不是空的,但它立即被释放。通过保留缓冲区来解决。谢谢

您想如何处理样本缓冲区?您应该在问题中包括您的
captureOutput:didOutputSampleBuffer:fromConnection:
方法。您想如何处理示例缓冲区?您应该在问题中包括您的
captureOutput:didOutputSampleBuffer:fromConnection:
方法。