用例:--我想从相机中捕获输入,在捕获的帧(和声音)之上绘制,并将结果保存为.mov文件。
问题:我看不出在将输入保存到文件之前如何修改它。
发布于 2012-06-25 19:24:20
RosyWriter几乎是在做我想做的事。将下面的代码添加到captureOutput:didOutputSampleBuffer:fromConnection:使我能够使用Quartz绘制到框架上。
CVImageBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CVPixelBufferLockBaseAddress(pixelBuffer, 0);
void *pxdata = CVPixelBufferGetBaseAddress(pixelBuffer);
NSParameterAssert(pxdata != NULL);
CGSize frameSize = CGSizeMake(self.videoDimensions.width, self.videoDimensions.height);
CGColorSpaceRef rgbColorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(pxdata, frameSize.width,
frameSize.height, 8, 4*frameSize.width, rgbColorSpace,
kCGImageAlphaNoneSkipFirst);
CGContextMoveToPoint(context, 100, 100);
CGContextAddLineToPoint(context, 200, 200);
CGContextDrawPath(context, kCGPathStroke);
CGColorSpaceRelease(rgbColorSpace);
CGContextRelease(context);https://stackoverflow.com/questions/11159819
复制相似问题