I am using avcapturesession with a preset AVCaptureSessionPresetMedium to capture video, i am applying effect on this video with opengl using shaders. I use assetWriter to write the video to an mp4 file. The problem is that the resulted video is slow specially when I add audio output.
This is how my code works :
- In - (void)captureOutput:(AVCaptureOutput *)captureOutput... function I apply the opengl filter to the captured frames
- then check if the captureoutput is video or audio if it's video, I use glReadPixels to create a CVPixelBufferRef that I send to an AVAssetWriterInputPixelBufferAdaptor to write it
- if it's audio, I write directly the CMSampleBufferRef
If someone can tell me what's wrong with my approach or which part is supposed to make the resulted video slow?