HiveHicks
HiveHicks

Reputation: 2334

Is there a way to make GPUImageView output existing CMSampleBuffer?

I want to use GPUImageView to output CMSampleBuffer which I receive from my AVCaptureVideoDataOutputSampleBufferDelegate. So, basically, I don't want GPUImage framework to manage AVCaptureSession itself, I just want it to draw what I'd pass to it. Still I can't see any obvious and easy way to do that. Is it even possible?

Upvotes: 1

Views: 517

Answers (1)

krafter
krafter

Reputation: 1432

Here's what you can do, fast and simple:

1.Set up your GPUImage with GPUImageView to output the frames as usual. Just like they do it in examples.

  1. Dive into GPUImageVideoCamera class. Add a delegate there. Like one:

    @protocol GPUImageVideoCameraDelegate @optional

    • (void)videoCameraCaptureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection; @end
  2. Go to GPUImageVideoCamera.m, find the: - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection method.

  3. Add your delegate call in there.

if (self.delegate) { [self.delegate videoCameraCaptureOutput:captureOutput didOutputSampleBuffer:sampleBuffer fromConnection:connection]; }

  1. Set your controller/class/whatever as delegate, videoCamera.delegate = self;

  2. Use the delegate method in your class and do whatever you want with the CMSampleBufferRef.

Make sure you work with CMSampleBufferRef "in-place", meaning - do not copy it into CPU memory if you wish to avoid using relatively slow CPU versus faster GPU.

From there you can set any image into CMSampleBufferRef.

Upvotes: 2

Related Questions