dav*_*ton 6 iphone opengl-es objective-c ios
我有两个成功的概念,我想现在合并.我成功地将相位框架分层CATextLayer
到CVImageBufferRef
相机框架上,然后通过AVAssetWriter
使用a来保存它AVAssetWriterInputPixelBufferAdaptor
.我这样做:
- (void) processNewBuffer:(CVImageBufferRef)cameraFrame {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
//
// //update CALayer on main queue
// //UIKit is not thread safe
dispatch_sync(dispatch_get_main_queue(), ^{
[self updateCALayer];
});
if(recorder.recording) {
CVPixelBufferLockBaseAddress(cameraFrame,0);
// do stuff with buffer here
uint8_t *baseAddress = (uint8_t *)CVPixelBufferGetBaseAddress(cameraFrame);
size_t bytesPerRow = CVPixelBufferGetBytesPerRow(cameraFrame);
width = CVPixelBufferGetWidth(cameraFrame);
height = CVPixelBufferGetHeight(cameraFrame);
/*Create a CGImageRef from the CVImageBufferRef*/
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef newContext = CGBitmapContextCreate(baseAddress, width, height, 8, bytesPerRow, colorSpace, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst);
[textLayer renderInContext:newContext];
[recorder appendPixelBuffer:cameraFrame withPresentationTime:camera.lastSampleTime];
CVPixelBufferUnlockBaseAddress(cameraFrame,0);
/*We release some components*/
CGContextRelease(newContext);
CGColorSpaceRelease(colorSpace);
}
[pool drain];
}
Run Code Online (Sandbox Code Playgroud)
这就像一个魅力.现在我的第二招.感谢这个问题的答案:
来自OpenGL的CMSampleBuffer用于AVAssestWritter的视频输出
我可以从WWDC 2010示例代码修改OpenGL Teapot示例,并将呈现的内容保存到iPhone上的电影文件中.
现在,我想要的是能够在相机框架的一个角落层叠茶壶,并将捆绑包保存到电影中.我遇到的问题是基本的C东西.当一个缓冲区为1280x720(相机框架)且茶壶位于320x320的缓冲区时,如何从一个缓冲区复制到下一个缓冲区.另一个考虑因素是速度.为了处理30fps,我无法移入和移出CGImageRef或UIImage类.这必须尽快发生.完成此任务的最佳方法是什么?
您可以尝试使用适用于 OpenGL 的 SpriteKit 框架(来自 iOS7),并且应保持高帧速率,处理图像/纹理。
希望能帮助到你
归档时间: |
|
查看次数: |
2007 次 |
最近记录: |