NSInvalidArgumentException * + [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:] - NULL樣本緩衝區。爲什麼AVCaptureStillImageOutput jpegStillImageNSDataRepresentation會用NULL樣本緩衝區引發異常?
如果您連續拍攝太多(太快)的照片,這似乎就會發生。
NSInvalidArgumentException * + [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:] - NULL樣本緩衝區。爲什麼AVCaptureStillImageOutput jpegStillImageNSDataRepresentation會用NULL樣本緩衝區引發異常?
如果您連續拍攝太多(太快)的照片,這似乎就會發生。
那麼它說,在文檔中:
此方法拋出NSInvalidArgumentException如果jpegSampleBuffer是JPEG格式NULL與否。
因此,這可能意味着JPEG處理器預期的數據不在緩衝區中(如果您拍照太快)。
因此,要麼你檢查imageSampleBuffer
的NULL
或我做了什麼:我把整個事件封裝在if語句中檢查:CMSampleBufferIsValid(imageSampleBuffer)
,但不知道這是否是保護這一點的正確方法。文檔有點稀疏。
這有什麼更新? – MobileMon
像往常一樣,檢查錯誤。
[self.stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection
completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error)
{
if (!error) {
而且只是櫃面,這裏是(IBAction)didTakePhoto
if (self.captureSession.isRunning) {
[self captureNow];
//Custom capture method.
}
獲得我不知道它的線程相關的同樣的問題。 – ribeto