码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 合并带有透明通道的视频-

时间:2015-02-05 09:34:15      阅读:400      评论:0      收藏:0      [点我收藏+]

标签:ios开发

视频的合成,透明通道是大家所熟知的

      透明通道是一个致力于公益活动全程透明化的组织。
在图形图像学中,透明通道也称Alpha通道,代表数字图像中像素点的透明信息。白色的Alpha像素用以定义不透明的彩色像素,而黑色的Alpha定以透明像素,黑白之间的灰阶则是彩色图片中的半透明部分。-----摘自百度百科

所以在合并雪花,灯光,爆破。。。 这里就需要有透明通道的视频。
这里我用的是GPUImage 这个工具,可以讲雪花无缝隙的结合起来,说到这里,大家最好会使用一点ps,在图片滤镜处理的时候,可以通过ps来看看参数和效果
通过ps实验,发现滤色可以做到这一点。GPUImageScreenBlendFilter 可以结局这个事情。
详细的GPUImage的头文件点击这里----http://blog.csdn.net/think_ma/article/details/43093331
不说了code    _movieFile = [[GPUImageMovie alloc] initWithURL:url];
    _movieFile.runBenchmark = YES;
    _movieFile.playAtActualSpeed = NO;
    _movieFile2 = [[GPUImageMovie alloc] initWithURL:url2];
    _movieFile2.runBenchmark = YES;
    _movieFile2.playAtActualSpeed = NO;
    _filter = [[GPUImageScreenBlendFilter alloc] init];
    //    filter = [[GPUImageUnsharpMaskFilter alloc] init];
    [_movieFile addTarget:self.filter];
    [_movieFile2 addTarget:self.filter];
    // Only rotate the video for display, leave orientation the same for recording
    // In addition to displaying to the screen, write out a processed version of the movie to disk
    NSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/last.mov"];
    unlink([pathToMovie UTF8String]); // If a file already exists, AVAssetWriter won't let you record new frames, so delete the old movie
    
    NSLog(@"file = %@",pathToMovie);
    NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie];
    
    self.movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(640.0, 360.0)];
    [self.filter addTarget:self.movieWriter];
    // Configure this for video from the movie file, where we want to preserve all video frames and audio samples
    self.movieWriter.shouldPassthroughAudio = YES;
    //movieFile.audioEncodingTarget = self.movieWriter;
    [_movieFile enableSynchronizedEncodingUsingMovieWriter:self.movieWriter];
    
    [self.movieWriter startRecording];
    [_movieFile startProcessing];
    [_movieFile2 startProcessing];
    __block mlkiMovie * sself = self;
    
    [self.movieWriter setCompletionBlock:^{
        [sself.filter removeTarget:sself.movieWriter];
        [sself.movieFile endProcessing];
        [sself.movieFile2 endProcessing];
        [sself.movieWriter finishRecording];
        NSLog(@"ok");
    }];

GPUImageScreenBlendFilter 相当于ps的滤镜。

iOS 合并带有透明通道的视频-

标签:ios开发

原文地址:http://blog.csdn.net/think_ma/article/details/43513427

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!