2

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 :

  1. In - (void)captureOutput:(AVCaptureOutput *)captureOutput... function I apply the opengl filter to the captured frames
  2. 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
  3. 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?

genpfault
  • 51,148
  • 11
  • 85
  • 139
Mirka_09
  • 21
  • 1
  • You mean it's slow as in the program runs too slow and you're dropping frames or you're writing every frame but the final video is playing at e.g. 1/2 speed? If the former then have you run your program through Instruments? – Tommy Apr 26 '11 at 15:35
  • The problem is when i capture audio with the video, i think i drop frames. Because when i capture only video and save it without the audio I get a good speed. – Mirka_09 Apr 26 '11 at 16:06

0 Answers0