我似乎无法让GPUImageMovieWriter正常工作。
尽管作者总是建议查看他们的例子;他们都没有能够正确地建立和运行。
所以这是我的代码示例:
ALAsset *asset = (ALAsset *)[self galleryImages][indexPath.row];
NSURL *fileURLForInput = [asset valueForProperty:ALAssetPropertyAssetURL];
GPUImageMovie *movieFile = [[GPUImageMovie alloc] initWithURL:fileURLForInput];
movieFile.runBenchmark = YES;
movieFile.playAtActualSpeed = NO;
NSURL *fileURLForOutput = [NSURL fileURLWithPath:[self getVideoLocalFilePathWithVideoID:videoID]];
GPUImageMovieWriter *movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:fileURLForOutput size:CGSizeMake(640, 480)];
movieWriter.shouldPassthroughAudio = YES;
movieFile.audioEncodingTarget = movieWriter;
[movieFile enableSynchronizedEncodingUsingMovieWriter:movieWriter];
[movieWriter startRecording];
[movieFile startProcessing];
[movieWriter setCompletionBlock:^{
PSLog(@"DONE!");
}];
运行代码示例会导致" EXC_BAD_ACCESS"错误。
如果我要删除这一行:
[movieFile enableSynchronizedEncodingUsingMovieWriter:movieWriter];
应用程序不会崩溃,但输出文件的大小为0字节,永远不会调用完成块。
有什么想法吗? :(
答案 0 :(得分:0)
在开始处理电影之前,您需要致电[movieFile addTarget:movieWriter]
。
答案 1 :(得分:0)
我认为您需要将GPUImageMovie和GPUImageMovieWriter变量设为强属性或实例变量。