IOS GPUImage制作GIF

需求:手机摄像头录制,生成gif文件(+视频文件 +美颜)

参考:

1、GPUImage图像的输入输出和滤镜通道 https://www.jianshu.com/p/91044a81ec85

2、图片合成gif图 https://blog.csdn.net/nopolun_ios/article/details/56016017

GPUImage录制视频,加美颜 请参考大神其他文章:https://www.jianshu.com/u/815d10a4bdce

新建GPUImageTextureOutput子类,重写方法:

//保存新建buffer

- (void)setInputFramebuffer:(GPUImageFramebuffer*)newInputFramebuffer atIndex:(NSInteger)textureIndex

{

    _newInputFramebuffer= newInputFramebuffer;

    [supersetInputFramebuffer:newInputFramebufferatIndex:textureIndex];

}

//Ready后,加入Array保存

- (void)newFrameReadyAtTime:(CMTime)frameTime atIndex:(NSInteger)textureIndex

{

    [supernewFrameReadyAtTime:frameTimeatIndex:textureIndex];

    [self.bufferArray addObject:_newInputFramebuffer];

}

开始录制时,加入责任链。结束时,从责任链移除,将bufferArray保存的GPUImageFramebuffer,转成UIImage,参考2  合成gif文件。GPUImageFramebuffer转UIImage代码:

 CGImageRef image = [buffer newCGImageFromFramebufferContents];

  UIImage* uiimageF = [UIImageimageWithCGImage:image];


demo地址:https://github.com/shuixuan1225/GPUImage_Gif.git

demo原工程地址:https://github.com/Guikunzhi/BeautifyFaceDemo

你可能感兴趣的:(IOS GPUImage制作GIF)