我尝试使用 GPUImage 混合两个视频。其中之一 (show.mov) 包含绿色背景。
这是 show.mov和 galaxy.mov .
我下载了最新版本的 GPUImage
并更改了 SimpleVideoFileFilter
示例:
- (void)viewDidLoad
{
[super viewDidLoad];
_movie = [[GPUImageMovie alloc] initWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"galaxy" ofType:@"mov"]]];
_greenMovie = [[GPUImageMovie alloc] initWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"snow" ofType:@"mov"]]];
_movie.playAtActualSpeed = YES;
_greenMovie.playAtActualSpeed = YES;
_filter = [[GPUImageChromaKeyBlendFilter alloc] init];
[_greenMovie addTarget:_filter];
[_movie addTarget:_filter];
GPUImageView *filterView = (GPUImageView *)self.view;
[_filter addTarget:filterView];
[_greenMovie startProcessing];
[_movie startProcessing];
}
当我运行项目时(无论是在设备上还是模拟器上),我只看到空白的白色 View ,14 秒后(show.mov 的长度)我只看到混合视频的最后一帧。使用示例中的编写器在磁盘上创建文件,但无法打开该文件。
我正在使用带有 7.0.3 和 XCode 5.0.2 的 iPhone 5
我错过了什么吗?
最佳答案
感谢@BradLarson,他指向一个 github issue我在哪里找到commit导致了这个问题。
在 GPUImageMovie.m
中,我在 startProcessing
方法中注释了两行:
[inputAsset loadValuesAsynchronouslyForKeys:[NSArray arrayWithObject:@"tracks"] completionHandler: ^{
//runSynchronouslyOnVideoProcessingQueue(^{
NSError *error = nil;
AVKeyValueStatus tracksStatus = [inputAsset statusOfValueForKey:@"tracks" error:&error];
if (!tracksStatus == AVKeyValueStatusLoaded)
{
return;
}
blockSelf.asset = inputAsset;
[blockSelf processAsset];
blockSelf = nil;
//});
}];
关于ios - 使用 GPUImage 将两个视频与色度键混合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21728405/