How to convert MTLTexture to CVPixelBuffer

I am writing a metal based camera for recording video which will allow users to pit image overlays on the video. It will also allow them to apply filters to the video (sepia, B&W etc).

I am able to display all of this on an MTKView, but now how do I convert this rendered texture back to video frames so I can write the video to disk?
You would need to use CVMetalTextureCacheCreate and CVMetalTextureCacheCreateTextureFromImage.

There are some examples of this API in the "Mixing Metal and OpenGL Rendering in a View" sample, albeit for a different use case.
How to convert MTLTexture to CVPixelBuffer
 
 
Q