6

I am trying to develop an iPhone app that processes/filters and records video.

I have two sample apps that have aspects of what I need and am trying to combine them.

  1. AVCamDemo from the WWDC10 sample code package (Apple Developer ID required)
    This deals with capturing/recording video.

  2. Brad Larson's ColorTracking sample app referenced here
    This deals with live processing of video using OpenGL ES

I get stuck when trying to combine the two.

What I have been trying to do is to use AVCaptureVideoOutput and the AVCaptureVideoDataOutputSampleBufferProtocol to process/filter the video frames through OpenGL ES (as in -2-), and at the same time somehow use AVCaptureMovieFileOutput to record the processed video (as in -1-).

Is this approach possible? If so, how would I need to set up the connections within the AVSession?

Or do I need to use the AVCaptureVideoDataOutputSampleBufferProtocol to process/filter the video AND then recombine the individual frames back into a movie - without using AVCaptureMovieFileOutput to save the movie file?

Any suggestions for the best approach to accomplish this are much appreciated!

Community
  • 1
  • 1
adriaan
  • 1,574
  • 14
  • 33
  • 2
    You will definitely want to use AVAssetWriter and a pixel buffer adapter to write the processed frames using AVCaptureVideoDataOutputSampleBufferProtocol. Also make sure you capture in (i think) BGRA. This will make it simple to convert the CMSampleBufferRef in order to pass into OpenGL. I believe I have seen something in the API that makes this conversion trivial. I belive CMSampleBufferGetImageBuffer(..) which returns CVImageBufferRef and can be treated as a CVPixelBufferRef. – Steve McFarlin Mar 08 '11 at 20:03
  • Thanks @Steve! AVAssetWriter definitely is the way to go. Based on your comment I've been able to find a few other bits of the puzzle in other SA threads. Will post here once I've got my solution working. – adriaan Mar 09 '11 at 22:58
  • you can use AVAssetWriter API. Maybe this [link](http://stackoverflow.com/questions/4944083/can-use-avcapturevideodataoutput-and-avcapturemoviefileoutput-at-the-same-time) will useful to you – shihongzhi Mar 06 '12 at 07:57

0 Answers0