05 GUPImage混合模式滤镜的使用
来源:互联网 发布:java jdk 1.7 中文 编辑:程序博客网 时间:2024/05/18 04:01
前几天一直在研究GPUImage,忽然发现混合模式的滤镜没有使用方法,各种搜索后发现也只是对GPUImage的简单使用,甚至在GPUImage的GitHub上的Demo里面都没有找到这一部分的内容的介绍,花费了很大力气后终于琢磨出来一点用法,可以对两个视频添加滤镜,效果是讲两个视频集成为一个视频,同时显示,中间会有渐变或者高亮等滤镜效果
下面是代码
</pre><pre name="code" class="objc">- (IBAction)blendFilter:(id)sender { NSString *sandBoxPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject]; // 要添加滤镜的视频1 GPUImageMovie *movieFile = [[GPUImageMovie alloc] initWithURL:[NSURL fileURLWithPath:[sandBoxPath stringByAppendingPathComponent:@"movie"]]]; movieFile.runBenchmark = YES; movieFile.playAtActualSpeed = NO; // 要添加滤镜的视频2 GPUImageMovie *movieFile2 = [[GPUImageMovie alloc] initWithURL:[[NSBundle mainBundle] URLForResource:@"video" withExtension:@"mov"]]; movieFile2.runBenchmark = YES; movieFile2.playAtActualSpeed = NO;// GPUImageScreenBlendFilter *filter = [[GPUImageScreenBlendFilter alloc] init]; GPUImageDivideBlendFilter *filter = [[GPUImageDivideBlendFilter alloc] init]; [movieFile addTarget:filter]; [movieFile2 addTarget:filter]; // 添加滤镜后的视频保存的位置 NSString *pathToMovie = [sandBoxPath stringByAppendingPathComponent:@"last.mov"]; unlink([pathToMovie UTF8String]); // If a file already exists, AVAssetWriter won't let you record new frames, so delete the old movie NSLog(@"%@",pathToMovie); NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie]; GPUImageMovieWriter *movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(480.0, 640.0)]; [filter addTarget:movieWriter]; // Configure this for video from the movie file, where we want to preserve all video frames and audio samples movieWriter.shouldPassthroughAudio = YES; //movieFile.audioEncodingTarget = self.movieWriter; [movieFile enableSynchronizedEncodingUsingMovieWriter:movieWriter]; [movieWriter startRecording]; [movieFile startProcessing]; [movieFile2 startProcessing]; // 结束后的回调 [movieWriter setCompletionBlock:^{ [filter removeTarget:movieWriter]; [movieFile endProcessing]; [movieFile2 endProcessing]; [movieWriter finishRecording]; NSLog(@"ok"); }]; }
0 0
- 05 GUPImage混合模式滤镜的使用
- GPUImage混合滤镜的简单使用
- Flash8滤镜与混合模式
- GUPImage库的队列管理
- 设计模式的混合使用
- 【PS滤镜】卷页滤镜的使用
- 减少滤镜的使用
- glow滤镜的使用
- 最小化滤镜的使用
- 【CSS滤镜的使用】
- actionScript中使用形状、遮罩、混合和滤镜
- GPUimage 混合滤镜
- 网卡的混合模式
- 图像滤镜艺术---PS图层混合模式之明度模式
- 图像滤镜艺术---PS图层混合模式之明度模式
- 使用CSS滤镜的方法
- Flash shader滤镜的使用
- AS3 模糊滤镜的使用
- block高级功能
- 中缀表达式转成后缀表达式,以及后缀求值
- ubuntu12.04 lts 安装gcc 4.8
- 第七届蓝桥杯本科B组省赛
- sizeof()、size()、strlen()总结
- 05 GUPImage混合模式滤镜的使用
- margin和padding
- 第五周上机实践项目——项目1-三角形类雏形-(1)
- Spring AOP编程
- Java多线程锁异常:IllegalMonitorStateException
- SVN——项目合作必不可少的工具
- C日记——快速排序
- nyoj999 师傅又被妖怪抓走了 (预处理+bfs+状态压缩)
- 51nod1428 活动安排问题