'Is it possible to set preferred sample buffer size for AVCaptureOutput?
Say we have an AVCaptureAudioDataOutput
object that has been set up with an AVCaptureSession
to get data samples from the device's microphone.
captureOutput(_:didOutput:from:)
in AVCaptureAudioDataOutputSampleBufferDelegate
always gets called with 2048 bytes of samples. Is it possible to set a preferred sample buffer size?
A basic example:
let output = AVCaptureAudioDataOutput()
output.setSampleBufferDelegate(delegate, queue)
// Add output to AVCaptureSession and start the capture session once everything is set up
...
// In the delegate
public func captureOutput(_ output: AVCaptureOutput,
didOutput sampleBuffer: CMSampleBuffer,
from connection: AVCaptureConnection) {
// sampleBuffer is 2048 bytes, but I want less
let blockBuffer = CMSampleBufferGetDataBuffer(sampleBuffer)
print(CMBlockBufferGetDataLength(blockBuffer!)) // 2048
...
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|