I'm trying to add a watermark/logo on a video that I'm recording using AVFoundation's AVCaptureVideoDataOutput.The problem I'm having is that the transparent parts of the UIImage are black once written to the video.What I'm doing wrong ?
CVPixelBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(buffer);
....
....
CIImage *image = [[CIImage alloc] initWithData:logoData];
CVPixelBufferLockBaseAddress( pixelBuffer, 0 );
CIContext *ciContext = [CIContext contextWithOptions:nil];
CGColorSpaceRef cSpace = CGColorSpaceCreateDeviceRGB();
[ciContext render:image toCVPixelBuffer:pixelBuffer bounds:CGRectMake(image.extent.origin.x, image.extent.origin.y - 2, image.extent.size.width, image.extent.size.height) colorSpace:cSpace];
CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
CGColorSpaceRelease(cSpace);