Hi I am currently working on an app which needs to capture a Video and at the same time should be able to take frames to blend them.
The problem I am having is that my frames coming from:
func captureOutput(
captureOutput: AVCaptureOutput!,
didOutputSampleBuffer sampleBuffer:
CMSampleBuffer!,
fromConnection connection: AVCaptureConnection!
)will drop after blending about 10-12 frames. I tried blending every 10th frame but it will still drop after 10-12 blended frames.
I know that I should copy the CVImageBuffer to release the imageBuffer which I got using the following:
let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)I also know that
func CMSampleBufferCreateCopy(
_ allocator: CFAllocator?,
_ sbuf: CMSampleBuffer,
_ sbufCopyOut: UnsafeMutablePointer<CMSampleBuffer?>
) -> OSStatusonly creates shallow copies and won't help releasing the original imageBuffer
So my question is: How can I create a complete deep copy of a CMSmapleBuffer or CVImageBuffer?
I would like to use:
func CMSampleBufferCreate(
_ allocator: CFAllocator?,
_ dataBuffer: CMBlockBuffer?,
_ dataReady: Bool,
_ makeDataReadyCallback: CMSampleBufferMakeDataReadyCallback?,
_ makeDataReadyRefcon: UnsafeMutablePointer<Void>,
_ formatDescription: CMFormatDescription?,
_ numSamples: CMItemCount,
_ numSampleTimingEntries: CMItemCount,
_ sampleTimingArray: UnsafePointer<CMSampleTimingInfo>,
_ numSampleSizeEntries: CMItemCount,
_ sampleSizeArray: UnsafePointer<Int>,
_ sBufOut: UnsafeMutablePointer<CMSampleBuffer?>
) -> OSStatusBut the function is a bit overwhelming and I don't know where to get all the attributes from.
I am sure I can take a lot from the given CMSampleBuffer.
I've been looking for a solution for a couple of days now.
If you need more context please feel free to ask.
I hope somone can help.