Hi,

Step A:

In your delegate for AVCaptureVideoDataOutput, you can use the method

- (void)captureOutput:(AVCaptureOutput *)captureOutput 
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer 
fromConnection:(AVCaptureConnection *)connection

to grab CMSampleBufferRef representing each frame.  You'll need to get a hold 
of the actual data bytes using various functions for CMSampleBufferRef and/or 
CMBlockBufferRef.  I will assume that you are getting this data back in an RGB 
format.  If not, you'll need to make sure that the requested pixel format 
attributes give you RGB data.

Step B:

Once you get the data buffer, you can get a CIImage using this method:

+ (CIImage *)imageWithBitmapData:(NSData *)d bytesPerRow:(size_t)bpr 
size:(CGSize)size format:(CIFormat)f colorSpace:(CGColorSpaceRef)cs

or you can use a CIImageProvider to create a CIImage.

Step C:

Push your CIImage thru the various CIFilters that you would like to apply.

Step D:

Render your CIImage into a bitmap buffer. Take that data and make a 
CMSampleBufferRef or CVPixelBufferRef, then push that object thru an 
AVAssetWriter object to get the sample written to the destination file.

Note:  This process can take a long time and when done in-line can cause 
captured frames to be dropped, so you'll probably want to copy the incoming 
CMSampleBuffers and process them on a separate thread. Also, the standard 
disclaimers about having written this in an e-mail apply, as well.

Hope that helps.

regards,

douglas

On Dec 28, 2011, at 11:58 PM, 吴明 wrote:

> 
> 
> 
> 
> you know that i want to use this function to my ios app. 
> 
> 
> 
> I know use AVCaptureVideoDataOutputSampleBufferDelegate can get every frame 
> data from capture, but i dont know how to change this data with 
> CVImageBufferRef datatype.
> 
> 
> 在 2011-12-29 01:32:41,"Nick Zitzmann" <n...@chronosnet.com> 写道:
>> 
>> On Dec 27, 2011, at 11:16 PM, 吴明 wrote:
>> 
>>> HI All:
>>> I wont capture view from the camera. and add an image to every frame.then 
>>> save the video to my app.
>>> How do this.
>> 
>> Use QTCaptureView and implement the delegate method -view:willDisplayImage:. 
>> In that method, do what you want to do to the frame, and it will be included 
>> in the final video.
>> 
>> Nick Zitzmann
>> <http://www.chronosnet.com/>
>> 
> 
> 
> 
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/douglas_welton%40earthlink.net
> 
> This email sent to douglas_wel...@earthlink.net

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to