草庐IT

iphone - 为什么 AVCaptureStillImageOutput jpegStillImageNSDataRepresentation 会抛出带有 NULL 样本缓冲区的异常?

coder 2023-07-29 原文

NSInvalidArgumentException * +[AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:] - NULL 样本缓冲区。

如果连续拍摄太多(太快)的照片,似乎会发生这种情况。

最佳答案

嗯,它在文档中说:

This method throws an NSInvalidArgumentException if jpegSampleBuffer is NULL or not in the JPEG format.

所以这可能意味着 JPEG 处理器需要的数据还没有在缓冲区中(如果你拍照太快的话)。

因此,要么你检查你的 imageSampleBuffer 是否有 NULL,要么我做的:我将整个事情包装在一个 if 语句检查中:CMSampleBufferIsValid(imageSampleBuffer) 但真的不知道这是否是保护它的正确方法。文档有点稀疏。

关于iphone - 为什么 AVCaptureStillImageOutput jpegStillImageNSDataRepresentation 会抛出带有 NULL 样本缓冲区的异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8452072/

有关iphone - 为什么 AVCaptureStillImageOutput jpegStillImageNSDataRepresentation 会抛出带有 NULL 样本缓冲区的异常?的更多相关文章

随机推荐