NSInvalidArgumentException * +[AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:] - NULL sample buffer.
This seems to happen if you take too many (too fast) photos in a row.
Well it says in the documentation:
This method throws an NSInvalidArgumentException if jpegSampleBuffer is NULL or not in the JPEG format.
So it probably means that the data being expected by the JPEG processor is not in the buffer yet (if you take pictures too quickly).
So either you check your imageSampleBuffer
for NULL
or what I did: I wrapped the entire thing in an if-statement checking: CMSampleBufferIsValid(imageSampleBuffer)
but don't really know if that is the correct way to safeguard this. Documentation is a bit sparse around.
Like always, check for error.
[self.stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection
completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error)
{
if (!error) {
Also just incase, here's (IBAction)didTakePhoto
if (self.captureSession.isRunning) {
[self captureNow];
//Custom capture method.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With